Skip to content

Commit

Permalink
Emit a warning when env loading bug is being relied on
Browse files Browse the repository at this point in the history
  • Loading branch information
KnVerey committed Jul 28, 2022
1 parent c4b4a41 commit 2a3b645
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions api/kv/kv.go
Expand Up @@ -133,7 +133,6 @@ func (kvl *loader) keyValuesFromLines(content []byte) ([]types.Pair, error) {
}

// KeyValuesFromLine returns a kv with blank key if the line is empty or a comment.
// The value will be retrieved from the environment if necessary.
func (kvl *loader) keyValuesFromLine(line []byte, currentLine int) (types.Pair, error) {
kv := types.Pair{}

Expand Down Expand Up @@ -164,7 +163,12 @@ func (kvl *loader) keyValuesFromLine(line []byte, currentLine int) (types.Pair,
kv.Value = data[1]
} else {
// No value (no `=` in the line) is a signal to obtain the value
// from the environment.
// 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)
}
kv.Key = key
Expand Down

0 comments on commit 2a3b645

Please sign in to comment.