|
|
@ -399,6 +399,12 @@ func LookupRegion(kv KVS) (string, error) { |
|
|
|
func CheckValidKeys(subSys string, kv KVS, validKVS KVS) error { |
|
|
|
func CheckValidKeys(subSys string, kv KVS, validKVS KVS) error { |
|
|
|
nkv := KVS{} |
|
|
|
nkv := KVS{} |
|
|
|
for _, kv := range kv { |
|
|
|
for _, kv := range kv { |
|
|
|
|
|
|
|
// Comment is a valid key, its also fully optional
|
|
|
|
|
|
|
|
// ignore it since it is a valid key for all
|
|
|
|
|
|
|
|
// sub-systems.
|
|
|
|
|
|
|
|
if kv.Key == Comment { |
|
|
|
|
|
|
|
continue |
|
|
|
|
|
|
|
} |
|
|
|
if _, ok := validKVS.Lookup(kv.Key); !ok { |
|
|
|
if _, ok := validKVS.Lookup(kv.Key); !ok { |
|
|
|
nkv = append(nkv, kv) |
|
|
|
nkv = append(nkv, kv) |
|
|
|
} |
|
|
|
} |
|
|
@ -557,23 +563,19 @@ func (c Config) SetKVS(s string, defaultKVS map[string]KVS) error { |
|
|
|
continue |
|
|
|
continue |
|
|
|
} |
|
|
|
} |
|
|
|
if len(kv) == 1 && prevK != "" { |
|
|
|
if len(kv) == 1 && prevK != "" { |
|
|
|
kvs = append(kvs, KV{ |
|
|
|
value := strings.Join([]string{ |
|
|
|
Key: prevK, |
|
|
|
kvs.Get(prevK), |
|
|
|
Value: strings.Join([]string{ |
|
|
|
madmin.SanitizeValue(kv[0]), |
|
|
|
kvs.Get(prevK), |
|
|
|
}, KvSpaceSeparator) |
|
|
|
madmin.SanitizeValue(kv[0]), |
|
|
|
kvs.Set(prevK, value) |
|
|
|
}, KvSpaceSeparator), |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
continue |
|
|
|
continue |
|
|
|
} |
|
|
|
} |
|
|
|
if len(kv) == 1 { |
|
|
|
if len(kv) == 2 { |
|
|
|
return Errorf(SafeModeKind, "key '%s', cannot have empty value", kv[0]) |
|
|
|
prevK = kv[0] |
|
|
|
|
|
|
|
kvs.Set(prevK, madmin.SanitizeValue(kv[1])) |
|
|
|
|
|
|
|
continue |
|
|
|
} |
|
|
|
} |
|
|
|
prevK = kv[0] |
|
|
|
return Errorf(SafeModeKind, "key '%s', cannot have empty value", kv[0]) |
|
|
|
kvs = append(kvs, KV{ |
|
|
|
|
|
|
|
Key: kv[0], |
|
|
|
|
|
|
|
Value: madmin.SanitizeValue(kv[1]), |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
tgt := Default |
|
|
|
tgt := Default |
|
|
@ -587,25 +589,27 @@ func (c Config) SetKVS(s string, defaultKVS map[string]KVS) error { |
|
|
|
_, defaultOk := defaultKVS[subSys].Lookup(Enable) |
|
|
|
_, defaultOk := defaultKVS[subSys].Lookup(Enable) |
|
|
|
if !ok && defaultOk { |
|
|
|
if !ok && defaultOk { |
|
|
|
// implicit state "on" if not specified.
|
|
|
|
// implicit state "on" if not specified.
|
|
|
|
kvs = append(kvs, KV{ |
|
|
|
kvs.Set(Enable, EnableOn) |
|
|
|
Key: Enable, |
|
|
|
|
|
|
|
Value: EnableOn, |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
currKVS := c[subSys][tgt] |
|
|
|
currKVS, ok := c[subSys][tgt] |
|
|
|
|
|
|
|
if !ok { |
|
|
|
|
|
|
|
currKVS = defaultKVS[subSys] |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for _, kv := range kvs { |
|
|
|
for _, kv := range kvs { |
|
|
|
|
|
|
|
if kv.Key == Comment { |
|
|
|
|
|
|
|
// Skip comment and add it later.
|
|
|
|
|
|
|
|
continue |
|
|
|
|
|
|
|
} |
|
|
|
currKVS.Set(kv.Key, kv.Value) |
|
|
|
currKVS.Set(kv.Key, kv.Value) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for _, defaultKV := range defaultKVS[subSys] { |
|
|
|
v, ok := kvs.Lookup(Comment) |
|
|
|
_, ok := c[subSys][tgt].Lookup(defaultKV.Key) |
|
|
|
if ok { |
|
|
|
if !ok { |
|
|
|
currKVS.Set(Comment, v) |
|
|
|
currKVS.Set(defaultKV.Key, defaultKV.Value) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
copy(c[subSys][tgt], currKVS) |
|
|
|
c[subSys][tgt] = currKVS |
|
|
|
return nil |
|
|
|
return nil |
|
|
|
} |
|
|
|
} |
|
|
|