mirror of
https://github.com/helm/helm.git
synced 2026-04-15 21:59:50 -04:00
Updated per feedback from gjenkins8
Signed-off-by: Matt Farina <matt.farina@suse.com>
This commit is contained in:
parent
0a5148faff
commit
e8a748d300
2 changed files with 17 additions and 10 deletions
|
|
@ -43,16 +43,10 @@ func concatPrefix(a, b string) string {
|
|||
// - A chart has access to all of the variables for it, as well as all of
|
||||
// the values destined for its dependencies.
|
||||
func CoalesceValues(chrt *chart.Chart, vals map[string]interface{}) (Values, error) {
|
||||
v, err := copystructure.Copy(vals)
|
||||
valsCopy, err := copyValues(vals)
|
||||
if err != nil {
|
||||
return vals, err
|
||||
}
|
||||
|
||||
valsCopy := v.(map[string]interface{})
|
||||
// if we have an empty map, make sure it is initialized
|
||||
if valsCopy == nil {
|
||||
valsCopy = make(map[string]interface{})
|
||||
}
|
||||
return coalesce(log.Printf, chrt, valsCopy, "", false)
|
||||
}
|
||||
|
||||
|
|
@ -71,6 +65,14 @@ func CoalesceValues(chrt *chart.Chart, vals map[string]interface{}) (Values, err
|
|||
// logic need to retain them for when Coalescing will happen again later in the
|
||||
// business logic.
|
||||
func MergeValues(chrt *chart.Chart, vals map[string]interface{}) (Values, error) {
|
||||
valsCopy, err := copyValues(vals)
|
||||
if err != nil {
|
||||
return vals, err
|
||||
}
|
||||
return coalesce(log.Printf, chrt, valsCopy, "", true)
|
||||
}
|
||||
|
||||
func copyValues(vals map[string]interface{}) (Values, error) {
|
||||
v, err := copystructure.Copy(vals)
|
||||
if err != nil {
|
||||
return vals, err
|
||||
|
|
@ -81,14 +83,19 @@ func MergeValues(chrt *chart.Chart, vals map[string]interface{}) (Values, error)
|
|||
if valsCopy == nil {
|
||||
valsCopy = make(map[string]interface{})
|
||||
}
|
||||
return coalesce(log.Printf, chrt, valsCopy, "", true)
|
||||
|
||||
return valsCopy, nil
|
||||
}
|
||||
|
||||
type printFn func(format string, v ...interface{})
|
||||
|
||||
// coalesce coalesces the dest values and the chart values, giving priority to the dest values.
|
||||
//
|
||||
// This is a helper function for CoalesceValues.
|
||||
// This is a helper function for CoalesceValues and MergeValues.
|
||||
//
|
||||
// Note, the merge argument specifies whether this is being used by MergeValues
|
||||
// or CoalesceValues. Coalescing removes null values and their keys in some
|
||||
// situations while merging keeps the null values.
|
||||
func coalesce(printf printFn, ch *chart.Chart, dest map[string]interface{}, prefix string, merge bool) (map[string]interface{}, error) {
|
||||
coalesceValues(printf, ch, dest, prefix, merge)
|
||||
return coalesceDeps(printf, ch, dest, prefix, merge)
|
||||
|
|
|
|||
|
|
@ -321,7 +321,7 @@ func TestProcessDependencyImportValuesForEnabledCharts(t *testing.T) {
|
|||
c := loadChart(t, "testdata/import-values-from-enabled-subchart/parent-chart")
|
||||
nameOverride := "parent-chart-prod"
|
||||
|
||||
if err := processDependencyImportValues(c, false); err != nil {
|
||||
if err := processDependencyImportValues(c, true); err != nil {
|
||||
t.Fatalf("processing import values dependencies %v", err)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue