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
+5 -9
View File
@@ -4,6 +4,7 @@ import (
"fmt"
"github.com/imdario/mergo"
"github.com/roboll/helmfile/environment"
"github.com/roboll/helmfile/pkg/maputil"
"github.com/roboll/helmfile/tmpl"
"gopkg.in/yaml.v2"
"path/filepath"
@@ -53,21 +54,16 @@ func (ld *EnvironmentValuesLoader) LoadEnvironmentValues(missingFileHandler *str
}
}
case map[interface{}]interface{}:
m := map[string]interface{}{}
for k, v := range typedValue {
switch typedKey := k.(type) {
case string:
m[typedKey] = v
default:
return nil, fmt.Errorf("unexpected type of key in inline environment values %v: expected string, got %T", typedValue, typedKey)
}
m, err := maputil.CastKeysToStrings(typedValue)
if err != nil {
return nil, err
}
if err := mergo.Merge(&envVals, &m, mergo.WithOverride); err != nil {
return nil, fmt.Errorf("failed to merge %v: %v", typedValue, err)
}
continue
default:
return nil, fmt.Errorf("unexpected type of values entry: %T", typedValue)
return nil, fmt.Errorf("unexpected type of value: value=%v, type=%T", typedValue, typedValue)
}
}
+1 -1
View File
@@ -1319,7 +1319,7 @@ func (st *HelmState) generateTemporaryValuesFiles(values []interface{}, missingF
}
generatedFiles = append(generatedFiles, valfile.Name())
default:
return nil, fmt.Errorf("unexpected type of values entry: %T", typedValue)
return nil, fmt.Errorf("unexpected type of value: value=%v, type=%T", typedValue, typedValue)
}
}
return generatedFiles, nil