Documentation ¶
Overview ¶
Package config provides a versatile configuration management system.
Package config ... (linter fix)
Package config ... (linter fix)
Index ¶
- Constants
- Variables
- func GetExpertiseLevel() uint8
- func JSONToMap(jsonData []byte) (map[string]interface{}, error)
- func MapToJSON(values map[string]interface{}) ([]byte, error)
- func Register(option *Option) error
- func SetConfigOption(key string, value interface{}) error
- func SetDataRoot(root *utils.DirStructure)
- func SetDefaultConfig(newValues map[string]interface{}) error
- func SetDefaultConfigOption(key string, value interface{}) error
- type BoolOption
- type IntOption
- type Option
- type StorageInterface
- func (s *StorageInterface) Delete(key string) error
- func (s *StorageInterface) Get(key string) (record.Record, error)
- func (s *StorageInterface) Put(r record.Record) error
- func (s *StorageInterface) Query(q *query.Query, local, internal bool) (*iterator.Iterator, error)
- func (s *StorageInterface) ReadOnly() bool
- type StringArrayOption
- type StringOption
Constants ¶
const ( ExpertiseLevelUser uint8 = 0 ExpertiseLevelExpert uint8 = 1 ExpertiseLevelDeveloper uint8 = 2 ExpertiseLevelNameUser = "user" ExpertiseLevelNameExpert = "expert" ExpertiseLevelNameDeveloper = "developer" )
Expertise Level constants
const ( OptTypeString uint8 = 1 OptTypeStringArray uint8 = 2 OptTypeInt uint8 = 3 OptTypeBool uint8 = 4 )
Various attribute options. Use ExternalOptType for extended types in the frontend.
const ( ReleaseLevelStable uint8 = 0 ReleaseLevelBeta uint8 = 1 ReleaseLevelExperimental uint8 = 2 ReleaseLevelNameStable = "stable" ReleaseLevelNameBeta = "beta" ReleaseLevelNameExperimental = "experimental" )
Release Level constants
Variables ¶
var ( // ErrInvalidJSON is returned by SetConfig and SetDefaultConfig if they receive invalid json. ErrInvalidJSON = errors.New("json string invalid") // ErrInvalidOptionType is returned by SetConfigOption and SetDefaultConfigOption if given an unsupported option type. ErrInvalidOptionType = errors.New("invalid option value type") )
var (
// Concurrent makes concurrency safe get methods available.
Concurrent = &safe{}
)
Functions ¶
func GetExpertiseLevel ¶ added in v0.4.0
func GetExpertiseLevel() uint8
GetExpertiseLevel returns the current active expertise level.
func MapToJSON ¶
MapToJSON expands a flattened map and returns it as json. The map is altered in the process.
func SetConfigOption ¶
SetConfigOption sets a single value in the (prioritized) user defined config.
func SetDataRoot ¶ added in v0.3.0
func SetDataRoot(root *utils.DirStructure)
SetDataRoot sets the data root from which the updates module derives its paths.
func SetDefaultConfig ¶
SetDefaultConfig sets the (fallback) default config.
func SetDefaultConfigOption ¶
SetDefaultConfigOption sets a single value in the (fallback) default config.
Types ¶
type BoolOption ¶
type BoolOption func() bool
BoolOption defines the returned function by GetAsBool.
func GetAsBool ¶
func GetAsBool(name string, fallback bool) BoolOption
GetAsBool returns a function that returns the wanted int with high performance.
type Option ¶
type Option struct { sync.Mutex Name string Key string // in path format: category/sub/key Description string OptType uint8 ExpertiseLevel uint8 ReleaseLevel uint8 RequiresRestart bool DefaultValue interface{} ExternalOptType string ValidationRegex string // contains filtered or unexported fields }
Option describes a configuration option.
type StorageInterface ¶ added in v0.3.0
type StorageInterface struct {
storage.InjectBase
}
StorageInterface provices a storage.Interface to the configuration manager.
func (*StorageInterface) Delete ¶ added in v0.3.0
func (s *StorageInterface) Delete(key string) error
Delete deletes a record from the database.
func (*StorageInterface) Get ¶ added in v0.3.0
func (s *StorageInterface) Get(key string) (record.Record, error)
Get returns a database record.
func (*StorageInterface) Put ¶ added in v0.3.0
func (s *StorageInterface) Put(r record.Record) error
Put stores a record in the database.
func (*StorageInterface) Query ¶ added in v0.3.0
Query returns a an iterator for the supplied query.
func (*StorageInterface) ReadOnly ¶ added in v0.3.0
func (s *StorageInterface) ReadOnly() bool
ReadOnly returns whether the database is read only.
type StringArrayOption ¶
type StringArrayOption func() []string
StringArrayOption defines the returned function by GetAsStringArray.
func GetAsStringArray ¶
func GetAsStringArray(name string, fallback []string) StringArrayOption
GetAsStringArray returns a function that returns the wanted string with high performance.
type StringOption ¶
type StringOption func() string
StringOption defines the returned function by GetAsString.
func GetAsString ¶
func GetAsString(name string, fallback string) StringOption
GetAsString returns a function that returns the wanted string with high performance.