config

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2020 License: BSD-3-Clause Imports: 12 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetCurrentConfigDirectories

func GetCurrentConfigDirectories() (main, legacy, overwrite string)

GetCurrentConfigDirectories returns currently used service YML configuration locations

func GetServiceConfigs

func GetServiceConfigs(serviceName string) (map[string]*ConfigMap, error)

GetServiceConfigs returns module-keyed configs for the named service from all known modules. The list of known modules is determined by listing all non-directory files under /etc/magma/configs.

func GetStructuredServiceConfig

func GetStructuredServiceConfig(moduleName string, serviceName string, out interface{}) (string, string, error)

GetStructuredServiceConfig updates 'out' structure with configs from the configs YML If successful, GetStructuredServiceConfig returns used YML file path & used overwrite cfg YML file path

func GetStructuredServiceConfigExt

func GetStructuredServiceConfigExt(
	moduleName,
	serviceName,
	configDir,
	oldConfigDir,
	configOverrideDir string,
	out interface{}) (ymlFilePath, ymlQWFilePath string, err error)

GetStructuredServiceConfigExt is an extended version of GetStructuredServiceConfig, it allows to pass config directory names

func SetConfigDirectories

func SetConfigDirectories(main, legacy, overwrite string)

SetConfigDirectories sets main, legacy, overwrite config directories to be used

Types

type ConfigMap

type ConfigMap struct {
	RawMap map[interface{}]interface{}
}

ConfigMap represents a map generated from a service YML file.

func GetServiceConfig

func GetServiceConfig(moduleName string, serviceName string) (*ConfigMap, error)

GetServiceConfig loads a config by name to a map of parameters Input: configName - name of config to load, e.g. control_proxy Output: map of parameters if it exists, error if not

func MustGetServiceConfig

func MustGetServiceConfig(moduleName string, serviceName string) *ConfigMap

MustGetServiceConfig is same as GetServiceConfig but fails on errors.

func NewConfigMap

func NewConfigMap(config map[interface{}]interface{}) *ConfigMap

NewConfigMap creates a new ConfigMap based on the input map.

func (*ConfigMap) GetBool

func (c *ConfigMap) GetBool(key string) (bool, error)

GetBool retrieves the bool parameter keyed by the passed key.

func (*ConfigMap) GetInt

func (c *ConfigMap) GetInt(key string) (int, error)

GetInt retrieves the int parameter keyed by the passed key.

func (*ConfigMap) GetMap

func (c *ConfigMap) GetMap(key string) (map[interface{}]interface{}, error)

GetMap retrieves the map[interface{}]interface{} parameter keyed by the passed key.

func (*ConfigMap) GetString

func (c *ConfigMap) GetString(key string) (string, error)

GetString retrieves the string parameter keyed by the passed key.

func (*ConfigMap) GetStrings

func (c *ConfigMap) GetStrings(key string) ([]string, error)

GetStrings retrieves the []string parameter keyed by the passed key.

func (*ConfigMap) MustGetBool

func (c *ConfigMap) MustGetBool(key string) bool

MustGetBool is same as GetBool but fails on errors and when the value does not exist.

func (*ConfigMap) MustGetInt

func (c *ConfigMap) MustGetInt(key string) int

MustGetInt is same as GetInt but fails on errors and when the value does not exist.

func (*ConfigMap) MustGetMap

func (c *ConfigMap) MustGetMap(key string) map[interface{}]interface{}

MustGetMap is same as GetMap but fails on errors and when the value does not exist.

func (*ConfigMap) MustGetString

func (c *ConfigMap) MustGetString(key string) string

MustGetString is same as GetString but fails on errors and when the value does not exist.

func (*ConfigMap) MustGetStrings

func (c *ConfigMap) MustGetStrings(key string) []string

MustGetStrings is same as GetStrings but fails on errors and when the value does not exist.

func (*ConfigMap) SetString

func (c *ConfigMap) SetString(strPtr *string, key string) error

SetString tries to set set the given string pointer to config value keyed by the passed key.

func (*ConfigMap) Validate

func (c *ConfigMap) Validate() error

Validate the config map.

Jump to

Keyboard shortcuts

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