fix: sprig dict funcs are failing on dicts nested under arrays (#646)

Fixes #643
This commit is contained in:
KUOKA Yusuke
2019-06-04 13:47:05 +09:00
committed by GitHub
parent 65ee6a2124
commit 2d2b3e486f
2 changed files with 39 additions and 21 deletions
+8 -1
View File
@@ -1522,6 +1522,8 @@ releases:
{stateExternal, `{{ if (keys .Environment.Values | has "foo") }}{{ .Environment.Values.foo }}{{ end }}`, `FOO`},
// See https://github.com/roboll/helmfile/issues/624
{stateExternal, `{{ if (keys .Environment.Values | has "bar") }}{{ if (keys .Environment.Values.bar | has "baz") }}{{ .Environment.Values.bar.baz }}{{ end }}{{ end }}`, `BAZ`},
// See https://github.com/roboll/helmfile/issues/643
{stateExternal, `{{ range $service := .Environment.Values.services }}{{ $service.name }}{{ if hasKey $service "something" }}{{ $service.something }}{{ end }}{{ end }}`, `xyfalse`},
}
for i := range testcases {
tc := testcases[i]
@@ -1530,7 +1532,12 @@ releases:
testFs := state.NewTestFs(map[string]string{
statePath: stateContent,
"/path/to/1.yaml": `foo: FOO`,
"/path/to/2.yaml": `bar: { "baz": "BAZ" }`,
"/path/to/2.yaml": `bar: { "baz": "BAZ" }
services:
- name: "x"
- name: "y"
something: false
`,
})
app := &App{
readFile: testFs.ReadFile,