config

package
v0.29.5 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2022 License: MPL-2.0 Imports: 22 Imported by: 116

Documentation

Index

Constants

View Source
const (
	// DefaultLogLevel is the default logging level.
	DefaultLogLevel = "WARN"

	// DefaultMaxStale is the default staleness permitted. This enables stale
	// queries by default for performance reasons.
	DefaultMaxStale = 2 * time.Second

	// DefaultReloadSignal is the default signal for reload.
	DefaultReloadSignal = syscall.SIGHUP

	// DefaultKillSignal is the default signal for termination.
	DefaultKillSignal = syscall.SIGINT

	// DefaultBlockQueryWaitTime is amount of time in seconds to do a blocking query for
	DefaultBlockQueryWaitTime = 60 * time.Second
)
View Source
const (
	// DefaultDedupPrefix is the default prefix used for deduplication mode.
	DefaultDedupPrefix = "consul-template/dedup/"

	// DefaultDedupTTL is the default TTL for deduplicate mode.
	DefaultDedupTTL = 15 * time.Second

	// DefaultDedupMaxStale is the default max staleness for the deduplication
	// manager.
	DefaultDedupMaxStale = DefaultMaxStale

	// DefaultDedupBlockQueryWaitTime is the default amount of time to do a blocking query for the deduplication
	DefaultDedupBlockQueryWaitTime = 60 * time.Second
)
View Source
const (
	// DefaultExecKillSignal is the default signal to send to the process to
	// tell it to gracefully terminate.
	DefaultExecKillSignal = syscall.SIGINT

	// DefaultExecKillTimeout is the maximum amount of time to wait for the
	// process to gracefully terminate before force-killing it.
	DefaultExecKillTimeout = 30 * time.Second

	// DefaultExecTimeout is the default amount of time to wait for a
	// command to exit. By default, this is disabled, which means the command
	// is allowed to run for an infinite amount of time.
	DefaultExecTimeout = 0 * time.Second
)
View Source
const (
	// DefaultRetryAttempts is the default number of maximum retry attempts.
	DefaultRetryAttempts = 12

	// DefaultRetryBackoff is the default base for the exponential backoff
	// algorithm.
	DefaultRetryBackoff = 250 * time.Millisecond

	// DefaultRetryMaxBackoff is the default maximum of backoff time
	DefaultRetryMaxBackoff = 1 * time.Minute
)
View Source
const (
	// DefaultDialKeepAlive is the default amount of time to keep alive
	// connections.
	DefaultDialKeepAlive = 30 * time.Second

	// DefaultDialTimeout is the amount of time to attempt to dial before timing
	// out.
	DefaultDialTimeout = 30 * time.Second

	// DefaultIdleConnTimeout is the default connection timeout for idle
	// connections.
	DefaultIdleConnTimeout = 90 * time.Second

	// DefaultMaxIdleConns is the default number of maximum idle connections.
	DefaultMaxIdleConns = 100

	// DefaultTLSHandshakeTimeout is the amount of time to negotiate the TLS
	// handshake.
	DefaultTLSHandshakeTimeout = 10 * time.Second
)
View Source
const (
	// XXX Change use to api.EnvVaultSkipVerify once we've updated vendored
	// vault to version 1.1.0 or newer.
	EnvVaultSkipVerify = "VAULT_SKIP_VERIFY"

	// DefaultVaultRenewToken is the default value for if the Vault token should
	// be renewed.
	DefaultVaultRenewToken = true

	// DefaultVaultUnwrapToken is the default value for if the Vault token should
	// be unwrapped.
	DefaultVaultUnwrapToken = false

	// DefaultVaultRetryBase is the default value for the base time to use for
	// exponential backoff.
	DefaultVaultRetryBase = 250 * time.Millisecond

	// DefaultVaultRetryMaxAttempts is the default maximum number of attempts to
	// retry before quitting.
	DefaultVaultRetryMaxAttempts = 5

	// DefaultVaultLeaseDuration is the default lease duration in seconds.
	DefaultVaultLeaseDuration = 5 * time.Minute

	// DefaultLeaseRenewalThreshold is the default fraction of a non-renewable
	// lease to wait for before refreshing
	DefaultLeaseRenewalThreshold = .90

	// DefaultK8SServiceAccountTokenPath is a default path to a file
	// with service token for the k8s auth method.
	DefaultK8SServiceAccountTokenPath = "/run/secrets/kubernetes.io/serviceaccount/token"

	// DefaultK8SServiceMountPath is a default value of the k8s auth method
	// login path.
	DefaultK8SServiceMountPath = "kubernetes"
)
View Source
const (
	// DefaultSSLVerify is the default value for SSL verification.
	DefaultSSLVerify = true
)
View Source
const (
	// DefaultSyslogFacility is the default facility to log to.
	DefaultSyslogFacility = "LOCAL0"
)
View Source
const (
	// DefaultTemplateCommandTimeout is the amount of time to wait for a command
	// to return.
	DefaultTemplateCommandTimeout = 30 * time.Second
)

Variables

View Source
var (
	// DefaultLogFileName is the default filename if the user didn't specify one
	// which means that the user specified a directory to log to
	DefaultLogFileName = fmt.Sprintf("%s.log", version.Name)

	// DefaultLogRotateDuration is the default time taken by the agent to rotate logs
	DefaultLogRotateDuration = 24 * time.Hour
)
View Source
var (
	// ErrWaitStringEmpty is the error returned when wait is specified as an empty
	// string.
	ErrWaitStringEmpty = errors.New("wait: cannot be empty")

	// ErrWaitInvalidFormat is the error returned when the wait is specified
	// incorrectly.
	ErrWaitInvalidFormat = errors.New("wait: invalid format")

	// ErrWaitNegative is the error returned with the wait is negative.
	ErrWaitNegative = errors.New("wait: cannot be negative")

	// ErrWaitMinLTMax is the error returned with the minimum wait time is not
	// less than the maximum wait time.
	ErrWaitMinLTMax = errors.New("wait: min must be less than max")
)
View Source
var DefaultExecReloadSignal = (os.Signal)(nil)

DefaultExecReloadSignal is the default signal to send to the process to tell it to reload its configuration.

View Source
var DefaultMaxIdleConnsPerHost = runtime.GOMAXPROCS(0) + 1

DefaultMaxIdleConnsPerHost is the default number of idle connections to use per host.

View Source
var DefaultSyslogName = version.Name

DefaultSyslogName is the default app name in syslog.

View Source
var ErrAuthStringEmpty = errors.New("auth: cannot be empty")

ErrAuthStringEmpty is the error returned with authentication is provided, but empty.

View Source
var (
	// ErrTemplateStringEmpty is the error returned with the template contents
	// are empty.
	ErrTemplateStringEmpty = errors.New("template: cannot be empty")
)

Functions

func Bool

func Bool(b bool) *bool

Bool returns a pointer to the given bool.

func BoolGoString

func BoolGoString(b *bool) string

BoolGoString returns the value of the boolean for printing in a string.

func BoolPresent

func BoolPresent(b *bool) bool

BoolPresent returns a boolean indicating if the pointer is nil, or if the pointer is pointing to the zero value..

func BoolVal

func BoolVal(b *bool) bool

BoolVal returns the value of the boolean at the pointer, or false if the pointer is nil.

func ConsulStringToStructFunc

func ConsulStringToStructFunc() mapstructure.DecodeHookFunc

ConsulStringToStructFunc checks if the value set for the key should actually be a struct and sets the appropriate value in the struct. This is for backwards-compatability with older versions of Consul Template.

func FileMode

func FileMode(o os.FileMode) *os.FileMode

FileMode returns a pointer to the given os.FileMode.

func FileModeGoString

func FileModeGoString(o *os.FileMode) string

FileModeGoString returns the value of the os.FileMode for printing in a string.

func FileModePresent

func FileModePresent(o *os.FileMode) bool

FileModePresent returns a boolean indicating if the pointer is nil, or if the pointer is pointing to the zero value.

func FileModeVal

func FileModeVal(o *os.FileMode) os.FileMode

FileModeVal returns the value of the os.FileMode at the pointer, or 0 if the pointer is nil.

func Float64 added in v0.28.1

func Float64(f float64) *float64

Float64 returns a pointer to the given float64

func FloatGoString added in v0.29.1

func FloatGoString(f *float64) string

FloatGoString returns the value of the float for printing in a string.

func Int

func Int(i int) *int

Int returns a pointer to the given int.

func IntGoString

func IntGoString(i *int) string

IntGoString returns the value of the int for printing in a string.

func IntPresent

func IntPresent(i *int) bool

IntPresent returns a boolean indicating if the pointer is nil, or if the pointer is pointing to the zero value.

func IntVal

func IntVal(i *int) int

IntVal returns the value of the int at the pointer, or 0 if the pointer is nil.

func Signal

func Signal(s os.Signal) *os.Signal

Signal returns a pointer to the given os.Signal.

func SignalGoString

func SignalGoString(s *os.Signal) string

SignalGoString returns the value of the os.Signal for printing in a string.

func SignalPresent

func SignalPresent(s *os.Signal) bool

SignalPresent returns a boolean indicating if the pointer is nil, or if the pointer is pointing to the zero value..

func SignalVal

func SignalVal(s *os.Signal) os.Signal

SignalVal returns the value of the os.Signal at the pointer, or 0 if the pointer is nil.

func String

func String(s string) *string

String returns a pointer to the given string.

func StringGoString

func StringGoString(s *string) string

StringGoString returns the value of the string for printing in a string.

func StringPresent

func StringPresent(s *string) bool

StringPresent returns a boolean indicating if the pointer is nil, or if the pointer is pointing to the zero value..

func StringToFileModeFunc

func StringToFileModeFunc() mapstructure.DecodeHookFunc

StringToFileModeFunc returns a function that converts strings to os.FileMode value. This is designed to be used with mapstructure for parsing out a filemode value.

func StringToWaitDurationHookFunc

func StringToWaitDurationHookFunc() mapstructure.DecodeHookFunc

StringToWaitDurationHookFunc returns a function that converts strings to wait value. This is designed to be used with mapstructure for parsing out a wait value.

func StringVal

func StringVal(s *string) string

StringVal returns the value of the string at the pointer, or "" if the pointer is nil.

func TimeDuration

func TimeDuration(t time.Duration) *time.Duration

TimeDuration returns a pointer to the given time.Duration.

func TimeDurationGoString

func TimeDurationGoString(t *time.Duration) string

TimeDurationGoString returns the value of the time.Duration for printing in a string.

func TimeDurationPresent

func TimeDurationPresent(t *time.Duration) bool

TimeDurationPresent returns a boolean indicating if the pointer is nil, or if the pointer is pointing to the zero value..

func TimeDurationVal

func TimeDurationVal(t *time.Duration) time.Duration

TimeDurationVal returns the value of the string at the pointer, or 0 if the pointer is nil.

Types

type AuthConfig

type AuthConfig struct {
	Enabled  *bool   `mapstructure:"enabled"`
	Username *string `mapstructure:"username"`
	Password *string `mapstructure:"password" json:"-"`
}

AuthConfig is the HTTP basic authentication data. Skip passwords in json output that is used for logging.

func DefaultAuthConfig

func DefaultAuthConfig() *AuthConfig

DefaultAuthConfig is the default configuration.

func ParseAuthConfig

func ParseAuthConfig(s string) (*AuthConfig, error)

ParseAuthConfig parses the auth into username:password.

func (*AuthConfig) Copy

func (c *AuthConfig) Copy() *AuthConfig

Copy returns a deep copy of this configuration.

func (*AuthConfig) Finalize

func (c *AuthConfig) Finalize()

Finalize ensures there no nil pointers.

func (*AuthConfig) GoString

func (c *AuthConfig) GoString() string

GoString defines the printable version of this struct.

func (*AuthConfig) Merge

func (c *AuthConfig) Merge(o *AuthConfig) *AuthConfig

Merge combines all values in this configuration with the values in the other configuration, with values in the other configuration taking precedence. Maps and slices are merged, most other values are overwritten. Complex structs define their own merge functionality.

func (*AuthConfig) String

func (c *AuthConfig) String() string

String is the string representation of this authentication. If authentication is not enabled, this returns the empty string. The username and password will be separated by a colon.

type Config

type Config struct {
	// Consul is the configuration for connecting to a Consul cluster.
	Consul *ConsulConfig `mapstructure:"consul"`

	// Dedup is used to configure the dedup settings
	Dedup *DedupConfig `mapstructure:"deduplicate"`

	// DefaultDelims is used to configure the default delimiters for templates
	DefaultDelims *DefaultDelims `mapstructure:"default_delimiters"`

	// Exec is the configuration for exec/supervise mode.
	Exec *ExecConfig `mapstructure:"exec"`

	// KillSignal is the signal to listen for a graceful terminate event.
	KillSignal *os.Signal `mapstructure:"kill_signal"`

	// LogLevel is the level with which to log for this config.
	LogLevel *string `mapstructure:"log_level"`

	// FileLog is the configuration for file logging.
	FileLog *LogFileConfig `mapstructure:"log_file"`

	// MaxStale is the maximum amount of time for staleness from Consul as given
	// by LastContact. If supplied, Consul Template will query all servers instead
	// of just the leader.
	MaxStale *time.Duration `mapstructure:"max_stale"`

	// PidFile is the path on disk where a PID file should be written containing
	// this processes PID.
	PidFile *string `mapstructure:"pid_file"`

	// ReloadSignal is the signal to listen for a reload event.
	ReloadSignal *os.Signal `mapstructure:"reload_signal"`

	// Syslog is the configuration for syslog.
	Syslog *SyslogConfig `mapstructure:"syslog"`

	// Templates is the list of templates.
	Templates *TemplateConfigs `mapstructure:"template"`

	// TemplateErrFatal determines whether template errors should cause the
	// process to exit, or just log and continue.
	TemplateErrFatal *bool `mapstructure:"template_error_fatal"`

	// Vault is the configuration for connecting to a vault server.
	Vault *VaultConfig `mapstructure:"vault"`

	// Nomad is the configuration for connecting to a Nomad agent.
	Nomad *NomadConfig `mapstructure:"nomad"`

	// Wait is the quiescence timers.
	Wait *WaitConfig `mapstructure:"wait"`

	// Additional command line options
	// Run once, executing each template exactly once, and exit
	Once bool

	// ParseOnly prevents any rendering and only loads the templates for
	// checking well formedness.
	ParseOnly bool

	// BlockQueryWaitTime is amount of time in seconds to do a blocking query for
	BlockQueryWaitTime *time.Duration `mapstructure:"block_query_wait"`
}

Config is used to configure Consul Template

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns the default configuration struct. Certain environment variables may be set which control the values for the default configuration.

func FromFile

func FromFile(path string) (*Config, error)

FromFile reads the configuration file at the given path and returns a new Config struct with the data populated.

func FromPath

func FromPath(path string) (*Config, error)

FromPath iterates and merges all configuration files in a given directory, returning the resulting config.

func Must

func Must(s string) *Config

Must returns a config object that must compile. If there are any errors, this function will panic. This is most useful in testing or constants.

func Parse

func Parse(s string) (*Config, error)

Parse parses the given string contents as a config

func TestConfig

func TestConfig(c *Config) *Config

TestConfig returns a default, finalized config, with the provided configuration taking precedence.

func (*Config) Copy

func (c *Config) Copy() *Config

Copy returns a deep copy of the current configuration. This is useful because the nested data structures may be shared.

func (*Config) Diff added in v0.20.1

func (expected *Config) Diff(actual *Config) string

Show diff between 2 Configs, useful in tests

func (*Config) Finalize

func (c *Config) Finalize()

Finalize ensures all configuration options have the default values, so it is safe to dereference the pointers later down the line. It also intelligently tries to activate stanzas that should be "enabled" because data was given, but the user did not explicitly add "Enabled: true" to the configuration.

func (*Config) GoString

func (c *Config) GoString() string

GoString defines the printable version of this struct.

func (*Config) Merge

func (c *Config) Merge(o *Config) *Config

Merge merges the values in config into this config object. Values in the config object overwrite the values in c.

type ConsulConfig

type ConsulConfig struct {
	// Address is the address of the Consul server. It may be an IP or FQDN.
	Address *string

	// Namespace is the Consul namespace to use for reading/writing. This can
	// also be set via the CONSUL_NAMESPACE environment variable.
	Namespace *string `mapstructure:"namespace"`

	// Auth is the HTTP basic authentication for communicating with Consul.
	Auth *AuthConfig `mapstructure:"auth"`

	// Retry is the configuration for specifying how to behave on failure.
	Retry *RetryConfig `mapstructure:"retry"`

	// SSL indicates we should use a secure connection while talking to
	// Consul. This requires Consul to be configured to serve HTTPS.
	SSL *SSLConfig `mapstructure:"ssl"`

	// Token is the token to communicate with Consul securely.
	Token *string

	// TokenFile is the path to a token to communicate with Consul securely.
	TokenFile *string `mapstructure:"token_file"`

	// Transport configures the low-level network connection details.
	Transport *TransportConfig `mapstructure:"transport"`
}

ConsulConfig contains the configurations options for connecting to a Consul cluster.

func DefaultConsulConfig

func DefaultConsulConfig() *ConsulConfig

DefaultConsulConfig returns a configuration that is populated with the default values.

func (*ConsulConfig) Copy

func (c *ConsulConfig) Copy() *ConsulConfig

Copy returns a deep copy of this configuration.

func (*ConsulConfig) Finalize

func (c *ConsulConfig) Finalize()

Finalize ensures there no nil pointers.

func (*ConsulConfig) GoString

func (c *ConsulConfig) GoString() string

GoString defines the printable version of this struct.

func (*ConsulConfig) Merge

func (c *ConsulConfig) Merge(o *ConsulConfig) *ConsulConfig

Merge combines all values in this configuration with the values in the other configuration, with values in the other configuration taking precedence. Maps and slices are merged, most other values are overwritten. Complex structs define their own merge functionality.

type DedupConfig

type DedupConfig struct {
	// Controls if deduplication mode is enabled
	Enabled *bool `mapstructure:"enabled"`

	// MaxStale is the maximum amount of time to allow for stale queries.
	MaxStale *time.Duration `mapstructure:"max_stale"`

	// Controls the KV prefix used. Defaults to defaultDedupPrefix
	Prefix *string `mapstructure:"prefix"`

	// TTL is the Session TTL used for lock acquisition, defaults to 15 seconds.
	TTL *time.Duration `mapstructure:"ttl"`

	// BlockQueryWaitTime is amount of time to do a blocking query for, defaults to 60 seconds.
	BlockQueryWaitTime *time.Duration `mapstructure:"block_query_wait"`
}

DedupConfig is used to enable the de-duplication mode, which depends on electing a leader per-template and watching of a key. This is used to reduce the cost of many instances of CT running the same template.

func DefaultDedupConfig

func DefaultDedupConfig() *DedupConfig

DefaultDedupConfig returns a configuration that is populated with the default values.

func (*DedupConfig) Copy

func (c *DedupConfig) Copy() *DedupConfig

Copy returns a deep copy of this configuration.

func (*DedupConfig) Finalize

func (c *DedupConfig) Finalize()

Finalize ensures there no nil pointers.

func (*DedupConfig) GoString

func (c *DedupConfig) GoString() string

GoString defines the printable version of this struct.

func (*DedupConfig) Merge

func (c *DedupConfig) Merge(o *DedupConfig) *DedupConfig

Merge combines all values in this configuration with the values in the other configuration, with values in the other configuration taking precedence. Maps and slices are merged, most other values are overwritten. Complex structs define their own merge functionality.

type DefaultDelims added in v0.25.0

type DefaultDelims struct {
	// Left is the left delimiter for templating
	Left *string `mapstructure:"left"`

	// Right is the right delimiter for templating
	Right *string `mapstructure:"right"`
}

DefaultDelims is used to configure the default delimiters used for all templates

func DefaultDefaultDelims added in v0.25.0

func DefaultDefaultDelims() *DefaultDelims

DefaultDefaultDelims returns the default DefaultDelims

func (*DefaultDelims) Copy added in v0.25.0

func (c *DefaultDelims) Copy() *DefaultDelims

Copy returns a copy of the DefaultDelims

func (*DefaultDelims) Merge added in v0.25.0

Merge merges the DefaultDelims

type EnvConfig

type EnvConfig struct {
	// Denylist specifies a list of environment variables to explicitly
	// exclude from the list of environment variables populated to the child.
	// If both Allowlist and Denylist are provided, Denylist takes
	// precedence over the values in Allowlist.
	Denylist []string `mapstructure:"denylist"`

	// DenylistDeprecated is the backward compatible option for Denylist for
	// configuration supported by v0.25.0 and older. This should not be used
	// directly, use Denylist instead. Values from this are combined to
	// Denylist in Finalize().
	DenylistDeprecated []string `mapstructure:"blacklist" json:"-"`

	// CustomEnv specifies custom environment variables to pass to the child
	// process. These are provided programmatically, override any environment
	// variables of the same name, are ignored from allowlist/denylist, and
	// are still included even if PristineEnv is set to true.
	Custom []string `mapstructure:"custom"`

	// PristineEnv specifies if the child process should inherit the parent's
	// environment.
	Pristine *bool `mapstructure:"pristine"`

	// Allowlist specifies a list of environment variables to exclusively
	// include in the list of environment variables populated to the child.
	Allowlist []string `mapstructure:"allowlist"`

	// AllowlistDeprecated is the backward compatible option for Allowlist for
	// configuration supported by v0.25.0 and older. This should not be used
	// directly, use Allowlist instead. Values from this are combined to
	// Allowlist in Finalize().
	AllowlistDeprecated []string `mapstructure:"whitelist" json:"-"`
}

EnvConfig is an embeddable struct for things that accept environment variable filtering. You should not use this directly and it is only public for mapstructure's decoding.

func DefaultEnvConfig

func DefaultEnvConfig() *EnvConfig

DefaultEnvConfig returns a configuration that is populated with the default values.

func (*EnvConfig) Copy

func (c *EnvConfig) Copy() *EnvConfig

Copy returns a deep copy of this configuration.

func (*EnvConfig) Env

func (c *EnvConfig) Env() []string

Env calculates and returns the finalized environment for this exec configuration. It takes into account pristine, custom environment, allowlist, and denylist values.

func (*EnvConfig) Finalize

func (c *EnvConfig) Finalize()

Finalize ensures there no nil pointers.

func (*EnvConfig) GoString

func (c *EnvConfig) GoString() string

GoString defines the printable version of this struct.

func (*EnvConfig) Merge

func (c *EnvConfig) Merge(o *EnvConfig) *EnvConfig

Merge combines all values in this configuration with the values in the other configuration, with values in the other configuration taking precedence. Maps and slices are merged, most other values are overwritten. Complex structs define their own merge functionality.

type ExecConfig

type ExecConfig struct {
	// Command is the command to execute and watch as a child process.
	Command commandList `mapstructure:"command"`

	// Enabled controls if this exec is enabled.
	Enabled *bool `mapstructure:"enabled"`

	// EnvConfig is the environmental customizations.
	Env *EnvConfig `mapstructure:"env"`

	// KillSignal is the signal to send to the command to kill it gracefully.
	KillSignal *os.Signal `mapstructure:"kill_signal"`

	// KillTimeout is the amount of time to give the process to cleanup before
	// hard-killing it.
	KillTimeout *time.Duration `mapstructure:"kill_timeout"`

	// ReloadSignal is the signal to send to the child process when a template
	// changes. This tells the child process that templates have
	ReloadSignal *os.Signal `mapstructure:"reload_signal"`

	// Splay is the maximum amount of random time to wait to signal or kill the
	// process. By default this is disabled, but it can be set to low values to
	// reduce the "thundering herd" problem where all tasks are restarted at once.
	Splay *time.Duration `mapstructure:"splay"`

	// Timeout is the maximum amount of time to wait for a command to complete.
	// By default, this is 0, which means "wait forever".
	Timeout *time.Duration `mapstructure:"timeout"`
}

ExecConfig is used to configure the application when it runs in exec/supervise mode.

func DefaultExecConfig

func DefaultExecConfig() *ExecConfig

DefaultExecConfig returns a configuration that is populated with the default values.

func (*ExecConfig) Copy

func (c *ExecConfig) Copy() *ExecConfig

Copy returns a deep copy of this configuration.

func (*ExecConfig) Finalize

func (c *ExecConfig) Finalize()

Finalize ensures there no nil pointers.

func (*ExecConfig) GoString

func (c *ExecConfig) GoString() string

GoString defines the printable version of this struct.

func (*ExecConfig) Merge

func (c *ExecConfig) Merge(o *ExecConfig) *ExecConfig

Merge combines all values in this configuration with the values in the other configuration, with values in the other configuration taking precedence. Maps and slices are merged, most other values are overwritten. Complex structs define their own merge functionality.

type LogFileConfig added in v0.28.0

type LogFileConfig struct {
	// LogFilePath is the path to the file the logs get written to
	LogFilePath *string `mapstructure:"path"`

	// LogRotateBytes is the maximum number of bytes that should be written to a log
	// file
	LogRotateBytes *int `mapstructure:"log_rotate_bytes"`

	// LogRotateDuration is the time after which log rotation needs to be performed
	LogRotateDuration *time.Duration `mapstructure:"log_rotate_duration"`

	// LogRotateMaxFiles is the maximum number of log file archives to keep
	LogRotateMaxFiles *int `mapstructure:"log_rotate_max_files"`
}

func DefaultLogFileConfig added in v0.28.0

func DefaultLogFileConfig() *LogFileConfig

DefaultLogFileConfig returns a configuration that is populated with the default values.

func (*LogFileConfig) Copy added in v0.28.0

func (c *LogFileConfig) Copy() *LogFileConfig

Copy returns a deep copy of this configuration.

func (*LogFileConfig) Finalize added in v0.28.0

func (c *LogFileConfig) Finalize()

Finalize ensures there no nil pointers.

func (*LogFileConfig) GoString added in v0.28.0

func (c *LogFileConfig) GoString() string

GoString defines the printable version of this struct.

func (*LogFileConfig) Merge added in v0.28.0

Merge combines all values in this configuration with the values in the other configuration, with values in the other configuration taking precedence. Maps and slices are merged, most other values are overwritten. Complex structs define their own merge functionality.

type NomadConfig added in v0.29.0

type NomadConfig struct {
	// Address is the URI to the Nomad agent.
	Address *string `mapstructure:"address"`

	// Enabled controls whether the Nomad integration is active.
	Enabled *bool `mapstructure:"enabled"`

	// Namespace is the Nomad namespace to use. This can also be set via
	// the NOMAD_NAMESPACE environment variable.
	Namespace *string `mapstructure:"namespace"`

	// SSL indicates we should use a secure connection while talking
	// to Nomad.
	SSL *SSLConfig `mapstructure:"ssl"`

	// Token is the Nomad ACL token to use with API requests. This can also
	// be set via the NOMAD_TOKEN environment variable.
	Token *string `mapstructure:"token" json:"-"`

	// AuthUsername and AuthPassword are the HTTP Basic Auth username and
	// password to use when authenticating with the Nomad API.
	AuthUsername *string `mapstructure:"auth_username"`
	AuthPassword *string `mapstructure:"auth_password"`

	// Transport configures the low-level network connection details.
	Transport *TransportConfig `mapstructure:"transport"`

	// Retry is the configuration for specifying how to behave on failure.
	Retry *RetryConfig `mapstructure:"retry"`
}

NomadConfig is the configuration for connecting to a Nomad agent.

func DefaultNomadConfig added in v0.29.0

func DefaultNomadConfig() *NomadConfig

func (*NomadConfig) Copy added in v0.29.0

func (n *NomadConfig) Copy() *NomadConfig

Copy returns a deep copy of this configuration.

func (*NomadConfig) Finalize added in v0.29.0

func (n *NomadConfig) Finalize()

Finalize ensures there no nil pointers.

func (*NomadConfig) GoString added in v0.29.0

func (n *NomadConfig) GoString() string

func (*NomadConfig) Merge added in v0.29.0

func (n *NomadConfig) Merge(o *NomadConfig) *NomadConfig

Merge combines all values in this configuration with the values in the other configuration, with values in the other configuration taking precedence. Maps and slices are merged, most other values are overwritten. Complex structs define their own merge functionality.

type RetryConfig

type RetryConfig struct {
	// Attempts is the total number of maximum attempts to retry before letting
	// the error fall through.
	// 0 means unlimited.
	Attempts *int

	// Backoff is the base of the exponentialbackoff. This number will be
	// multiplied by the next power of 2 on each iteration.
	Backoff *time.Duration

	// MaxBackoff is an upper limit to the sleep time between retries
	// A MaxBackoff of zero means there is no limit to the exponential growth of the backoff.
	MaxBackoff *time.Duration `mapstructure:"max_backoff"`

	// Enabled signals if this retry is enabled.
	Enabled *bool
}

RetryConfig is a shared configuration for upstreams that support retires on failure.

func DefaultRetryConfig

func DefaultRetryConfig() *RetryConfig

DefaultRetryConfig returns a configuration that is populated with the default values.

func (*RetryConfig) Copy

func (c *RetryConfig) Copy() *RetryConfig

Copy returns a deep copy of this configuration.

func (*RetryConfig) Finalize

func (c *RetryConfig) Finalize()

Finalize ensures there no nil pointers.

func (*RetryConfig) GoString

func (c *RetryConfig) GoString() string

GoString defines the printable version of this struct.

func (*RetryConfig) Merge

func (c *RetryConfig) Merge(o *RetryConfig) *RetryConfig

Merge combines all values in this configuration with the values in the other configuration, with values in the other configuration taking precedence. Maps and slices are merged, most other values are overwritten. Complex structs define their own merge functionality.

func (*RetryConfig) RetryFunc

func (c *RetryConfig) RetryFunc() RetryFunc

RetryFunc returns the retry function associated with this configuration.

type RetryFunc

type RetryFunc func(int) (bool, time.Duration)

RetryFunc is the signature of a function that supports retries.

type SSLConfig

type SSLConfig struct {
	CaCert     *string `mapstructure:"ca_cert"`
	CaPath     *string `mapstructure:"ca_path"`
	Cert       *string `mapstructure:"cert"`
	Enabled    *bool   `mapstructure:"enabled"`
	Key        *string `mapstructure:"key"`
	ServerName *string `mapstructure:"server_name"`
	Verify     *bool   `mapstructure:"verify"`
}

SSLConfig is the configuration for SSL.

func DefaultSSLConfig

func DefaultSSLConfig() *SSLConfig

DefaultSSLConfig returns a configuration that is populated with the default values.

func (*SSLConfig) Copy

func (c *SSLConfig) Copy() *SSLConfig

Copy returns a deep copy of this configuration.

func (*SSLConfig) Finalize

func (c *SSLConfig) Finalize()

Finalize ensures there no nil pointers.

func (*SSLConfig) GoString

func (c *SSLConfig) GoString() string

GoString defines the printable version of this struct.

func (*SSLConfig) Merge

func (c *SSLConfig) Merge(o *SSLConfig) *SSLConfig

Merge combines all values in this configuration with the values in the other configuration, with values in the other configuration taking precedence. Maps and slices are merged, most other values are overwritten. Complex structs define their own merge functionality.

type SyslogConfig

type SyslogConfig struct {
	Enabled  *bool   `mapstructure:"enabled"`
	Facility *string `mapstructure:"facility"`
	Name     *string `mapstructure:"name"`
}

SyslogConfig is the configuration for syslog.

func DefaultSyslogConfig

func DefaultSyslogConfig() *SyslogConfig

DefaultSyslogConfig returns a configuration that is populated with the default values.

func (*SyslogConfig) Copy

func (c *SyslogConfig) Copy() *SyslogConfig

Copy returns a deep copy of this configuration.

func (*SyslogConfig) Finalize

func (c *SyslogConfig) Finalize()

Finalize ensures there no nil pointers.

func (*SyslogConfig) GoString

func (c *SyslogConfig) GoString() string

GoString defines the printable version of this struct.

func (*SyslogConfig) Merge

func (c *SyslogConfig) Merge(o *SyslogConfig) *SyslogConfig

Merge combines all values in this configuration with the values in the other configuration, with values in the other configuration taking precedence. Maps and slices are merged, most other values are overwritten. Complex structs define their own merge functionality.

type TemplateConfig

type TemplateConfig struct {
	// Backup determines if this template should retain a backup. The default
	// value is false.
	Backup *bool `mapstructure:"backup"`

	// Command is the arbitrary command to execute after a template has
	// successfully rendered. This is DEPRECATED. Use Exec instead.
	Command commandList `mapstructure:"command"`

	// CommandTimeout is the amount of time to wait for the command to finish
	// before force-killing it. This is DEPRECATED. Use Exec instead.
	CommandTimeout *time.Duration `mapstructure:"command_timeout"`

	// Contents are the raw template contents to evaluate. Either this or Source
	// must be specified, but not both.
	Contents *string `mapstructure:"contents"`

	// CreateDestDirs tells Consul Template to create the parent directories of
	// the destination path if they do not exist. The default value is true.
	CreateDestDirs *bool `mapstructure:"create_dest_dirs"`

	// Destination is the location on disk where the template should be rendered.
	// This is required unless running in debug/dry mode.
	Destination *string `mapstructure:"destination"`

	// ErrMissingKey is used to control how the template behaves when attempting
	// to index a struct or map key that does not exist.
	ErrMissingKey *bool `mapstructure:"error_on_missing_key"`

	// ErrFatal determines whether template errors should cause the process to
	// exit, or just log and continue.
	ErrFatal *bool `mapstructure:"error_fatal"`

	// Exec is the configuration for the command to run when the template renders
	// successfully.
	Exec *ExecConfig `mapstructure:"exec"`

	// Perms are the file system permissions to use when creating the file on
	// disk. This is useful for when files contain sensitive information, such as
	// secrets from Vault.
	Perms *os.FileMode `mapstructure:"perms"`

	// User is the username or uid that will be set when creating the file on disk.
	// Useful when simply setting Perms is not enough.
	//
	// Platform dependent: this doesn't work on Windows but it fails gracefully
	// with a warning
	User *string `mapstructure:"user"`

	// Uid is equivalent to User when it's a valid int and it's defined for backward compatibility with v0.28.0
	Uid *int `mapstructure:"uid"`

	// Group is the group name or gid that will be set when creating the file on disk.
	// Useful when simply setting Perms is not enough.
	//
	// Platform dependent: this doesn't work on Windows but it fails gracefully
	// with a warning
	Group *string `mapstructure:"group"`

	// Gid is equivalent to Group when it's a valid int and it's defined for backward compatibility with v0.28.0
	Gid *int `mapstructure:"gid"`

	// Source is the path on disk to the template contents to evaluate. Either
	// this or Contents should be specified, but not both.
	Source *string `mapstructure:"source"`

	// Wait configures per-template quiescence timers.
	Wait *WaitConfig `mapstructure:"wait"`

	// LeftDelim and RightDelim are optional configurations to control what
	// delimiter is utilized when parsing the template.
	LeftDelim  *string `mapstructure:"left_delimiter"`
	RightDelim *string `mapstructure:"right_delimiter"`

	// FunctionDenylist is a list of functions that this template is not
	// permitted to run.
	FunctionDenylist []string `mapstructure:"function_denylist"`

	// FunctionDenylistDeprecated is the backward compatible option for
	// FunctionDenylist for configuration supported by v0.25.0 and older. This
	// should not be used directly, use FunctionDenylist instead. Values from
	// this are combined to FunctionDenylist in Finalize().
	FunctionDenylistDeprecated []string `mapstructure:"function_blacklist" json:"-"`

	// SandboxPath adds a prefix to any path provided to the `file` function
	// and causes an error if a relative path tries to traverse outside that
	// prefix.
	SandboxPath *string `mapstructure:"sandbox_path"`
}

TemplateConfig is a representation of a template on disk, as well as the associated commands and reload instructions.

func DefaultTemplateConfig

func DefaultTemplateConfig() *TemplateConfig

DefaultTemplateConfig returns a configuration that is populated with the default values.

func ParseTemplateConfig

func ParseTemplateConfig(s string) (*TemplateConfig, error)

ParseTemplateConfig parses a string in the form source:destination:command into a TemplateConfig.

func (*TemplateConfig) Copy

func (c *TemplateConfig) Copy() *TemplateConfig

Copy returns a deep copy of this configuration.

func (*TemplateConfig) Display

func (c *TemplateConfig) Display() string

Display is the human-friendly form of this configuration. It tries to describe this template in as much detail as possible in a single line, so log consumers can uniquely identify it.

func (*TemplateConfig) Finalize

func (c *TemplateConfig) Finalize()

Finalize ensures the configuration has no nil pointers and sets default values.

func (*TemplateConfig) GoString

func (c *TemplateConfig) GoString() string

GoString defines the printable version of this struct.

func (*TemplateConfig) Merge

Merge combines all values in this configuration with the values in the other configuration, with values in the other configuration taking precedence. Maps and slices are merged, most other values are overwritten. Complex structs define their own merge functionality.

type TemplateConfigs

type TemplateConfigs []*TemplateConfig

TemplateConfigs is a collection of TemplateConfigs

func DefaultTemplateConfigs

func DefaultTemplateConfigs() *TemplateConfigs

DefaultTemplateConfigs returns a configuration that is populated with the default values.

func (*TemplateConfigs) Copy

func (c *TemplateConfigs) Copy() *TemplateConfigs

Copy returns a deep copy of this configuration.

func (*TemplateConfigs) Finalize

func (c *TemplateConfigs) Finalize()

Finalize ensures the configuration has no nil pointers and sets default values.

func (*TemplateConfigs) GoString

func (c *TemplateConfigs) GoString() string

GoString defines the printable version of this struct.

func (*TemplateConfigs) Merge

Merge combines all values in this configuration with the values in the other configuration, with values in the other configuration taking precedence. Maps and slices are merged, most other values are overwritten. Complex structs define their own merge functionality.

type TransportConfig added in v0.18.1

type TransportConfig struct {
	// CustomDialer overrides the default net.Dial with a custom dialer. This is
	// useful for instance with Vault Agent Templating to direct Consul Template
	// requests through an internal cache.
	CustomDialer dependency.TransportDialer `mapstructure:"-"`

	// DialKeepAlive is the amount of time for keep-alives.
	DialKeepAlive *time.Duration `mapstructure:"dial_keep_alive"`

	// DialTimeout is the amount of time to wait to establish a connection.
	DialTimeout *time.Duration `mapstructure:"dial_timeout"`

	// DisableKeepAlives determines if keep-alives should be used. Disabling this
	// significantly decreases performance.
	DisableKeepAlives *bool `mapstructure:"disable_keep_alives"`

	// IdleConnTimeout is the timeout for idle connections.
	IdleConnTimeout *time.Duration `mapstructure:"idle_conn_timeout"`

	// MaxIdleConns is the maximum number of total idle connections.
	MaxIdleConns *int `mapstructure:"max_idle_conns"`

	// MaxIdleConnsPerHost is the maximum number of idle connections per remote
	// host.
	MaxIdleConnsPerHost *int `mapstructure:"max_idle_conns_per_host"`

	// TLSHandshakeTimeout is the amount of time to wait to complete the TLS
	// handshake.
	TLSHandshakeTimeout *time.Duration `mapstructure:"tls_handshake_timeout"`
}

TransportConfig is the configuration to tune low-level APIs for the interactions on the wire.

func DefaultTransportConfig added in v0.18.1

func DefaultTransportConfig() *TransportConfig

DefaultTransportConfig returns a configuration that is populated with the default values.

func (*TransportConfig) Copy added in v0.18.1

func (c *TransportConfig) Copy() *TransportConfig

Copy returns a deep copy of this configuration.

func (*TransportConfig) Finalize added in v0.18.1

func (c *TransportConfig) Finalize()

Finalize ensures there no nil pointers.

func (*TransportConfig) GoString added in v0.18.1

func (c *TransportConfig) GoString() string

GoString defines the printable version of this struct.

func (*TransportConfig) Merge added in v0.18.1

Merge combines all values in this configuration with the values in the other configuration, with values in the other configuration taking precedence. Maps and slices are merged, most other values are overwritten. Complex structs define their own merge functionality.

type VaultConfig

type VaultConfig struct {
	// Address is the URI to the Vault server.
	Address *string `mapstructure:"address"`

	// Enabled controls whether the Vault integration is active.
	Enabled *bool `mapstructure:"enabled"`

	// Namespace is the Vault namespace to use for reading/writing secrets. This can
	// also be set via the VAULT_NAMESPACE environment variable.
	Namespace *string `mapstructure:"namespace"`

	// RenewToken renews the Vault token.
	RenewToken *bool `mapstructure:"renew_token"`

	// Retry is the configuration for specifying how to behave on failure.
	Retry *RetryConfig `mapstructure:"retry"`

	// SSL indicates we should use a secure connection while talking to Vault.
	SSL *SSLConfig `mapstructure:"ssl"`

	// Token is the Vault token to communicate with for requests. It may be
	// a wrapped token or a real token. This can also be set via the VAULT_TOKEN
	// environment variable, or via the VaultAgentTokenFile.
	Token *string `mapstructure:"token" json:"-"`

	// VaultAgentTokenFile is the path of file that contains a Vault Agent token.
	// If vault_agent_token_file is specified:
	//   - Consul Template will not try to renew the Vault token.
	//   - Consul Template will periodically stat the file and update the token if it has
	// changed.
	VaultAgentTokenFile *string `mapstructure:"vault_agent_token_file" json:"-"`

	// Transport configures the low-level network connection details.
	Transport *TransportConfig `mapstructure:"transport"`

	// UnwrapToken unwraps the provided Vault token as a wrapped token.
	UnwrapToken *bool `mapstructure:"unwrap_token"`

	// DefaultLeaseDuration configures the default lease duration when not explicitly
	// set by vault
	DefaultLeaseDuration *time.Duration `mapstructure:"default_lease_duration"`

	// LeaseRenewalThreshold configues how long Consul Template should wait for to
	// refresh dynamic, non-renewable leases, measured as a fraction of the lease
	// duration.
	LeaseRenewalThreshold *float64 `mapstructure:"lease_renewal_threshold"`

	// If Token is empty and K8SAuthRoleName is set, it means to use
	// k8s vault auth method.
	//
	// The kubernetes auth method can be used to authenticate with Vault
	// using a Kubernetes Service Account Token. This method of
	// authentication makes it easy to introduce a Vault token into
	// a Kubernetes Pod.
	//
	// This can also be set via the VAULT_K8S_AUTH_ROLE_NAME.
	K8SAuthRoleName *string `mapstructure:"k8s_auth_role_name"`
	// K8SServiceAccountTokenPath is the path of file that contains
	// a K8SServiceAccountToken. It will be ignored if K8SServiceAccountToken
	// is set.
	//
	// Default value is "/run/secrets/kubernetes.io/serviceaccount/token".
	//
	// This can also be set via the VAULT_K8S_SERVICE_ACCOUNT_TOKEN_PATH.
	K8SServiceAccountTokenPath *string `mapstructure:"k8s_service_account_token_path"`
	// Value of an account token for k8s auth method.
	//
	// This can also be set via the VAULT_K8S_SERVICE_ACCOUNT_TOKEN.
	K8SServiceAccountToken *string `mapstructure:"k8s_service_account_token"`
	// K8SServiceMountPath is a part of k8s login path, by default the value is
	// "kubernetes". In this case a full path will be "auth/kubernetes/login".
	//
	// This can also be set via the VAULT_K8S_SERVICE_MOUNT_PATH.
	K8SServiceMountPath *string `mapstructure:"k8s_service_mount_path"`
}

VaultConfig is the configuration for connecting to a vault server.

func DefaultVaultConfig

func DefaultVaultConfig() *VaultConfig

DefaultVaultConfig returns a configuration that is populated with the default values.

func (*VaultConfig) Copy

func (c *VaultConfig) Copy() *VaultConfig

Copy returns a deep copy of this configuration.

func (*VaultConfig) Finalize

func (c *VaultConfig) Finalize()

Finalize ensures there no nil pointers.

func (*VaultConfig) GoString

func (c *VaultConfig) GoString() string

GoString defines the printable version of this struct.

func (*VaultConfig) Merge

func (c *VaultConfig) Merge(o *VaultConfig) *VaultConfig

Merge combines all values in this configuration with the values in the other configuration, with values in the other configuration taking precedence. Maps and slices are merged, most other values are overwritten. Complex structs define their own merge functionality.

type WaitConfig

type WaitConfig struct {
	// Enabled determines if this wait is enabled.
	Enabled *bool `mapstructure:"bool"`

	// Min and Max are the minimum and maximum time, respectively, to wait for
	// data changes before rendering a new template to disk.
	Min *time.Duration `mapstructure:"min"`
	Max *time.Duration `mapstructure:"max"`
}

WaitConfig is the Min/Max duration used by the Watcher

func DefaultWaitConfig

func DefaultWaitConfig() *WaitConfig

DefaultWaitConfig is the default configuration.

func ParseWaitConfig

func ParseWaitConfig(s string) (*WaitConfig, error)

ParseWaitConfig parses a string of the format `minimum(:maximum)` into a WaitConfig.

func (*WaitConfig) Copy

func (c *WaitConfig) Copy() *WaitConfig

Copy returns a deep copy of this configuration.

func (*WaitConfig) Finalize

func (c *WaitConfig) Finalize()

Finalize ensures there no nil pointers.

func (*WaitConfig) GoString

func (c *WaitConfig) GoString() string

GoString defines the printable version of this struct.

func (*WaitConfig) Merge

func (c *WaitConfig) Merge(o *WaitConfig) *WaitConfig

Merge combines all values in this configuration with the values in the other configuration, with values in the other configuration taking precedence. Maps and slices are merged, most other values are overwritten. Complex structs define their own merge functionality.

type WaitVar

type WaitVar WaitConfig

WaitVar implements the Flag.Value interface and allows the user to specify a watch interval using Go's flag parsing library.

func (*WaitVar) Set

func (w *WaitVar) Set(value string) error

Set sets the value in the format min[:max] for a wait timer.

func (*WaitVar) String

func (w *WaitVar) String() string

String returns the string format for this wait variable

Jump to

Keyboard shortcuts

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