mirror of
https://github.com/minio/minio.git
synced 2025-05-23 02:21:51 -04:00
make sure to set relevant config entries correctly (#17485)
Bonus: also allow skipping keys properly.
This commit is contained in:
parent
82ce78a17c
commit
74759b05a5
@ -176,14 +176,11 @@ func (sCfg *Config) UnmarshalJSON(data []byte) error {
|
|||||||
|
|
||||||
// LookupConfig - lookup api config and override with valid environment settings if any.
|
// LookupConfig - lookup api config and override with valid environment settings if any.
|
||||||
func LookupConfig(kvs config.KVS) (cfg Config, err error) {
|
func LookupConfig(kvs config.KVS) (cfg Config, err error) {
|
||||||
// remove this since we have removed this already.
|
deprecatedKeys := []string{
|
||||||
kvs.Delete(apiReadyDeadline)
|
apiReadyDeadline,
|
||||||
kvs.Delete("extend_list_cache_life")
|
"extend_list_cache_life",
|
||||||
kvs.Delete(apiReplicationWorkers)
|
apiReplicationWorkers,
|
||||||
kvs.Delete(apiReplicationFailedWorkers)
|
apiReplicationFailedWorkers,
|
||||||
|
|
||||||
if err = config.CheckValidKeys(config.APISubSys, kvs, DefaultKVS); err != nil {
|
|
||||||
return cfg, err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
disableODirect := env.Get(EnvAPIDisableODirect, kvs.Get(apiDisableODirect)) == config.EnableOn
|
disableODirect := env.Get(EnvAPIDisableODirect, kvs.Get(apiDisableODirect)) == config.EnableOn
|
||||||
@ -196,6 +193,16 @@ func LookupConfig(kvs config.KVS) (cfg Config, err error) {
|
|||||||
RootAccess: rootAccess,
|
RootAccess: rootAccess,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
corsAllowOrigin := strings.Split(env.Get(EnvAPICorsAllowOrigin, kvs.Get(apiCorsAllowOrigin)), ",")
|
||||||
|
if len(corsAllowOrigin) == 0 {
|
||||||
|
corsAllowOrigin = []string{"*"} // defaults to '*'
|
||||||
|
}
|
||||||
|
cfg.CorsAllowOrigin = corsAllowOrigin
|
||||||
|
|
||||||
|
if err = config.CheckValidKeys(config.APISubSys, kvs, DefaultKVS, deprecatedKeys...); err != nil {
|
||||||
|
return cfg, err
|
||||||
|
}
|
||||||
|
|
||||||
// Check environment variables parameters
|
// Check environment variables parameters
|
||||||
requestsMax, err := strconv.Atoi(env.Get(EnvAPIRequestsMax, kvs.GetWithDefault(apiRequestsMax, DefaultKVS)))
|
requestsMax, err := strconv.Atoi(env.Get(EnvAPIRequestsMax, kvs.GetWithDefault(apiRequestsMax, DefaultKVS)))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -219,12 +226,6 @@ func LookupConfig(kvs config.KVS) (cfg Config, err error) {
|
|||||||
}
|
}
|
||||||
cfg.ClusterDeadline = clusterDeadline
|
cfg.ClusterDeadline = clusterDeadline
|
||||||
|
|
||||||
corsAllowOrigin := strings.Split(env.Get(EnvAPICorsAllowOrigin, kvs.Get(apiCorsAllowOrigin)), ",")
|
|
||||||
if len(corsAllowOrigin) == 0 {
|
|
||||||
corsAllowOrigin = []string{"*"} // defaults to '*'
|
|
||||||
}
|
|
||||||
cfg.CorsAllowOrigin = corsAllowOrigin
|
|
||||||
|
|
||||||
remoteTransportDeadline, err := time.ParseDuration(env.Get(EnvAPIRemoteTransportDeadline, kvs.GetWithDefault(apiRemoteTransportDeadline, DefaultKVS)))
|
remoteTransportDeadline, err := time.ParseDuration(env.Get(EnvAPIRemoteTransportDeadline, kvs.GetWithDefault(apiRemoteTransportDeadline, DefaultKVS)))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return cfg, err
|
return cfg, err
|
||||||
|
@ -598,7 +598,7 @@ func LookupSite(siteKV KVS, regionKV KVS) (s Site, err error) {
|
|||||||
|
|
||||||
// CheckValidKeys - checks if inputs KVS has the necessary keys,
|
// CheckValidKeys - checks if inputs KVS has the necessary keys,
|
||||||
// returns error if it find extra or superflous keys.
|
// returns error if it find extra or superflous keys.
|
||||||
func CheckValidKeys(subSys string, kv KVS, validKVS KVS) error {
|
func CheckValidKeys(subSys string, kv KVS, validKVS KVS, deprecatedKeys ...string) error {
|
||||||
nkv := KVS{}
|
nkv := KVS{}
|
||||||
for _, kv := range kv {
|
for _, kv := range kv {
|
||||||
// Comment is a valid key, its also fully optional
|
// Comment is a valid key, its also fully optional
|
||||||
@ -607,6 +607,16 @@ func CheckValidKeys(subSys string, kv KVS, validKVS KVS) error {
|
|||||||
if kv.Key == Comment {
|
if kv.Key == Comment {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
var skip bool
|
||||||
|
for _, deprecatedKey := range deprecatedKeys {
|
||||||
|
if kv.Key == deprecatedKey {
|
||||||
|
skip = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if skip {
|
||||||
|
continue
|
||||||
|
}
|
||||||
if _, ok := validKVS.Lookup(kv.Key); !ok {
|
if _, ok := validKVS.Lookup(kv.Key); !ok {
|
||||||
nkv = append(nkv, kv)
|
nkv = append(nkv, kv)
|
||||||
}
|
}
|
||||||
|
@ -281,9 +281,11 @@ func DefaultParityBlocks(drive int) int {
|
|||||||
func LookupConfig(kvs config.KVS, setDriveCount int) (cfg Config, err error) {
|
func LookupConfig(kvs config.KVS, setDriveCount int) (cfg Config, err error) {
|
||||||
cfg = Config{}
|
cfg = Config{}
|
||||||
|
|
||||||
kvs.Delete("dma")
|
deprecatedKeys := []string{
|
||||||
|
"dma",
|
||||||
|
}
|
||||||
|
|
||||||
if err = config.CheckValidKeys(config.StorageClassSubSys, kvs, DefaultKVS); err != nil {
|
if err = config.CheckValidKeys(config.StorageClassSubSys, kvs, DefaultKVS, deprecatedKeys...); err != nil {
|
||||||
return Config{}, err
|
return Config{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user