config

package
v0.0.0-...-0e2b5c9 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: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LogLevelNone  = "none"
	LogLevelDebug = "debug"
	LogLevelInfo  = "info"
	LogLevelWarn  = "warn"
	LogLevelError = "error"
)

List of available log levels

Variables

View Source
var (
	// ErrNoAddr is returned when the server address is missing from configuration
	ErrNoAddr = errors.New("no address supplied")
	// ErrNoCert is returned when the certificate path is missing from configuration
	ErrNoCert = errors.New("no certificate path supplied")
	// ErrNoKey is returned when the key path is missing from configuration
	ErrNoKey = errors.New("no key path supplied")
	// ErrNoPassphrase is returned when the passphrase is missing from configuration
	ErrNoPassphrase = errors.New("no database passphrase supplied")
	// ErrNoDatabase is returned when the database name is missing
	ErrNoDatabase = errors.New("no database name supplied")
	// ErrUnsupportedDBType is returned when an invalid DB type is provided in configuration
	ErrUnsupportedDBType = errors.New("unknown or unsupported database type")
	// ErrNoDBFile is returned when no database file is provided in configuration
	ErrNoDBFile = errors.New("no database file supplied")
	// ErrNoUsername is returned when no username is provided in configuration
	ErrNoUsername = errors.New("no username supplied")
	// ErrNoPassword is returned when no password is provided in configuration
	ErrNoPassword = errors.New("no password supplied")
	// ErrInvalidSecureConnection is returned when an invalid secure connection mode is provided.
	// see available config.DBSecureConnectionType
	ErrInvalidSecureConnection = errors.New("invalid secure connection mode")
	// ErrNoSchema is returned when database configuration is missing a schema (postgres only)
	ErrNoSchema = errors.New("no schema supplied")
	// ErrAtLeastOneURLRequired is returned when a list of urls is empty but require at least one
	ErrAtLeastOneURLRequired = errors.New("at least one url is required")
	// ErrIndexNameRequired is returned when a index name is empty but required
	ErrIndexNameRequired = errors.New("index name is required")
	// ErrGRPCAddrRequired is returned when the http-grpc-host-port is empty but required
	ErrGRPCAddrRequired = errors.New("http-grpc-host-port is required")
	// ErrInvalidCryptoMode is returned when the provided crypto mode is unknown
	ErrInvalidCryptoMode = errors.New("crypto-mode is invalid")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	Monitor bool

	Crypto CryptoCfg

	GRPC ServerCfg
	HTTP HTTPServerCfg

	MQTT  MQTTCfg
	Kafka KafkaCfg
	GCP   GCPCfg

	DB DBCfg

	OpencensusSampleAll bool
	OpencensusAddress   string

	ES ESCfg

	LoggerLevel string
}

Config type holds the application configuration

func New

func New() *Config

New creates a fresh configuration.

func (Config) Validate

func (c Config) Validate() error

Validate check Config and returns an error if anything is invalid

func (*Config) ViperCfgFields

func (cfg *Config) ViperCfgFields() []slibcfg.ViperCfgField

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

type CryptoCfg

type CryptoCfg struct {
	C2PrivateKeyPath       string
	NewClientKeySendPubkey bool
	// contains filtered or unexported fields
}

CryptoCfg holds the crypto configuration

func (CryptoCfg) CryptoMode

func (c CryptoCfg) CryptoMode() CryptoMode

CryptoMode returns configured mode as CryptoMode

func (CryptoCfg) Validate

func (c CryptoCfg) Validate() error

Validate checks CryptoCfg and returns an error if anything is invalid

type CryptoMode

type CryptoMode string

CryptoMode defines the type of cryptography used by the C2 instance

const (
	SymKey CryptoMode = "symkey"
	PubKey CryptoMode = "pubkey"
)

List of crypto modes supported

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) Validate

func (c DBCfg) Validate() error

Validate checks DBCfg and returns an error if anything is invalid

type ESCfg

type ESCfg struct {
	Enable bool
	URLs   []string

	MessageIndexName string
	// contains filtered or unexported fields
}

ESCfg holds ElasticSearch config

func (ESCfg) IsMessageLoggingEnabled

func (c ESCfg) IsMessageLoggingEnabled() bool

IsMessageLoggingEnabled indicate whenever broker message must be logged to elasticsearch

func (ESCfg) Validate

func (c ESCfg) Validate() error

Validate checks ESCfg and returns an error if anything is invalid

type GCPCfg

type GCPCfg struct {
	Enabled          bool
	ProjectID        string
	Region           string
	RegistryID       string
	CommandSubFolder string
}

GCPCfg holds configuration for GCP IoT Core

type HTTPServerCfg

type HTTPServerCfg struct {
	ServerCfg
	GRPCAddr string
}

HTTPServerCfg extends the ServerCfg for the HTTP

func (HTTPServerCfg) Validate

func (c HTTPServerCfg) Validate() error

Validate checks HTTPServerCfg and returns an error if anything is invalid

type KafkaCfg

type KafkaCfg struct {
	Enabled bool
	Brokers []string
}

KafkaCfg holds configuration for Kafka

func (KafkaCfg) Validate

func (c KafkaCfg) Validate() error

Validate checks KafkaCfg and returns an error if anything is invalid

type MQTTCfg

type MQTTCfg struct {
	Enabled  bool
	ID       string
	Broker   string
	QoSPub   int
	QoSSub   int
	Username string
	Password string
}

MQTTCfg holds configuration for MQTT

func (MQTTCfg) Validate

func (c MQTTCfg) Validate() error

Validate checks MQTTCfg and returns an error if anything is invalid

type ServerCfg

type ServerCfg struct {
	Addr string
	Key  string
	Cert string
}

ServerCfg holds configuration for a 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