fix: "cannot unmarshal !!str <no value> into bool" errors in state templates (#645)

Seems like we are affected by https://github.com/golang/go/issues/24963. That is, even though we internally use the template option `missingkey=zero`, in some cases it still prints `<no value>` instead of zero values, which has been confusing the state yaml parsing.

This fixes the issue by naively replacing all the remaining occurrences of `<no value>` in the rendered text, while printing debug logs to ease debugging in the future when there is unexpected side-effects introduced by this native method.

Fixes #553
This commit is contained in:
KUOKA Yusuke
2019-06-04 13:23:38 +09:00
committed by GitHub
parent 1d3f5f8a33
commit 65ee6a2124
4 changed files with 16 additions and 5 deletions
+2 -2
View File
@@ -13,9 +13,9 @@ func (c *Context) stringTemplate() *template.Template {
}
tmpl := template.New("stringTemplate").Funcs(funcMap)
if c.preRender {
tmpl.Option("missingkey=zero")
tmpl = tmpl.Option("missingkey=zero")
} else {
tmpl.Option("missingkey=error")
tmpl = tmpl.Option("missingkey=error")
}
return tmpl
}