nconf

package
v0.0.0-...-3e08555 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2020 License: MIT Imports: 17 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)

ConfigureLogging accepts a logging config for logrus

func LoadCAFromFiles

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

LoadCAFromFiles loads CA from files

func LoadCAFromValue

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

LoadCAFromValue loads CA from values

func LoadCertFromFiles

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

LoadCertFromFiles load certificate from files

func LoadCertFromValues

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

LoadCertFromValues load certificate from values

func LoadConfig

func LoadConfig(cmd *cobra.Command, serviceName string, input interface{}) error

LoadConfig loads the config from a file if specified, otherwise from the environment

func LoadConfigWithFile

func LoadConfigWithFile(serviceName, configFile string, input interface{}) error

LoadConfigWithFile loads the service configuration from an optional file, otherwise from the environment

func LoadFromEnv

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

func SetupBugSnag

func SetupBugSnag(config *BugSnagConfig, version string) error

Types

type BugSnagConfig

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

type HTTPClientTimeoutConfig

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

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

HTTPClientTimeoutConfig represents common HTTP client timeout values

type HTTPServerTimeoutConfig

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

HTTPServerTimeoutConfig represents common HTTP server timeout values

type LoggingConfig

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

LoggingConfig holds the configuration options

type RootArgs

type RootArgs struct {
	Prefix  string
	EnvFile string
}

RootArgs ..

func (*RootArgs) ConfigFlag

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

ConfigFlag reads the config flag

func (*RootArgs) MustSetup

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

MustSetup forces Setup

func (*RootArgs) PrefixFlag

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

PrefixFlag ...

func (*RootArgs) Setup

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

Setup ...

type TLSConfig

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

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

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

TLSConfig classic TLS Configuration

func (TLSConfig) TLSConfig

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

TLSConfig loads tls config and returns

Jump to

Keyboard shortcuts

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