mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-11 17:12:51 +00:00
Remove Functionality that Pulls Env Variables from Empty Keys
This commit is contained in:
11
api/kv/kv.go
11
api/kv/kv.go
@@ -7,7 +7,6 @@ import (
|
|||||||
"bufio"
|
"bufio"
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
|
||||||
"strings"
|
"strings"
|
||||||
"unicode"
|
"unicode"
|
||||||
"unicode/utf8"
|
"unicode/utf8"
|
||||||
@@ -162,14 +161,8 @@ func (kvl *loader) keyValuesFromLine(line []byte, currentLine int) (types.Pair,
|
|||||||
if len(data) == 2 {
|
if len(data) == 2 {
|
||||||
kv.Value = data[1]
|
kv.Value = data[1]
|
||||||
} else {
|
} else {
|
||||||
// No value (no `=` in the line) is a signal to obtain the value
|
// If there is value (no `=` in the line), we set value to an empty string
|
||||||
// from the environment. This behaviour was accidentally imported from kubectl code, and
|
kv.Value = ""
|
||||||
// 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)
|
|
||||||
}
|
}
|
||||||
kv.Key = key
|
kv.Key = key
|
||||||
return kv, nil
|
return kv, nil
|
||||||
|
|||||||
@@ -50,6 +50,26 @@ func TestKeyValuesFromLines(t *testing.T) {
|
|||||||
},
|
},
|
||||||
expectedErr: false,
|
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
|
// TODO: add negative testcases
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user