Documentation ¶
Index ¶
- Constants
- Variables
- func Bool(b bool) *bool
- func BoolGoString(b *bool) string
- func BoolPresent(b *bool) bool
- func BoolVal(b *bool) bool
- func ConsulStringToStructFunc() mapstructure.DecodeHookFunc
- func FileMode(o os.FileMode) *os.FileMode
- func FileModeGoString(o *os.FileMode) string
- func FileModePresent(o *os.FileMode) bool
- func FileModeVal(o *os.FileMode) os.FileMode
- func Int(i int) *int
- func IntGoString(i *int) string
- func IntPresent(i *int) bool
- func IntVal(i *int) int
- func Signal(s os.Signal) *os.Signal
- func SignalGoString(s *os.Signal) string
- func SignalPresent(s *os.Signal) bool
- func SignalVal(s *os.Signal) os.Signal
- func String(s string) *string
- func StringGoString(s *string) string
- func StringPresent(s *string) bool
- func StringToFileModeFunc() mapstructure.DecodeHookFunc
- func StringVal(s *string) string
- func TimeDuration(t time.Duration) *time.Duration
- func TimeDurationGoString(t *time.Duration) string
- func TimeDurationPresent(t *time.Duration) bool
- func TimeDurationVal(t *time.Duration) time.Duration
- type AuthConfig
- type Config
- type ConsulConfig
- type EnvConfig
- type RetryConfig
- type RetryFunc
- type SSLConfig
- type SyslogConfig
- type TransportConfig
Constants ¶
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 )
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 )
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 )
const ( // DefaultSSLVerify is the default value for SSL verification. DefaultSSLVerify = true )
const (
// DefaultSyslogFacility is the default facility to log to.
DefaultSyslogFacility = "LOCAL0"
)
Variables ¶
var ( // DefaultMaxIdleConnsPerHost is the default number of idle connections to use // per host. DefaultMaxIdleConnsPerHost = runtime.GOMAXPROCS(0) + 1 )
var ( // ErrAuthStringEmpty is the error returned with authentication is provided, // but empty. ErrAuthStringEmpty = errors.New("auth: cannot be empty") )
Functions ¶
func BoolGoString ¶
BoolGoString returns the value of the boolean for printing in a string.
func BoolPresent ¶
BoolPresent returns a boolean indicating if the pointer is nil, or if the pointer is pointing to the zero value..
func BoolVal ¶
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 FileModeGoString ¶
FileModeGoString returns the value of the os.FileMode for printing in a string.
func FileModePresent ¶
FileModePresent returns a boolean indicating if the pointer is nil, or if the pointer is pointing to the zero value.
func FileModeVal ¶
FileModeVal returns the value of the os.FileMode at the pointer, or 0 if the pointer is nil.
func IntGoString ¶
IntGoString returns the value of the int for printing in a string.
func IntPresent ¶
IntPresent returns a boolean indicating if the pointer is nil, or if the pointer is pointing to the zero value.
func SignalGoString ¶
SignalGoString returns the value of the os.Signal for printing in a string.
func SignalPresent ¶
SignalPresent returns a boolean indicating if the pointer is nil, or if the pointer is pointing to the zero value..
func SignalVal ¶
SignalVal returns the value of the os.Signal at the pointer, or 0 if the pointer is nil.
func StringGoString ¶
StringGoString returns the value of the string for printing in a string.
func StringPresent ¶
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 StringVal ¶
StringVal returns the value of the string at the pointer, or "" if the pointer is nil.
func TimeDuration ¶
TimeDuration returns a pointer to the given time.Duration.
func TimeDurationGoString ¶
TimeDurationGoString returns the value of the time.Duration for printing in a string.
func TimeDurationPresent ¶
TimeDurationPresent returns a boolean indicating if the pointer is nil, or if the pointer is pointing to the zero value..
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"` // 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"` // 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"` From *string `mapstructure:"from"` To *string `mapstructure:"to"` Interval *time.Duration `mapstructure:"interval"` }
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 ¶
FromFile reads the configuration file at the given path and returns a new Config struct with the data populated.
func FromPath ¶
FromPath iterates and merges all configuration files in a given directory, returning the resulting config.
func Must ¶
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 TestConfig ¶
TestConfig returns a default, finalized config, with the provided configuration taking precedence.
func (*Config) Copy ¶
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.
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 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) Env ¶
Env calculates and returns the finalized environment for this exec configuration. It takes into account pristine, custom environment, whitelist, and blacklist values.
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 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.
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 TransportConfig ¶
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 ¶
func DefaultTransportConfig() *TransportConfig
DefaultTransportConfig returns a configuration that is populated with the default values.
func (*TransportConfig) Copy ¶
func (c *TransportConfig) Copy() *TransportConfig
Copy returns a deep copy of this configuration.
func (*TransportConfig) Finalize ¶
func (c *TransportConfig) Finalize()
Finalize ensures there no nil pointers.
func (*TransportConfig) GoString ¶
func (c *TransportConfig) GoString() string
GoString defines the printable version of this struct.
func (*TransportConfig) Merge ¶
func (c *TransportConfig) Merge(o *TransportConfig) *TransportConfig
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.