config

package
v0.19.5 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2018 License: MPL-2.0 Imports: 20 Imported by: 0

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
)
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
)
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 (
	// DefaultVaultGrace is the default grace period before which to read a new
	// secret from Vault. If a lease is due to expire in 15 seconds, Consul
	// Template will read a new secret at that time minus this value.
	DefaultVaultGrace = 15 * time.Second

	// 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
)
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 (
	// 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 is the default signal to send to the process to
	// tell it to reload its configuration.
	DefaultExecReloadSignal = (os.Signal)(nil)
)
View Source
var (
	// DefaultMaxIdleConnsPerHost is the default number of idle connections to use
	// per host.
	DefaultMaxIdleConnsPerHost = runtime.GOMAXPROCS(0) + 1
)
View Source
var (
	// ErrAuthStringEmpty is the error returned with authentication is provided,
	// but empty.
	ErrAuthStringEmpty = errors.New("auth: cannot be 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 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"`
}

AuthConfig is the HTTP basic authentication data.

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"`

	// 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"`

	// 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"`

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

	// Wait is the quiescence timers.
	Wait *WaitConfig `mapstructure:"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) 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

	// 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

	// 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"`
}

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 EnvConfig

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

	// 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 whitelist/blacklist, 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"`

	// WhitelistEnv specifies a list of environment variables to exclusively
	// include in the list of environment variables populated to the child.
	Whitelist []string `mapstructure:"whitelist"`
}

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, whitelist, and blacklist 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 *string `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. The
	// default value is "SIGTERM".
	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 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"`
}

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 *string `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"`

	// 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"`

	// 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"`
}

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 {
	// 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"`

	// Grace is the amount of time before a lease is about to expire to force a
	// new secret to be read.
	Grace *time.Duration `mapstructure:"grace"`

	// 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.
	Token *string `mapstructure:"token" 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"`
}

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