conf

package module
v0.0.0-...-23465b2 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2023 License: Apache-2.0 Imports: 12 Imported by: 1

Documentation

Overview

Package config implements a component to handle agent configuration. This component temporarily wraps pkg/config.

This component initializes pkg/config based on the bundle params, and will return the same results as that package. This is to support migration to a component architecture. When no code still uses pkg/config, that package will be removed.

The mock component does nothing at startup, beginning with an empty config. It also overwrites the pkg/config.Datadog for the duration of the test.

Index

Constants

View Source
const (
	// DefaultSite is the default site the Agent sends data to.
	DefaultSite = "datadoghq.com"

	// DefaultBatchWait is the default HTTP batch wait in second for logs
	DefaultBatchWait = 5

	// DefaultBatchMaxConcurrentSend is the default HTTP batch max concurrent send for logs
	DefaultBatchMaxConcurrentSend = 0

	// DefaultBatchMaxSize is the default HTTP batch max size (maximum number of events in a single batch) for logs
	DefaultBatchMaxSize = 1000

	// DefaultInputChanSize is the default input chan size for events
	DefaultInputChanSize = 100

	// DefaultBatchMaxContentSize is the default HTTP batch max content size (before compression) for logs
	// It is also the maximum possible size of a single event. Events exceeding this limit are dropped.
	DefaultBatchMaxContentSize = 5000000

	// DefaultLogsSenderBackoffFactor is the default logs sender backoff randomness factor
	DefaultLogsSenderBackoffFactor = 2.0

	// DefaultLogsSenderBackoffBase is the default logs sender base backoff time, seconds
	DefaultLogsSenderBackoffBase = 1.0

	// DefaultLogsSenderBackoffMax is the default logs sender maximum backoff time, seconds
	DefaultLogsSenderBackoffMax = 120.0

	// DefaultLogsSenderBackoffRecoveryInterval is the default logs sender backoff recovery interval
	DefaultLogsSenderBackoffRecoveryInterval = 2
)

Variables

View Source
var (
	// StartTime is the agent startup time
	StartTime = time.Now()
)

Variables to initialize at start time

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

func GetIPCAddress

func GetIPCAddress(cfg ConfigReader) (string, error)

GetIPCAddress returns the IPC address or an error if the address is not local

func IsLocalAddress

func IsLocalAddress(address string) (string, error)

IsLocalAddress determines whether it is local address

func Merge

func Merge(configPaths []string, cfg Config) error

Merge will merge additional configuration into an existing configuration

func SanitizeAPIKeyConfig

func SanitizeAPIKeyConfig(cfg Config, key string)

SanitizeAPIKeyConfig strips newlines and other control characters from a given key.

Types

type Component

type Component interface {
	ConfigReader

	// Warnings returns config warnings collected during setup.
	Warnings() *Warnings

	// Object returns wrapped config
	Object() ConfigReader
}

Component is the component type.

type Config

type Config interface {
	ConfigReaderWriter
	ConfigLoader
}

Config represents an object that can load and store configuration parameters coming from different kind of sources: - defaults - files - environment variables - flags

func NewConfig

func NewConfig(name string, envPrefix string, envKeyReplacer *strings.Replacer) Config

NewConfig returns a new Config object.

type ConfigLoader

type ConfigLoader 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
	MergeConfigOverride(in io.Reader) 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)
}

type ConfigReader

type ConfigReader 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

	ConfigFileUsed() string

	AllSettings() map[string]interface{}
	AllSettingsWithoutDefault() map[string]interface{}
	AllKeys() []string

	IsSet(key string) 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 ConfigReader to config (completes config.Component interface)
	Object() ConfigReader
}

ConfigReader is a subset of Config that only allows reading of configuration

type ConfigReaderWriter

type ConfigReaderWriter interface {
	ConfigReader
	ConfigWriter
}

type ConfigWriter

type ConfigWriter interface {
	Set(key string, value interface{})
	CopyConfig(cfg Config)
}

type LogConfig

type LogConfig ConfigReader

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 Warnings

type Warnings struct {
	TraceMallocEnabledWithPy2 bool
	Err                       error
}

Warnings represent the warnings in the config

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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