Fix panic related to env values from files and sprig dict funcs (#625)

* fix: 0.68.0: go panic w/ multiple bases/layers

Fixes #623

* fix: 0.64.1+: getOrNil/hasKey fails on Environment.Values with nested maps

Fixes #624
This commit is contained in:
KUOKA Yusuke
2019-05-30 15:41:00 +09:00
committed by GitHub
parent 591086dac9
commit b3f4586ed8
6 changed files with 200 additions and 14 deletions
+8 -3
View File
@@ -1,8 +1,9 @@
package environment
import (
"encoding/json"
"github.com/imdario/mergo"
"github.com/roboll/helmfile/pkg/maputil"
"gopkg.in/yaml.v2"
)
type Environment struct {
@@ -13,12 +14,16 @@ type Environment struct {
var EmptyEnvironment Environment
func (e Environment) DeepCopy() Environment {
bytes, err := json.Marshal(e.Values)
bytes, err := yaml.Marshal(e.Values)
if err != nil {
panic(err)
}
var values map[string]interface{}
if err := json.Unmarshal(bytes, &values); err != nil {
if err := yaml.Unmarshal(bytes, &values); err != nil {
panic(err)
}
values, err = maputil.CastKeysToStrings(values)
if err != nil {
panic(err)
}
return Environment{