From d4f968f51e39426896ea45af57116b39e62be9d7 Mon Sep 17 00:00:00 2001 From: Jesse Simpson Date: Fri, 15 Aug 2025 09:12:35 -0400 Subject: [PATCH] fix: undo changes to chart v2 Signed-off-by: Jesse Simpson --- pkg/chart/v2/util/coalesce.go | 2 +- pkg/chart/v2/util/coalesce_test.go | 66 ------------------------------ pkg/chart/v2/util/values.go | 14 ------- 3 files changed, 1 insertion(+), 81 deletions(-) diff --git a/pkg/chart/v2/util/coalesce.go b/pkg/chart/v2/util/coalesce.go index 307603bae..a3e0f5ae8 100644 --- a/pkg/chart/v2/util/coalesce.go +++ b/pkg/chart/v2/util/coalesce.go @@ -300,7 +300,7 @@ func coalesceTablesFullKey(printf printFn, dst, src map[string]interface{}, pref } else { printf("warning: cannot overwrite table with non table for %s (%v)", fullkey, val) } - } else if istable(dv) && val != nil && isNonEmptyString(val) && isNonEmptyTable(dv) { + } else if istable(dv) && val != nil { printf("warning: destination for %s is a table. Ignoring non-table value (%v)", fullkey, val) } } diff --git a/pkg/chart/v2/util/coalesce_test.go b/pkg/chart/v2/util/coalesce_test.go index 9559ca81d..e2c45a435 100644 --- a/pkg/chart/v2/util/coalesce_test.go +++ b/pkg/chart/v2/util/coalesce_test.go @@ -717,72 +717,6 @@ func TestCoalesceValuesWarnings(t *testing.T) { } -func TestCoalesceValuesWarningsWithEmptyDefaultMaps(t *testing.T) { - - c := withDeps(&chart.Chart{ - Metadata: &chart.Metadata{Name: "level1"}, - Values: map[string]interface{}{ - "something": map[string]interface{}{ - "somethingElse": []interface{}{}, - }, - }, - }) - - vals := map[string]interface{}{ - "something": map[string]interface{}{ - "somethingElse": map[string]interface{}{}, - }, - } - - warnings := make([]string, 0) - printf := func(format string, v ...interface{}) { - t.Logf(format, v...) - warnings = append(warnings, fmt.Sprintf(format, v...)) - } - - _, err := coalesce(printf, c, vals, "", false) - if err != nil { - t.Fatal(err) - } - - t.Logf("vals: %v", vals) - assert.NotContains(t, warnings, "warning: destination for level1.something.somethingElse is a table. Ignoring non-table value ([])") -} - -func TestCoalesceValuesWarningsWithEmptyStringDefault(t *testing.T) { - - c := withDeps(&chart.Chart{ - Metadata: &chart.Metadata{Name: "level1"}, - Values: map[string]interface{}{ - "auth": map[string]interface{}{ - "existingSecret": "", - }, - }, - }) - - vals := map[string]interface{}{ - "auth": map[string]interface{}{ - "existingSecret": map[string]interface{}{ - "name": "secretName", - }, - }, - } - - warnings := make([]string, 0) - printf := func(format string, v ...interface{}) { - t.Logf(format, v...) - warnings = append(warnings, fmt.Sprintf(format, v...)) - } - - _, err := coalesce(printf, c, vals, "", false) - if err != nil { - t.Fatal(err) - } - - t.Logf("vals: %v", vals) - assert.NotContains(t, warnings, "warning: destination for level1.auth.existingSecret is a table. Ignoring non-table value ()") -} - func TestConcatPrefix(t *testing.T) { assert.Equal(t, "b", concatPrefix("", "b")) assert.Equal(t, "a.b", concatPrefix("a", "b")) diff --git a/pkg/chart/v2/util/values.go b/pkg/chart/v2/util/values.go index 5549580ce..6850e8b9b 100644 --- a/pkg/chart/v2/util/values.go +++ b/pkg/chart/v2/util/values.go @@ -179,20 +179,6 @@ func istable(v interface{}) bool { return ok } -func isNonEmptyTable(val interface{}) bool { - table, ok := val.(map[string]interface{}) - if !ok { - return false - } - - return len(table) > 0 -} - -func isNonEmptyString(val interface{}) bool { - valueString := fmt.Sprintf("%v", val) - return valueString != "" -} - // PathValue takes a path that traverses a YAML structure and returns the value at the end of that path. // The path starts at the root of the YAML structure and is comprised of YAML keys separated by periods. // Given the following YAML data the value at path "chapter.one.title" is "Loomings".