Do not fail due to missing env in base helmfile (#1009)

When helmfile is run with `--environment NAME` and there was a base hemlfile that misses `environments`, helmfile had been trying to load env values for NAME and failing.

A base helmfile is allowed to reference values from within itself, but that's optional. In other words, a base helmfile that misses the env is okay as long as it doesn't self-reference env values.

So, this change allows missing env and env values while loading base helmfile. After loading, a base helmfile can fail due to referencing missing env values, but that's okay.

Fixes #1008
This commit is contained in:
KUOKA Yusuke
2019-12-01 11:37:56 +09:00
committed by GitHub
parent 27c098c17c
commit 07c42474cc
3 changed files with 49 additions and 12 deletions
+36
View File
@@ -177,6 +177,42 @@ releases:
}
}
func TestVisitDesiredStatesWithReleasesFiltered_Issue1008_MissingNonDefaultEnvInBase(t *testing.T) {
files := map[string]string{
"/path/to/base.yaml": `
helmDefaults:
wait: true
`,
"/path/to/helmfile.yaml": `
bases:
- base.yaml
environments:
test:
releases:
- name: zipkin
chart: stable/zipkin
`,
}
fs := testhelper.NewTestFs(files)
app := &App{
KubeContext: "default",
Logger: helmexec.NewLogger(os.Stderr, "debug"),
Namespace: "",
Env: "test",
}
app = injectFs(app, fs)
noop := func(st *state.HelmState, helm helmexec.Interface) []error {
return []error{}
}
err := app.VisitDesiredStatesWithReleasesFiltered(
"helmfile.yaml", noop,
)
if err != nil {
t.Errorf("unexpected error: %v", err)
}
}
func TestVisitDesiredStatesWithReleasesFiltered_MissingEnvValuesFileHandler(t *testing.T) {
testcases := []struct {
name string