From 3514e89eb30f8ef5e3e743d8a66f9748169ab2b5 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Fri, 4 Dec 2020 21:54:24 -0800 Subject: [PATCH] support envs as well for new crawler sub-system (#11033) --- cmd/config/crawler/crawler.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/cmd/config/crawler/crawler.go b/cmd/config/crawler/crawler.go index cc1386b42..6f28b2fcc 100644 --- a/cmd/config/crawler/crawler.go +++ b/cmd/config/crawler/crawler.go @@ -21,12 +21,16 @@ import ( "time" "github.com/minio/minio/cmd/config" + "github.com/minio/minio/pkg/env" ) // Compression environment variables const ( Delay = "delay" MaxWait = "max_wait" + + EnvDelay = "MINIO_CRAWLER_DELAY" + EnvMaxWait = "MINIO_CRAWLER_MAX_WAIT" ) // Config represents the heal settings. @@ -54,13 +58,13 @@ var ( Help = config.HelpKVS{ config.HelpKV{ Key: Delay, - Description: `crawler delay multiplier, default 10`, + Description: `crawler delay multiplier, defaults to '10.0'`, Optional: true, Type: "float", }, config.HelpKV{ Key: MaxWait, - Description: `maximum wait time between operations, default 15s`, + Description: `maximum wait time between operations, defaults to '15s'`, Optional: true, Type: "duration", }, @@ -72,13 +76,11 @@ func LookupConfig(kvs config.KVS) (cfg Config, err error) { if err = config.CheckValidKeys(config.CrawlerSubSys, kvs, DefaultKVS); err != nil { return cfg, err } - delay := kvs.Get(Delay) - cfg.Delay, err = strconv.ParseFloat(delay, 64) + cfg.Delay, err = strconv.ParseFloat(env.Get(EnvDelay, kvs.Get(Delay)), 64) if err != nil { return cfg, err } - wait := kvs.Get(MaxWait) - cfg.MaxWait, err = time.ParseDuration(wait) + cfg.MaxWait, err = time.ParseDuration(env.Get(EnvMaxWait, kvs.Get(MaxWait))) if err != nil { return cfg, err }