Documentation ¶
Overview ¶
Package config provides a common infrastructure for reading configuration data stored in local TOML files.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Read ¶
Read takes the TOML configuration file at `path`, parses it into `dest` and then uses github.com/asaskevich/govalidator to validate the struct.
func SetDuration ¶
func SetDuration(co *ConfigOption)
SetDuration converts a command line int to a duration, and stores it in the final config.
func SetURL ¶
func SetURL(co *ConfigOption)
SetURL converts a command line string to a URL, and stores it in the final config.
Types ¶
type ConfigOption ¶
type ConfigOption struct { Name string // e.g. "db-url" EnvVar string // e.g. "DATABASE_URL". Defaults to uppercase/underscore representation of name OptType types.BasicKind // The type of this option, e.g. types.Bool FlagDefault interface{} // A default if no option is provided. Omit or set to `nil` if no default Required bool // Whether this option must be set for Horizon to run Usage string // Help text CustomSetValue func(*ConfigOption) // Optional function for custom validation/transformation ConfigKey interface{} // Pointer to the final key in the linked Config struct }
ConfigOption is a complete description of the configuration of a command line option
func (*ConfigOption) Init ¶
func (co *ConfigOption) Init(cmd *cobra.Command) error
Init handles initialisation steps, including configuring and binding the env variable name.
func (*ConfigOption) Require ¶
func (co *ConfigOption) Require()
Require checks that a required string configuration option is not empty, raising a user error if it is.
func (*ConfigOption) SetValue ¶
func (co *ConfigOption) SetValue()
SetValue sets a value in the global config, using a custom function, if one was provided.
type InvalidConfigError ¶
InvalidConfigError is the error that is returned when an invalid configuration is encountered by the `Read` func.
func (*InvalidConfigError) Error ¶
func (err *InvalidConfigError) Error() string