Documentation ¶
Index ¶
Constants ¶
const ( // DefaultFilePerms are the default file permissions for templates rendered // onto disk when a specific file permission has not already been specified. DefaultFilePerms = 0644 // DefaultDedupPrefix is the default prefix used for de-duplication mode DefaultDedupPrefix = "consul-template/dedup/" // DefaultCommandTimeout is the amount of time to wait for a command to return. DefaultCommandTimeout = 30 * time.Second // DefaultReloadSignal is the default signal for reload. DefaultReloadSignal = syscall.SIGHUP // DefaultDumpSignal is the default signal for a core dump. DefaultDumpSignal = syscall.SIGQUIT // DefaultKillSignal is the default signal for termination. DefaultKillSignal = syscall.SIGINT )
Variables ¶
This section is empty.
Functions ¶
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.
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 (*AuthConfig) String ¶
func (a *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 location of the Consul instance to query (may be an IP // address or FQDN) with port. Consul string `mapstructure:"consul"` // Token is the Consul API token. Token string `mapstructure:"token"` // ReloadSignal is the signal to listen for a reload event. ReloadSignal os.Signal `mapstructure:"reload_signal"` // DumpSignal is the signal to listen for a core dump event. DumpSignal os.Signal `mapstructure:"dump_signal"` // KillSignal is the signal to listen for a graceful terminate event. KillSignal os.Signal `mapstructure:"kill_signal"` // Auth is the HTTP basic authentication for communicating with Consul. Auth *AuthConfig `mapstructure:"auth"` // Vault is the configuration for connecting to a vault server. Vault *VaultConfig `mapstructure:"vault"` // 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"` // Syslog is the configuration for syslog. Syslog *SyslogConfig `mapstructure:"syslog"` // Exec is the configuration for exec/supervise mode. Exec *ExecConfig `mapstructure:"exec"` // 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"` // ConfigTemplates is a slice of the ConfigTemplate objects in the config. ConfigTemplates []*ConfigTemplate `mapstructure:"template"` // Retry is the duration of time to wait between Consul failures. Retry time.Duration `mapstructure:"retry"` // Wait is the quiescence timers. Wait *watch.Wait `mapstructure:"wait"` // PidFile is the path on disk where a PID file should be written containing // this processes PID. PidFile string `mapstructure:"pid_file"` // LogLevel is the level with which to log for this config. LogLevel string `mapstructure:"log_level"` // Deduplicate is used to configure the dedup settings Deduplicate *DeduplicateConfig `mapstructure:"deduplicate"` // contains filtered or unexported fields }
Config is used to configure Consul Template
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns the default configuration struct.
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 (*Config) Copy ¶
Copy returns a deep copy of the current configuration. This is useful because the nested data structures may be shared.
func (*Config) Merge ¶
Merge merges the values in config into this config object. Values in the config object overwrite the values in c.
type ConfigTemplate ¶
type ConfigTemplate struct { Source string `mapstructure:"source"` Destination string `mapstructure:"destination"` EmbeddedTemplate string `mapstructure:"contents"` Command string `mapstructure:"command"` CommandTimeout time.Duration `mapstructure:"command_timeout"` Perms os.FileMode `mapstructure:"perms"` Backup bool `mapstructure:"backup"` LeftDelim string `mapstructure:"left_delimiter"` RightDelim string `mapstructure:"right_delimiter"` Wait *watch.Wait `mapstructure:"wait"` }
ConfigTemplate is the representation of an input template, output location, and optional command to execute when rendered
func ParseConfigTemplate ¶
func ParseConfigTemplate(s string) (*ConfigTemplate, error)
ParseConfigTemplate parses a string into a ConfigTemplate struct
type DeduplicateConfig ¶
type DeduplicateConfig struct { // Controls if deduplication mode is enabled Enabled bool `mapstructure:"enabled"` // 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"` }
DeduplicateConfig 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.
type ExecConfig ¶
type ExecConfig struct { // Command is the command to execute and watch as a child process. Command string `mapstructure:"command"` // Splay is the maximum amount of time to wait to kill the process. Splay time.Duration `mapstructure:"splay"` // 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"` // 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"` }
ExecConfig is used to configure the application when it runs in exec/supervise mode.
type SSLConfig ¶
type SSLConfig struct { Enabled bool `mapstructure:"enabled"` Verify bool `mapstructure:"verify"` Cert string `mapstructure:"cert"` Key string `mapstructure:"key"` CaCert string `mapstructure:"ca_cert"` CaPath string `mapstructure:"ca_path"` ServerName string `mapstructure:"server_name"` }
SSLConfig is the configuration for SSL.
type SyslogConfig ¶
type SyslogConfig struct { Enabled bool `mapstructure:"enabled"` Facility string `mapstructure:"facility"` }
SyslogConfig is the configuration for syslog.
type VaultConfig ¶
type VaultConfig struct { Address string `mapstructure:"address"` Token string `mapstructure:"token" json:"-"` UnwrapToken bool `mapstructure:"unwrap_token"` RenewToken bool `mapstructure:"renew_token"` // SSL indicates we should use a secure connection while talking to Vault. SSL *SSLConfig `mapstructure:"ssl"` }
VaultConfig is the configuration for connecting to a vault server.