config

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2022 License: MPL-2.0 Imports: 14 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
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

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

	// Exec is the configuration for exec/supervise mode.
	Exec *config.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.
	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"`

	// Prefixes is the list of all prefix dependencies (consul)
	// in merge order.
	Prefixes *PrefixConfigs `mapstructure:"prefix"`

	// Pristine indicates that we want a clean environment only
	// composed of consul config variables, not inheriting from exising
	// environment
	Pristine *bool `mapstructure:"pristine"`

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

	// Sanitize converts any "bad" characters in key values to underscores
	Sanitize *bool `mapstructure:"sanitize"`

	// Secrets is the list of all secret dependencies (vault)
	Secrets *PrefixConfigs `mapstructure:"secret"`

	Services *ServiceConfigs `mapstructure:"service"`

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

	// Upcase converts environment variables to uppercase
	Upcase *bool `mapstructure:"upcase"`

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

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

Config is used to configure Consul ENV

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

type KeyFormat

type KeyFormat struct {
	Format *string `mapstructure:"format"`
	Name   *string `mapstructure:"name"`
}

KeyFormat wraps configuration for a particular key in secrets set.

Name is the name of the key Format is per-key format override, just like PrefixConfig.Format

func (*KeyFormat) Copy

func (f *KeyFormat) Copy() *KeyFormat

type KeyFormats

type KeyFormats []*KeyFormat

KeyFormats holds a list of per-key override configurations.

func (*KeyFormats) Copy

func (f *KeyFormats) Copy() *KeyFormats

type PrefixConfig

type PrefixConfig struct {
	Format   *string     `mapstructure:"format"`
	NoPrefix *bool       `mapstructure:"no_prefix"`
	Path     *string     `mapstructure:"path"`
	Keys     *KeyFormats `mapstructure:"key"`
}

PrefixConfig is a wrapper around some common options for Consul and Vault prefixes.

func DefaultPrefixConfig

func DefaultPrefixConfig() *PrefixConfig

func ParsePrefixConfig

func ParsePrefixConfig(s string) (*PrefixConfig, error)

func (*PrefixConfig) Copy

func (c *PrefixConfig) Copy() *PrefixConfig

func (*PrefixConfig) Finalize

func (c *PrefixConfig) Finalize()

func (*PrefixConfig) GoString

func (c *PrefixConfig) GoString() string

func (*PrefixConfig) Merge

func (c *PrefixConfig) Merge(o *PrefixConfig) *PrefixConfig

type PrefixConfigs

type PrefixConfigs []*PrefixConfig

func DefaultPrefixConfigs

func DefaultPrefixConfigs() *PrefixConfigs

func (*PrefixConfigs) Copy

func (c *PrefixConfigs) Copy() *PrefixConfigs

func (*PrefixConfigs) Finalize

func (c *PrefixConfigs) Finalize()

func (*PrefixConfigs) GoString

func (c *PrefixConfigs) GoString() string

func (*PrefixConfigs) Merge

type ServiceConfig

type ServiceConfig struct {
	Query         *string `mapstructure:"query"`
	FormatId      *string `mapstructure:"format_id"`
	FormatName    *string `mapstructure:"format_name"`
	FormatAddress *string `mapstructure:"format_address"`
	FormatTag     *string `mapstructure:"format_tag"`
	FormatPort    *string `mapstructure:"format_port"`
}

func DefaultServiceConfig

func DefaultServiceConfig() *ServiceConfig

func ParseServiceConfig

func ParseServiceConfig(s string) (*ServiceConfig, error)

func (*ServiceConfig) Copy

func (s *ServiceConfig) Copy() *ServiceConfig

func (*ServiceConfig) Finalize

func (s *ServiceConfig) Finalize()

func (*ServiceConfig) GoString

func (s *ServiceConfig) GoString() string

func (*ServiceConfig) Merge

type ServiceConfigs

type ServiceConfigs []*ServiceConfig

func DefaultServiceConfigs

func DefaultServiceConfigs() *ServiceConfigs

func (*ServiceConfigs) Copy

func (s *ServiceConfigs) Copy() *ServiceConfigs

func (*ServiceConfigs) Finalize

func (s *ServiceConfigs) Finalize()

func (*ServiceConfigs) GoString

func (s *ServiceConfigs) GoString() string

func (*ServiceConfigs) LastSeviceConfig

func (s *ServiceConfigs) LastSeviceConfig() *ServiceConfig

func (*ServiceConfigs) Merge

Jump to

Keyboard shortcuts

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