Documentation
¶
Overview ¶
Package model contains types for Agent config
Index ¶
- func AddOverride(name string, value interface{})
- func AddOverrideFunc(f func(Config))
- func AddOverrides(vars map[string]interface{})
- func ApplyOverrideFuncs(config Config)
- type Config
- type Loader
- type NotificationReceiver
- type Proxy
- type Reader
- type ReaderWriter
- type Source
- type ValueWithSource
- type Warnings
- type Writer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddOverride ¶
func AddOverride(name string, value interface{})
AddOverride provides an externally accessible method for overriding config variables. This method must be called before Load() to be effective.
func AddOverrideFunc ¶
func AddOverrideFunc(f func(Config))
AddOverrideFunc allows to add a custom logic to override configuration. This method must be called before Load() to be effective.
func AddOverrides ¶
func AddOverrides(vars map[string]interface{})
AddOverrides provides an externally accessible method for overriding config variables. This method must be called before Load() to be effective.
func ApplyOverrideFuncs ¶
func ApplyOverrideFuncs(config Config)
ApplyOverrideFuncs calls overrideFuncs
Types ¶
type Config ¶
type Config interface { ReaderWriter Loader }
Config represents an object that can load and store configuration parameters coming from different kind of sources: - defaults - files - environment variables - flags
type Loader ¶
type Loader interface { SetDefault(key string, value interface{}) SetFs(fs afero.Fs) SetEnvPrefix(in string) BindEnv(input ...string) SetEnvKeyReplacer(r *strings.Replacer) SetEnvKeyTransformer(key string, fn func(string) interface{}) UnmarshalKey(key string, rawVal interface{}, opts ...viper.DecoderConfigOption) error Unmarshal(rawVal interface{}) error UnmarshalExact(rawVal interface{}) error ReadInConfig() error ReadConfig(in io.Reader) error MergeConfig(in io.Reader) error MergeConfigMap(cfg map[string]any) error AddConfigPath(in string) SetConfigName(in string) SetConfigFile(in string) SetConfigType(in string) BindPFlag(key string, flag *pflag.Flag) error // SetKnown adds a key to the set of known valid config keys SetKnown(key string) // BindEnvAndSetDefault sets the default value for a config parameter and adds an env binding // in one call, used for most config options. // // If env is provided, it will override the name of the environment variable used for this // config key BindEnvAndSetDefault(key string, val interface{}, env ...string) }
Loader is a subset of Config that allows loading the configuration
type NotificationReceiver ¶ added in v0.51.0
type NotificationReceiver func(key string)
NotificationReceiver represents the callback type to receive notifications each time the `Set` method is called. The configuration will call each NotificationReceiver registered through the 'OnUpdate' method, therefore 'NotificationReceiver' should not be blocking.
type Proxy ¶
type Proxy struct { HTTP string `mapstructure:"http"` HTTPS string `mapstructure:"https"` NoProxy []string `mapstructure:"no_proxy"` }
Proxy represents the configuration for proxies in the agent
type Reader ¶
type Reader interface { Get(key string) interface{} GetString(key string) string GetBool(key string) bool GetInt(key string) int GetInt32(key string) int32 GetInt64(key string) int64 GetFloat64(key string) float64 GetTime(key string) time.Time GetDuration(key string) time.Duration GetStringSlice(key string) []string GetFloat64SliceE(key string) ([]float64, error) GetStringMap(key string) map[string]interface{} GetStringMapString(key string) map[string]string GetStringMapStringSlice(key string) map[string][]string GetSizeInBytes(key string) uint GetProxies() *Proxy GetSource(key string) Source GetAllSources(key string) []ValueWithSource ConfigFileUsed() string AllSettings() map[string]interface{} AllSettingsWithoutDefault() map[string]interface{} AllSourceSettingsWithoutDefault(source Source) map[string]interface{} AllKeys() []string IsSet(key string) bool IsSetForSource(key string, source Source) bool // UnmarshalKey Unmarshal a configuration key into a struct UnmarshalKey(key string, rawVal interface{}, opts ...viper.DecoderConfigOption) error // IsKnown returns whether this key is known IsKnown(key string) bool // GetKnownKeys returns all the keys that meet at least one of these criteria: // 1) have a default, 2) have an environment variable binded, 3) are an alias or 4) have been SetKnown() GetKnownKeys() map[string]interface{} // GetEnvVars returns a list of the env vars that the config supports. // These have had the EnvPrefix applied, as well as the EnvKeyReplacer. GetEnvVars() []string // IsSectionSet checks if a given section is set by checking if any of // its subkeys is set. IsSectionSet(section string) bool // Warnings returns pointer to a list of warnings (completes config.Component interface) Warnings() *Warnings // Object returns Reader to config (completes config.Component interface) Object() Reader // OnUpdate adds a callback to the list receivers to be called each time a value is change in the configuration // by a call to the 'Set' method. The configuration will sequentially call each receiver. OnUpdate(callback NotificationReceiver) }
Reader is a subset of Config that only allows reading of configuration
type ReaderWriter ¶
ReaderWriter is a subset of Config that allows reading and writing the configuration
type Source ¶
type Source string
Source stores what edits a setting as a string
type ValueWithSource ¶ added in v0.51.0
type ValueWithSource struct { Source Source Value interface{} }
ValueWithSource is a tuple for a source and a value, not necessarily the applied value in the main config