From cf7613ba6b3008464014a88fc4b8dc2cc93bf914 Mon Sep 17 00:00:00 2001 From: Matt Farina Date: Tue, 20 May 2025 15:46:20 -0400 Subject: [PATCH] Reverting fix "renders int as float" This reverts #13533 This change has caused issues with numerous charts around things unrelated to toml. This is because of functions like typeIs/typeOf being used and acted upon. The change caused a significant regression. Note: This kind of change can be put into v3 charts, that are in active development, without causing a regression. Closes #30880 Signed-off-by: Matt Farina --- pkg/chart/v2/loader/load.go | 6 +----- pkg/chart/v2/util/dependencies_test.go | 19 ------------------- pkg/chart/v2/util/values.go | 6 +----- pkg/cmd/template_test.go | 12 ------------ pkg/cmd/testdata/output/issue-totoml.txt | 8 -------- .../testcharts/issue-totoml/Chart.yaml | 3 --- .../issue-totoml/templates/configmap.yaml | 6 ------ .../testcharts/issue-totoml/values.yaml | 2 -- 8 files changed, 2 insertions(+), 60 deletions(-) delete mode 100644 pkg/cmd/testdata/output/issue-totoml.txt delete mode 100644 pkg/cmd/testdata/testcharts/issue-totoml/Chart.yaml delete mode 100644 pkg/cmd/testdata/testcharts/issue-totoml/templates/configmap.yaml delete mode 100644 pkg/cmd/testdata/testcharts/issue-totoml/values.yaml diff --git a/pkg/chart/v2/loader/load.go b/pkg/chart/v2/loader/load.go index f0905e508..75c73e959 100644 --- a/pkg/chart/v2/loader/load.go +++ b/pkg/chart/v2/loader/load.go @@ -19,7 +19,6 @@ package loader import ( "bufio" "bytes" - "encoding/json" "errors" "fmt" "io" @@ -224,10 +223,7 @@ func LoadValues(data io.Reader) (map[string]interface{}, error) { } return nil, fmt.Errorf("error reading yaml document: %w", err) } - if err := yaml.Unmarshal(raw, ¤tMap, func(d *json.Decoder) *json.Decoder { - d.UseNumber() - return d - }); err != nil { + if err := yaml.Unmarshal(raw, ¤tMap); err != nil { return nil, fmt.Errorf("cannot unmarshal yaml document: %w", err) } values = MergeMaps(values, currentMap) diff --git a/pkg/chart/v2/util/dependencies_test.go b/pkg/chart/v2/util/dependencies_test.go index 07b2441e2..5947eac69 100644 --- a/pkg/chart/v2/util/dependencies_test.go +++ b/pkg/chart/v2/util/dependencies_test.go @@ -15,7 +15,6 @@ limitations under the License. package util import ( - "encoding/json" "os" "path/filepath" "sort" @@ -238,20 +237,6 @@ func TestProcessDependencyImportValues(t *testing.T) { if b := strconv.FormatBool(pv); b != vv { t.Errorf("failed to match imported bool value %v with expected %v for key %q", b, vv, kk) } - case json.Number: - if fv, err := pv.Float64(); err == nil { - if sfv := strconv.FormatFloat(fv, 'f', -1, 64); sfv != vv { - t.Errorf("failed to match imported float value %v with expected %v for key %q", sfv, vv, kk) - } - } - if iv, err := pv.Int64(); err == nil { - if siv := strconv.FormatInt(iv, 10); siv != vv { - t.Errorf("failed to match imported int value %v with expected %v for key %q", siv, vv, kk) - } - } - if pv.String() != vv { - t.Errorf("failed to match imported string value %q with expected %q for key %q", pv, vv, kk) - } default: if pv != vv { t.Errorf("failed to match imported string value %q with expected %q for key %q", pv, vv, kk) @@ -356,10 +341,6 @@ func TestProcessDependencyImportValuesMultiLevelPrecedence(t *testing.T) { if s := strconv.FormatFloat(pv, 'f', -1, 64); s != vv { t.Errorf("failed to match imported float value %v with expected %v", s, vv) } - case json.Number: - if pv.String() != vv { - t.Errorf("failed to match imported string value %q with expected %q", pv, vv) - } default: if pv != vv { t.Errorf("failed to match imported string value %q with expected %q", pv, vv) diff --git a/pkg/chart/v2/util/values.go b/pkg/chart/v2/util/values.go index 42b1a28e8..6850e8b9b 100644 --- a/pkg/chart/v2/util/values.go +++ b/pkg/chart/v2/util/values.go @@ -17,7 +17,6 @@ limitations under the License. package util import ( - "encoding/json" "errors" "fmt" "io" @@ -106,10 +105,7 @@ func tableLookup(v Values, simple string) (Values, error) { // ReadValues will parse YAML byte data into a Values. func ReadValues(data []byte) (vals Values, err error) { - err = yaml.Unmarshal(data, &vals, func(d *json.Decoder) *json.Decoder { - d.UseNumber() - return d - }) + err = yaml.Unmarshal(data, &vals) if len(vals) == 0 { vals = Values{} } diff --git a/pkg/cmd/template_test.go b/pkg/cmd/template_test.go index c478fced4..a6c848e08 100644 --- a/pkg/cmd/template_test.go +++ b/pkg/cmd/template_test.go @@ -22,18 +22,6 @@ import ( "testing" ) -func TestTemplateCmdWithToml(t *testing.T) { - - tests := []cmdTestCase{ - { - name: "check toToml function rendering", - cmd: fmt.Sprintf("template '%s'", "testdata/testcharts/issue-totoml"), - golden: "output/issue-totoml.txt", - }, - } - runTestCmd(t, tests) -} - var chartPath = "testdata/testcharts/subchart" func TestTemplateCmd(t *testing.T) { diff --git a/pkg/cmd/testdata/output/issue-totoml.txt b/pkg/cmd/testdata/output/issue-totoml.txt deleted file mode 100644 index 06cf4bb8d..000000000 --- a/pkg/cmd/testdata/output/issue-totoml.txt +++ /dev/null @@ -1,8 +0,0 @@ ---- -# Source: issue-totoml/templates/configmap.yaml -apiVersion: v1 -kind: ConfigMap -metadata: - name: issue-totoml -data: | - key = 13 diff --git a/pkg/cmd/testdata/testcharts/issue-totoml/Chart.yaml b/pkg/cmd/testdata/testcharts/issue-totoml/Chart.yaml deleted file mode 100644 index f4be7a213..000000000 --- a/pkg/cmd/testdata/testcharts/issue-totoml/Chart.yaml +++ /dev/null @@ -1,3 +0,0 @@ -apiVersion: v2 -name: issue-totoml -version: 0.1.0 diff --git a/pkg/cmd/testdata/testcharts/issue-totoml/templates/configmap.yaml b/pkg/cmd/testdata/testcharts/issue-totoml/templates/configmap.yaml deleted file mode 100644 index 621e70d48..000000000 --- a/pkg/cmd/testdata/testcharts/issue-totoml/templates/configmap.yaml +++ /dev/null @@ -1,6 +0,0 @@ -apiVersion: v1 -kind: ConfigMap -metadata: - name: issue-totoml -data: | - {{ .Values.global | toToml }} diff --git a/pkg/cmd/testdata/testcharts/issue-totoml/values.yaml b/pkg/cmd/testdata/testcharts/issue-totoml/values.yaml deleted file mode 100644 index dd0140449..000000000 --- a/pkg/cmd/testdata/testcharts/issue-totoml/values.yaml +++ /dev/null @@ -1,2 +0,0 @@ -global: - key: 13 \ No newline at end of file