Merge pull request #30 from safing/fix/config-persistence

Fix config persistence
This commit is contained in:
Daniel 2020-04-14 20:26:05 +02:00 committed by GitHub
commit 481771efea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 1 deletions

View file

@ -47,7 +47,7 @@ func saveConfig() error {
for key, option := range options {
option.Lock()
if option.activeValue != nil {
activeValues[key] = option.activeValue
activeValues[key] = option.activeValue.getData(option)
}
option.Unlock()
}

View file

@ -13,6 +13,21 @@ type valueCache struct {
boolVal bool
}
func (vc *valueCache) getData(opt *Option) interface{} {
switch opt.OptType {
case OptTypeBool:
return vc.boolVal
case OptTypeInt:
return vc.intVal
case OptTypeString:
return vc.stringVal
case OptTypeStringArray:
return vc.stringArrayVal
default:
return nil
}
}
func validateValue(option *Option, value interface{}) (*valueCache, error) { //nolint:gocyclo
switch v := value.(type) {
case string: