From 3e8a9d4436473f6f624e9568754dde9f117caf58 Mon Sep 17 00:00:00 2001 From: Sumanth Lingappa <42572246+sumanth-lingappa@users.noreply.github.com> Date: Thu, 7 Jul 2022 09:32:42 +0530 Subject: [PATCH 1/2] boolean value passed in ENV taken care --- helper/schema/schema.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/helper/schema/schema.go b/helper/schema/schema.go index 7cbd5858917..81368757757 100644 --- a/helper/schema/schema.go +++ b/helper/schema/schema.go @@ -409,6 +409,16 @@ func EnvDefaultFunc(k string, dv interface{}) SchemaDefaultFunc { return dv, nil } + return func() (interface{}, error) { + v := os.Getenv(k) + if v == "" { + return dv, nil + } + if v == "true" || v == "false" { + return strconv.ParseBool(v) + } + return v, nil + } } // MultiEnvDefaultFunc is a helper function that returns the value of the first From 57f14689492ae73410782067b918e793cab88020 Mon Sep 17 00:00:00 2001 From: Sumanth Lingappa <42572246+sumanth-lingappa@users.noreply.github.com> Date: Thu, 7 Jul 2022 09:44:03 +0530 Subject: [PATCH 2/2] deleted earlier missed code --- helper/schema/schema.go | 7 ------- 1 file changed, 7 deletions(-) diff --git a/helper/schema/schema.go b/helper/schema/schema.go index 81368757757..dff84df6f5a 100644 --- a/helper/schema/schema.go +++ b/helper/schema/schema.go @@ -402,13 +402,6 @@ type SchemaDefaultFunc func() (interface{}, error) // given environment variable, if one exists, or the default value // otherwise. func EnvDefaultFunc(k string, dv interface{}) SchemaDefaultFunc { - return func() (interface{}, error) { - if v := os.Getenv(k); v != "" { - return v, nil - } - - return dv, nil - } return func() (interface{}, error) { v := os.Getenv(k) if v == "" {