config

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const Prefix = "courier"

Variables

View Source
var (
	ErrMissingBindAddr           = errors.New("invalid configuration: missing bindaddr")
	ErrMissingServerMode         = errors.New("invalid configuration: missing server mode (debug, release, test)")
	ErrMissingCertPaths          = errors.New("invalid configuration: missing cert path or pool path")
	ErrTLSNotConfigured          = errors.New("cannot create TLS configuration in insecure mode")
	ErrMissingLocalPath          = errors.New("invalid configuration: missing path for local storage")
	ErrNoStorageEnabled          = errors.New("invalid configuration: must enable either local storage or secret manager storage")
	ErrMultipleStorageEnabled    = errors.New("invalid configuration: cannot enable both local storage and secret manager storage")
	ErrMissingSecretsCredentials = errors.New("invalid configuration: missing credentials for secret manager storage")
	ErrMissingSecretsProject     = errors.New("invalid configuration: missing project name for secret manager storage")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	Maintenance      bool                `default:"false" desc:"starts the server in maintenance mode"`
	BindAddr         string              `split_words:"true" default:":8842" desc:"ip address and port of server"`
	Mode             string              `split_words:"true" default:"release" desc:"either debug or release"`
	LogLevel         logger.LevelDecoder `split_words:"true" default:"info" desc:"verbosity of logging: trace, debug, info, warn, error, fatal, panic"`
	ConsoleLog       bool                `split_words:"true" default:"false" desc:"set for human readable logs (otherwise json logs)"`
	MTLS             MTLSConfig          `split_words:"true"`
	LocalStorage     LocalStorageConfig  `split_words:"true"`
	GCPSecretManager GCPSecretsConfig    `split_words:"true"`
	// contains filtered or unexported fields
}

func New

func New() (conf Config, err error)

Create a new Config struct using values from the environment prefixed with COURIER.

func (Config) GetLogLevel added in v1.0.0

func (c Config) GetLogLevel() zerolog.Level

Parse and return the zerolog log level for configuring global logging.

func (Config) IsZero

func (c Config) IsZero() bool

Return true if the configuration has not been processed (e.g. not loaded from the environment or configuration file).

func (Config) Mark

func (c Config) Mark() (Config, error)

Mark a configuration as processed, for cases where the configuration is manually created (e.g. in tests).

func (Config) Validate

func (c Config) Validate() (err error)

Validate the configuration.

type GCPSecretsConfig

type GCPSecretsConfig struct {
	Enabled     bool   `split_words:"true" default:"false" desc:"set to true to enable GCP secret manager"`
	Credentials string `split_words:"true" desc:"path to json file with gcp service account credentials"`
	Project     string `split_words:"true" desc:"name of gcp project to use with secret manager"`
}

func (GCPSecretsConfig) Validate

func (c GCPSecretsConfig) Validate() (err error)

type LocalStorageConfig

type LocalStorageConfig struct {
	Enabled bool   `split_words:"true" default:"false" desc:"set to true to enable local storage"`
	Path    string `split_words:"true" desc:"path to the directory to store certs and passwords"`
}

func (LocalStorageConfig) Validate

func (c LocalStorageConfig) Validate() (err error)

type MTLSConfig

type MTLSConfig struct {
	Insecure bool   `split_words:"true" default:"true" desc:"set to false to enable TLS configuration"`
	CertPath string `split_words:"true" desc:"the certificate chain and private key of the server"`
	PoolPath string `split_words:"true" desc:"the cert pool to validate clients for mTLS"`
	// contains filtered or unexported fields
}

func (*MTLSConfig) GetCert

func (c *MTLSConfig) GetCert() (_ tls.Certificate, err error)

func (*MTLSConfig) GetCertPool

func (c *MTLSConfig) GetCertPool() (_ *x509.CertPool, err error)

func (*MTLSConfig) ParseTLSConfig

func (c *MTLSConfig) ParseTLSConfig() (_ *tls.Config, err error)

func (*MTLSConfig) Validate

func (c *MTLSConfig) Validate() error

Jump to

Keyboard shortcuts

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