Order all keys in config (#8541)

New changes

- return default values when sub-sys is
  not configured.
- state is hidden parameter now
- remove worm mode to be saved in config
This commit is contained in:
Harshavardhana
2019-11-20 15:10:24 -08:00
committed by GitHub
parent ca96560d56
commit 5ac4b517c9
51 changed files with 1436 additions and 642 deletions

View File

@@ -48,17 +48,31 @@ const (
// DefaultKVS - default KV settings for caching.
var (
DefaultKVS = config.KVS{
config.State: config.StateOff,
config.Comment: "This is a default cache configuration, only applicable in gateway setups",
Drives: "",
Exclude: "",
Expiry: DefaultExpiry,
Quota: DefaultQuota,
config.KV{
Key: config.State,
Value: config.StateOff,
},
config.KV{
Key: Drives,
Value: "",
},
config.KV{
Key: Exclude,
Value: "",
},
config.KV{
Key: Expiry,
Value: DefaultExpiry,
},
config.KV{
Key: Quota,
Value: DefaultQuota,
},
}
)
const (
cacheDelimiter = ";"
cacheDelimiter = ","
)
// LookupConfig - extracts cache configuration provided by environment
@@ -92,14 +106,20 @@ func LookupConfig(kvs config.KVS) (Config, error) {
cfg.Drives, err = parseCacheDrives(strings.Split(drives, cacheDelimiter))
if err != nil {
return cfg, err
cfg.Drives, err = parseCacheDrives(strings.Split(drives, cacheDelimiterLegacy))
if err != nil {
return cfg, err
}
}
cfg.Enabled = true
if excludes := env.Get(EnvCacheExclude, kvs.Get(Exclude)); excludes != "" {
cfg.Exclude, err = parseCacheExcludes(strings.Split(excludes, cacheDelimiter))
if err != nil {
return cfg, err
cfg.Exclude, err = parseCacheExcludes(strings.Split(excludes, cacheDelimiterLegacy))
if err != nil {
return cfg, err
}
}
}