From b7746d09e41d4d3cf024f483177101f166f34674 Mon Sep 17 00:00:00 2001 From: Cailyn Edwards Date: Wed, 4 Jan 2023 16:28:58 -0500 Subject: [PATCH] Remove Functionality that Pulls Env Variables from Empty Keys --- api/kv/kv.go | 11 ++--------- api/kv/kv_test.go | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/api/kv/kv.go b/api/kv/kv.go index 617b5aeee..ddfe68069 100644 --- a/api/kv/kv.go +++ b/api/kv/kv.go @@ -7,7 +7,6 @@ import ( "bufio" "bytes" "fmt" - "os" "strings" "unicode" "unicode/utf8" @@ -162,14 +161,8 @@ func (kvl *loader) keyValuesFromLine(line []byte, currentLine int) (types.Pair, if len(data) == 2 { kv.Value = data[1] } else { - // No value (no `=` in the line) is a signal to obtain the value - // from the environment. This behaviour was accidentally imported from kubectl code, and - // will be removed in the next major release of Kustomize. - _, _ = fmt.Fprintln(os.Stderr, "WARNING: "+ - "This Kustomization is relying on a bug that loads values from the environment "+ - "when they are omitted from an env file. "+ - "This behaviour will be removed in the next major release of Kustomize.") - kv.Value = os.Getenv(key) + // If there is value (no `=` in the line), we set value to an empty string + kv.Value = "" } kv.Key = key return kv, nil diff --git a/api/kv/kv_test.go b/api/kv/kv_test.go index 5f9631c65..f37be9690 100644 --- a/api/kv/kv_test.go +++ b/api/kv/kv_test.go @@ -50,6 +50,26 @@ func TestKeyValuesFromLines(t *testing.T) { }, expectedErr: false, }, + { + desc: "no value with equals", + content: ` + k1= + `, + expectedPairs: []types.Pair{ + {Key: "k1", Value: ""}, + }, + expectedErr: false, + }, + { + desc: "no value without equals", + content: ` + k1 + `, + expectedPairs: []types.Pair{ + {Key: "k1", Value: ""}, + }, + expectedErr: false, + }, // TODO: add negative testcases }