nconf

package
v0.58.4 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2021 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigureLogging

func ConfigureLogging(config LoggingConfig) (*logrus.Entry, error)

func LoadCAFromFiles

func LoadCAFromFiles(cafiles []string) (*x509.CertPool, error)

func LoadCAFromValue

func LoadCAFromValue(ca string) (*x509.CertPool, error)

func LoadCertFromFiles

func LoadCertFromFiles(certFile, keyFile string) (tls.Certificate, error)

func LoadCertFromValues

func LoadCertFromValues(certPEM, keyPEM string) (tls.Certificate, error)

func LoadConfigFromFile added in v0.49.0

func LoadConfigFromFile(configFile string, input interface{}) error

LoadConfigFromFile will load the configuration from the specified file based on the file type There is only support for .json and .yml now. It will use the underlying json/yaml packages directly. meaning those should be the only required tags.

func LoadFromEnv

func LoadFromEnv(prefix, filename string, face interface{}) error

func LoadFromFile deprecated added in v0.40.1

func LoadFromFile(configFile string, input interface{}) error
Deprecated: This method relies on parsing the json/yaml to a map, then running it through mapstructure.
This required that both tags exist (annoying!). And so there is now LoadConfigFromFile.

LoadFromFile will load the configuration from the specified file based on the file type There is only support for .json and .yml now

func SetupBugSnag

func SetupBugSnag(config *BugSnagConfig, version string) error

Types

type BugSnagConfig

type BugSnagConfig struct {
	Environment    string
	APIKey         string `envconfig:"api_key" json:"api_key" yaml:"api_key"`
	LogHook        bool   `envconfig:"log_hook" json:"log_hook" yaml:"log_hook"`
	ProjectPackage string `envconfig:"project_package" json:"project_package" yaml:"project_package"`
}

type ErrUnknownConfigFormat added in v0.48.3

type ErrUnknownConfigFormat struct {
	// contains filtered or unexported fields
}

ErrUnknownConfigFormat indicates the extension of the config file is not supported as a config source

func (*ErrUnknownConfigFormat) Error added in v0.48.3

func (e *ErrUnknownConfigFormat) Error() string

type HTTPClientTimeoutConfig

type HTTPClientTimeoutConfig struct {
	// Dial = net.Dialer.Timeout
	Dial util.Duration `mapstructure:"dial"`
	// KeepAlive = net.Dialer.KeepAlive
	KeepAlive util.Duration `mapstructure:"keep_alive" split_words:"true" json:"keep_alive" yaml:"keep_alive"`

	// TLSHandshake = http.Transport.TLSHandshakeTimeout
	TLSHandshake util.Duration `mapstructure:"tls_handshake" split_words:"true" json:"tls_handshake" yaml:"tls_handshake"`
	// ResponseHeader = http.Transport.ResponseHeaderTimeout
	ResponseHeader util.Duration `mapstructure:"response_header" split_words:"true" json:"response_header" yaml:"response_header"`
	// Total = http.Client.Timeout or equivalent
	// The maximum amount of time a client request can take.
	Total util.Duration `mapstructure:"total"`
}

HTTPClientTimeoutConfig represents common HTTP client timeout values

type HTTPServerTimeoutConfig

type HTTPServerTimeoutConfig struct {
	// Read = http.Server.ReadTimeout
	Read util.Duration `mapstructure:"read"`
	// Write = http.Server.WriteTimeout
	Write util.Duration `mapstructure:"write"`
	// Handler = http.TimeoutHandler (or equivalent).
	// The maximum amount of time a server handler can take.
	Handler util.Duration `mapstructure:"handler"`
}

HTTPServerTimeoutConfig represents common HTTP server timeout values

type LoggingConfig

type LoggingConfig struct {
	Level            string                 `mapstructure:"log_level"`
	File             string                 `mapstructure:"log_file"`
	DisableColors    bool                   `mapstructure:"disable_colors" split_words:"true" json:"disable_colors" yaml:"disable_colors"`
	QuoteEmptyFields bool                   `mapstructure:"quote_empty_fields" split_words:"true" json:"quote_empty_fields" yaml:"quote_empty_fields"`
	TSFormat         string                 `mapstructure:"ts_format" json:"ts_format" yaml:"ts_format"`
	Fields           map[string]interface{} `mapstructure:"fields"`
	UseNewLogger     bool                   `mapstructure:"use_new_logger" split_words:"true" json:"use_new_logger" yaml:"use_new_logger"`
}

type RootArgs

type RootArgs struct {
	Prefix     string
	ConfigFile string
}

func (*RootArgs) AddFlags added in v0.40.1

func (args *RootArgs) AddFlags(cmd *cobra.Command) *cobra.Command

func (*RootArgs) ConfigFlag

func (args *RootArgs) ConfigFlag() *pflag.Flag

func (*RootArgs) MustSetup

func (args *RootArgs) MustSetup(config interface{}, serviceName, version string) logrus.FieldLogger

func (*RootArgs) PrefixFlag

func (args *RootArgs) PrefixFlag() *pflag.Flag

func (*RootArgs) Setup

func (args *RootArgs) Setup(config interface{}, serviceName, version string) (logrus.FieldLogger, error)

type RootConfig added in v0.48.0

type RootConfig struct {
	Log         LoggingConfig
	BugSnag     *BugSnagConfig
	Metrics     metriks.Config
	Tracing     tracing.Config
	FeatureFlag featureflag.Config
	Instrument  instrument.Config
}

func DefaultConfig added in v0.49.0

func DefaultConfig() RootConfig

type TLSConfig

type TLSConfig struct {
	CAFiles  []string `mapstructure:"ca_files" envconfig:"ca_files" json:"ca_files" yaml:"ca_files"`
	KeyFile  string   `mapstructure:"key_file" split_words:"true" json:"key_file" yaml:"key_file"`
	CertFile string   `mapstructure:"cert_file" split_words:"true" json:"cert_file" yaml:"cert_file"`

	Cert string `mapstructure:"cert"`
	Key  string `mapstructure:"key"`
	CA   string `mapstructure:"ca"`

	Insecure bool `default:"false"`
	Enabled  bool `default:"false"`
}

func (TLSConfig) TLSConfig

func (cfg TLSConfig) TLSConfig() (*tls.Config, error)

Jump to

Keyboard shortcuts

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