Documentation ¶
Overview ¶
Package configmanager, reads JSON configuration with an arbitrary structure
Index ¶
- type ConfigFileType
- type Configuration
- func (cfg *Configuration) AddSearchPath(searchpath string)
- func (cfg Configuration) AllSettings() interface{}
- func (cfg *Configuration) Encrypt(key string) (err error)
- func (cfg Configuration) Get(key string) interface{}
- func (cfg Configuration) GetArray(key string) (arr map[string]string, err error)
- func (cfg Configuration) GetArrayValues(key string) (values []string, err error)
- func (cfg Configuration) GetBool(key string) (bool, error)
- func (cfg Configuration) GetInt(key string) (int, error)
- func (cfg Configuration) GetString(key string) string
- func (cfg Configuration) IsEncrypted(key string) int8
- func (cfg *Configuration) ReadConfiguration() (err error)
- func (cfg *Configuration) SaveEncryptionKey(key string, encryptionKey []byte, encryptionNonce []byte) (err error)
- func (cfg *Configuration) SetAuditing(au *audit.Audit)
- func (cfg *Configuration) SetBool(key string, value bool) (err error)
- func (cfg *Configuration) SetFilename(filename string)
- func (cfg *Configuration) SetFiletype(filetype ConfigFileType)
- func (cfg *Configuration) SetMonitorForChange(monitor bool)
- func (cfg *Configuration) SetString(key string, value string) (err error)
- func (cfg Configuration) Write(filename string) (err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConfigFileType ¶
type ConfigFileType int
const ( CFT_YAML ConfigFileType = 1 // Not supported CFT_JSON ConfigFileType = 2 )
type Configuration ¶
type Configuration struct {
// contains filtered or unexported fields
}
Configuration defines the Configuration structure. It has no exposed properties
func New ¶
func New(slog *servicelogger.Logger, queue *basicqueue.BasicQueue) (cfg Configuration, err error)
New creates a new Configuration object
func (*Configuration) AddSearchPath ¶
func (cfg *Configuration) AddSearchPath(searchpath string)
AddSearchPath adds a search path to the list of paths to search for the configuration file
func (Configuration) AllSettings ¶
func (cfg Configuration) AllSettings() interface{}
AllSettings returns the map of all the settings read from the configuration as an interface{}
func (*Configuration) Encrypt ¶
func (cfg *Configuration) Encrypt(key string) (err error)
Encrypt encrypts a key's string value (doesn't make sense for any other type) and replaces its unencrypted value in the configuration map by its encrypted value
func (Configuration) Get ¶
func (cfg Configuration) Get(key string) interface{}
Get returns the value of "key" as an interface{}
func (Configuration) GetArray ¶
func (cfg Configuration) GetArray(key string) (arr map[string]string, err error)
GetArray returns the value of "key" as an array
func (Configuration) GetArrayValues ¶
func (cfg Configuration) GetArrayValues(key string) (values []string, err error)
GetArrayValues returns the values of the array below "key" as an array of strings
func (Configuration) GetBool ¶
func (cfg Configuration) GetBool(key string) (bool, error)
GetBool returns the value of "key" as a bool
func (Configuration) GetInt ¶
func (cfg Configuration) GetInt(key string) (int, error)
GetInt returns the value of "key" as an int
func (Configuration) GetString ¶
func (cfg Configuration) GetString(key string) string
GetString returns the value of "key" as a string. If the key value is encrypted it is decrypted
func (Configuration) IsEncrypted ¶
func (cfg Configuration) IsEncrypted(key string) int8
IsEncrypted checks whether a key's value is encrypted. Returns 0 when it's encrypted, 1 when it's not encrypted and -1 if the key does not exist
func (*Configuration) ReadConfiguration ¶
func (cfg *Configuration) ReadConfiguration() (err error)
ReadConfiguration searches for the configuration file in the defined search paths, reads and unmarshals the file
func (*Configuration) SaveEncryptionKey ¶
func (cfg *Configuration) SaveEncryptionKey(key string, encryptionKey []byte, encryptionNonce []byte) (err error)
func (*Configuration) SetAuditing ¶
func (cfg *Configuration) SetAuditing(au *audit.Audit)
func (*Configuration) SetBool ¶
func (cfg *Configuration) SetBool(key string, value bool) (err error)
SetBool sets an exisition configuration key to a new boolean value
func (*Configuration) SetFilename ¶
func (cfg *Configuration) SetFilename(filename string)
SetFilename defines the filename (without extension) to use
func (*Configuration) SetFiletype ¶
func (cfg *Configuration) SetFiletype(filetype ConfigFileType)
SetFiletype sets the file type of the configuration file. See ConfigFileType for value definitions
func (*Configuration) SetMonitorForChange ¶
func (cfg *Configuration) SetMonitorForChange(monitor bool)
SetMonitorForChange sets the monitoring flag. If set to true, the configuration file will be monitored for changes and reloaded when it changes
func (*Configuration) SetString ¶
func (cfg *Configuration) SetString(key string, value string) (err error)
SetString sets an existing configuration key to a new string value
func (Configuration) Write ¶
func (cfg Configuration) Write(filename string) (err error)
Write writes the configuration back to a file