config

package
v1.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 12, 2020 License: Apache-2.0 Imports: 5 Imported by: 3

Documentation

Index

Constants

View Source
const (
	AddressS           = "address"
	QtyPurchasedS      = "qty_purchased"
	PurchaseDateS      = "purchase_date"
	UnlockDateS        = "unlock_date"
	NotifyImmediatelyS = "notify_immediately"
	RewardTargetS      = "reward_target"
	DelegationNodeS    = "delegation_node"
	RecourseS          = "recourse_period"
	RewardSourceS      = "reward_source"
	ValidationPublic1S = "validation_public_1"
	ValidationPublic2S = "validation_public_2"
	ValidationScriptS  = "validation_script"
)

each column needs a const string identifier

Variables

This section is empty.

Functions

func DefaultConfigPath

func DefaultConfigPath(ndauhome string) string

DefaultConfigPath returns the default path at which a config file is expected

func WithConfig

func WithConfig(configPath string, lambda func(*Config) error) error

WithConfig wraps configuration editing.

It reads the config file from the specified path, creating a default if necessary. It then calls the provided function with that configuration. If the provided function returns without error, it writes the new configuration to the same path.

Types

type ColumnMap

type ColumnMap map[string]int

ColumnMap is the map of column names to indices

This permits us not to worry about the headers, and instead simply fetch the desired columns directly.

type Config

type Config struct {
	Path        string    `toml:"path"`
	Sheet       string    `toml:"sheet"`
	Columns     ColumnMap `toml:"columns"`
	FirstRow    int       `toml:"first_row"`
	NomsPath    string    `toml:"noms_path"`
	GenesisToml string    `toml:"genesis_toml"`
}

Config is the configuration data used by ETL

func DefaultConfig

func DefaultConfig() (*Config, error)

DefaultConfig creates a default config struct

func LoadConfig

func LoadConfig(configPath string) (*Config, error)

LoadConfig returns a config object loaded from its file

func LoadDefaultConfig

func LoadDefaultConfig(configPath string) (*Config, error)

LoadDefaultConfig returns a config object loaded from its file

If the file does not exist, a default is transparently created

func (*Config) CheckColumns

func (conf *Config) CheckColumns() error

CheckColumns verifies that all expected columns are present

func (*Config) Dump

func (conf *Config) Dump(configPath string) error

Dump writes the given config object to the specified file

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL