config

package
v0.0.0-...-0d671b9 Latest Latest
Warning

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

Go to latest
Published: May 7, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDBFilepathRequired      = errors.New("database file path is required")
	ErrC2EndpointRequired      = errors.New("c2 endpoint is required")
	ErrC2CertificateRequired   = errors.New("c2 certificate is required")
	ErrC2CertificatePath       = errors.New("c2 certificate can't be read")
	ErrGRPCListenAddrRequired  = errors.New("grpc listen address is required")
	ErrHTTPListenAddrRequired  = errors.New("http listen address is required")
	ErrNoPassphrase            = errors.New("no database passphrase supplied")
	ErrNoDBAddr                = errors.New("no database address supplied")
	ErrNoDatabase              = errors.New("no database name supplied")
	ErrUnsupportedDBType       = errors.New("unknown or unsupported database type")
	ErrNoDBFile                = errors.New("no database file supplied")
	ErrNoUsername              = errors.New("no username supplied")
	ErrNoPassword              = errors.New("no password supplied")
	ErrInvalidSecureConnection = errors.New("invalid secure connection mode")
	ErrNoSchema                = errors.New("no schema supplied")
	ErrGRPCCertRequired        = errors.New("grpc certificate path is required")
	ErrGRPCKeyRequired         = errors.New("grpc key path is required")
	ErrHTTPCertRequired        = errors.New("http certificate path is required")
	ErrHTTPKeyRequired         = errors.New("http key path is required")
	ErrHTTPGRPCAddrRequired    = errors.New("http-grpc address is required")
)

Config validation errors

Functions

This section is empty.

Types

type API

type API struct {
	Server              ServerCfg
	DB                  DBCfg
	C2Endpoint          string
	C2Certificate       string
	OpencensusSampleAll bool
	OpencensusAddress   string
	LoggerLevel         string
}

API describes the configuration required for the API application

func NewAPI

func NewAPI() *API

NewAPI creates a new configuration struct for the C2AE api

func (API) Validate

func (c API) Validate() error

Validate checks configuration and return errors when invalid

func (*API) ViperCfgFields

func (c *API) ViperCfgFields() []slibcfg.ViperCfgField

ViperCfgFields returns the list of configuration bound's fields to be loaded by viper

type DBCfg

type DBCfg struct {
	Logging          bool
	Type             slibcfg.DBType
	File             string
	Host             string
	Database         string
	Username         string
	Password         string
	Passphrase       string
	Schema           string
	SecureConnection slibcfg.DBSecureConnectionType
}

DBCfg holds configuration for databases

func (DBCfg) ConnectionString

func (c DBCfg) ConnectionString() (string, error)

ConnectionString returns the string to use to establish the db connection

func (DBCfg) LogFields

func (c DBCfg) LogFields() log.Fields

LogFields returns parts of the configuration that is safe to log (ie: no passwords)

func (DBCfg) Validate

func (c DBCfg) Validate() error

Validate checks DBCfg and returns an error if anything is invalid

type ServerCfg

type ServerCfg struct {
	GRPCAddr     string
	GRPCCert     string
	GRPCKey      string
	HTTPAddr     string
	HTTPGRPCAddr string
	HTTPCert     string
	HTTPKey      string
}

ServerCfg holds configuration for api server

func (ServerCfg) Validate

func (c ServerCfg) Validate() error

Validate checks ServerCfg and returns an error if anything is invalid

Jump to

Keyboard shortcuts

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