Documentation ¶
Index ¶
- func BindPFlags(c *FlowConfig, flags *pflag.FlagSet) (bool, error)
- func InitializePFlagSet(flags *pflag.FlagSet, config *FlowConfig)
- func LogConfig(logger *zerolog.Event, flags *pflag.FlagSet) map[string]struct{}
- func RawViperConfig() *viper.Viper
- func Unmarshall(flowConfig *FlowConfig) error
- type FlowConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BindPFlags ¶
func BindPFlags(c *FlowConfig, flags *pflag.FlagSet) (bool, error)
BindPFlags binds the configuration to the cli pflag set. This should be called after all pflags have been parsed. If the --config-file flag has been set the config will be loaded from the specified config file. Args:
c: The Flow configuration that will be used to unmarshall the configuration values into after binding pflags. This needs to be done because pflags may override a configuration value.
Returns:
error: if there is any error encountered binding pflags or unmarshalling the config struct, all errors are considered irrecoverable. bool: true if --config-file flag was set and config file was loaded, false otherwise.
Note: As configuration management is improved, this func should accept the entire Flow config as the arg to unmarshall new config values into.
func InitializePFlagSet ¶
func InitializePFlagSet(flags *pflag.FlagSet, config *FlowConfig)
InitializePFlagSet initializes all CLI flags for the Flow node base configuration on the provided pflag set. Args:
*pflag.FlagSet: the pflag set of the Flow node. *FlowConfig: the config used to set default values on the flags
Note: in subsequent PR's all flag initialization for Flow node should be moved to this func.
func LogConfig ¶
LogConfig logs configuration keys and values if they were overridden with a config file. It also returns a map of keys for which the values were set by a config file.
Parameters:
- logger: *zerolog.Event to which the configuration keys and values will be logged.
- flags: *pflag.FlagSet containing the set flags.
Returns:
- map[string]struct{}: map of keys for which the values were set by a config file.
func RawViperConfig ¶ added in v0.33.1
RawViperConfig returns the raw viper config store. Returns:
*viper.Viper: the raw viper config store.
func Unmarshall ¶
func Unmarshall(flowConfig *FlowConfig) error
Unmarshall unmarshalls the Flow configuration into the provided FlowConfig struct. Args:
flowConfig: the flow config struct used for unmarshalling.
Returns:
error: if there is any error encountered unmarshalling the configuration, all errors are considered irrecoverable.
Types ¶
type FlowConfig ¶
type FlowConfig struct { // ConfigFile used to set a path to a config.yml file used to override the default-config.yml file. ConfigFile string `validate:"filepath" mapstructure:"config-file"` NetworkConfig *netconf.Config `mapstructure:"network-config"` }
FlowConfig Flow configuration.
func DefaultConfig ¶
func DefaultConfig() (*FlowConfig, error)
DefaultConfig initializes the flow configuration. All default values for the Flow configuration are stored in the default-config.yml file. These values can be overridden by node operators by setting the corresponding cli flag. DefaultConfig should be called before any pflags are parsed, this will allow the configuration to initialize with defaults from default-config.yml. Returns:
*FlowConfig: an instance of the network configuration fully initialized to the default values set in the config file error: if there is any error encountered while initializing the configuration, all errors are considered irrecoverable.
func (*FlowConfig) Validate ¶
func (fc *FlowConfig) Validate() error
Validate checks validity of the Flow config. Errors indicate that either the configuration is broken, incompatible with the node's internal state, or that the node's internal state is corrupted. In all cases, continuation is impossible.