config

package
v0.0.0-...-1d39891 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoAnalyzerSpecified = errors.New("No analyzer specified in the configuration file")

ErrNoAnalyzerSpecified error no analyzer section is specified in the configuration file

Functions

func BindPFlag

func BindPFlag(key string, flag *pflag.Flag) error

BindPFlag binds a command line flag to a configuration value

func Get

func Get(key string) interface{}

Get returns a value of the configuration as in interface

func GetAnalyzerServiceAddresses

func GetAnalyzerServiceAddresses() ([]common.ServiceAddress, error)

GetAnalyzerServiceAddresses returns a list of connectable Analyzers

func GetBool

func GetBool(key string) bool

GetBool returns a boolean from the configuration

func GetEtcdServerAddrs

func GetEtcdServerAddrs() []string

GetEtcdServerAddrs returns the ETCD server address specified in the configuration file or embedded

func GetInt

func GetInt(key string) int

GetInt returns an interger from the configuration

func GetOneAnalyzerServiceAddress

func GetOneAnalyzerServiceAddress() (common.ServiceAddress, error)

GetOneAnalyzerServiceAddress returns a random connectable Analyzer

func GetString

func GetString(key string) string

GetString returns a string from the configuration

func GetStringMapString

func GetStringMapString(key string) map[string]string

GetStringMapString returns a map of strings from the configuration

func GetStringSlice

func GetStringSlice(key string) []string

GetStringSlice returns a slice of strings from the configuration

func GetTLSClientConfig

func GetTLSClientConfig(setupRootCA bool) (*tls.Config, error)

GetTLSClientConfig returns TLS config to be used by client

func GetTLSServerConfig

func GetTLSServerConfig(setupRootCA bool) (*tls.Config, error)

GetTLSServerConfig returns TLS config to be used by server

func GetURL

func GetURL(protocol string, addr string, port int, path string) *url.URL

GetURL constructs a URL from a tuple of protocol, address, port and path If TLS is enabled, it will return the https (or wss) version of the URL.

func InitConfig

func InitConfig(backend string, paths []string) error

InitConfig global config

func InitLogging

func InitLogging() error

InitLogging set up logging based on the section "logging" of the configuration file

func InitRBAC

func InitRBAC(kapi etcd.KeysAPI) error

InitRBAC inits the RBAC mechanism. It load - the model from the configuration - a policy on etcd - a policy bundled in the executable - additional policy rules from the configuration

func IsSet

func IsSet(key string) bool

IsSet returns wether a key is set

func IsTLSEnabled

func IsTLSEnabled() bool

IsTLSEnabled returns true is the client / server certificates are set

func LoadConfig

func LoadConfig(cfg *viper.Viper, backend string, paths []string) error

LoadConfig initializes config with the given backend/path

func NewAuthenticationBackendByName

func NewAuthenticationBackendByName(name string) (backend shttp.AuthenticationBackend, err error)

NewAuthenticationBackendByName creates a new auth backend based on the name

func NewHTTPServer

func NewHTTPServer(serviceType common.ServiceType) (*shttp.Server, error)

NewHTTPServer returns a new HTTP server based on the configuration

func NewWSClient

func NewWSClient(clientType common.ServiceType, url *url.URL, opts websocket.ClientOpts) (*websocket.Client, error)

NewWSClient creates a Client based on the configuration

func NewWSServer

func NewWSServer(server *shttp.Server, endpoint string, authBackend shttp.AuthenticationBackend) *websocket.Server

NewWSServer creates a Server based on the configuration

func Set

func Set(key string, value interface{})

Set a value of the configuration

func SetDefault

func SetDefault(key string, value interface{})

SetDefault set the default configuration value for a key

Types

type Config

type Config interface {
	SetDefault(key string, value interface{})
	IsSet(key string) bool
	Get(key string) interface{}
	Set(key string, value interface{})
	GetBool(key string) bool
	GetInt(key string) int
	GetString(key string) string
	GetStringSlice(key string) []string
	GetStringMapString(key string) map[string]string
	GetStringMap(key string) map[string]interface{}
}

Config defines a config interface

type SkydiveConfig

type SkydiveConfig struct {
	*viper.Viper
}

SkydiveConfig implements the Config interface

func GetConfig

func GetConfig() *SkydiveConfig

GetConfig get current config

func (*SkydiveConfig) Get

func (c *SkydiveConfig) Get(key string) interface{}

Get returns a value of the configuration as in interface

func (*SkydiveConfig) GetAnalyzerServiceAddresses

func (c *SkydiveConfig) GetAnalyzerServiceAddresses() ([]common.ServiceAddress, error)

GetAnalyzerServiceAddresses returns a list of connectable Analyzers

func (*SkydiveConfig) GetBool

func (c *SkydiveConfig) GetBool(key string) bool

GetBool returns a boolean from the configuration

func (*SkydiveConfig) GetEtcdServerAddrs

func (c *SkydiveConfig) GetEtcdServerAddrs() []string

GetEtcdServerAddrs returns the ETCD server address specified in the configuration file or embedded

func (*SkydiveConfig) GetInt

func (c *SkydiveConfig) GetInt(key string) int

GetInt returns an interger from the configuration

func (*SkydiveConfig) GetOneAnalyzerServiceAddress

func (c *SkydiveConfig) GetOneAnalyzerServiceAddress() (common.ServiceAddress, error)

GetOneAnalyzerServiceAddress returns a random connectable Analyzer

func (*SkydiveConfig) GetString

func (c *SkydiveConfig) GetString(key string) string

GetString returns a string from the configuration

func (*SkydiveConfig) GetStringMapString

func (c *SkydiveConfig) GetStringMapString(key string) map[string]string

GetStringMapString returns a map of strings from the configuration

func (*SkydiveConfig) GetStringSlice

func (c *SkydiveConfig) GetStringSlice(key string) []string

GetStringSlice returns a slice of strings from the configuration

func (*SkydiveConfig) GetURL

func (c *SkydiveConfig) GetURL(protocol string, addr string, port int, path string) *url.URL

GetURL constructs a URL from a tuple of protocol, address, port and path If TLS is enabled, it will return the https (or wss) version of the URL.

func (*SkydiveConfig) IsSet

func (c *SkydiveConfig) IsSet(key string) bool

IsSet returns wether a key is set

func (*SkydiveConfig) IsTLSEnabled

func (c *SkydiveConfig) IsTLSEnabled() bool

IsTLSEnabled returns true is the client / server certificates are set

func (*SkydiveConfig) Set

func (c *SkydiveConfig) Set(key string, value interface{})

Set a value of the configuration

func (*SkydiveConfig) SetDefault

func (c *SkydiveConfig) SetDefault(key string, value interface{})

SetDefault set the default configuration value for a key

Jump to

Keyboard shortcuts

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