Repository: helm/helm
Pull request #30885 (2025-05-20 20:16:31)

Revert "fix (helm) : toToml` renders int as float [ backport to v3 ]"
Reverts helm/helm#13534


Patch:
diff --git a/pkg/chart/loader/load.go b/pkg/chart/loader/load.go
index 622dac4b8..a68a05aa9 100644
--- a/pkg/chart/loader/load.go
+++ b/pkg/chart/loader/load.go
@@ -18,7 +18,6 @@ package loader
 
 import (
 	"bytes"
-	"encoding/json"
 	"log"
 	"os"
 	"path/filepath"
@@ -105,10 +104,7 @@ func LoadFiles(files []*BufferedFile) (*chart.Chart, error) {
 			}
 		case f.Name == "values.yaml":
 			c.Values = make(map[string]interface{})
-			if err := yaml.Unmarshal(f.Data, &c.Values, func(d *json.Decoder) *json.Decoder {
-				d.UseNumber()
-				return d
-			}); err != nil {
+			if err := yaml.Unmarshal(f.Data, &c.Values); err != nil {
 				return c, errors.Wrap(err, "cannot load values.yaml")
 			}
 		case f.Name == "values.schema.json":
diff --git a/pkg/chartutil/values.go b/pkg/chartutil/values.go
index 566951ec5..61c633a6d 100644
--- a/pkg/chartutil/values.go
+++ b/pkg/chartutil/values.go
@@ -17,7 +17,6 @@ limitations under the License.
 package chartutil
 
 import (
-	"encoding/json"
 	"fmt"
 	"io"
 	"os"
@@ -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{}
 	}


Test patch:
diff --git a/cmd/helm/template_test.go b/cmd/helm/template_test.go
index d13f96057..e5b939879 100644
--- a/cmd/helm/template_test.go
+++ b/cmd/helm/template_test.go
@@ -161,11 +161,6 @@ func TestTemplateCmd(t *testing.T) {
 			cmd:    fmt.Sprintf("template '%s' -f %s/extra_values.yaml", chartPath, chartPath),
 			golden: "output/template-subchart-cm-set-file.txt",
 		},
-		{
-			name:   "check toToml function rendering",
-			cmd:    fmt.Sprintf("template '%s'", "testdata/testcharts/issue-totoml"),
-			golden: "output/issue-totoml.txt",
-		},
 	}
 	runTestCmd(t, tests)
 }
diff --git a/cmd/helm/testdata/output/issue-totoml.txt b/cmd/helm/testdata/output/issue-totoml.txt
deleted file mode 100644
index 06cf4bb8d..000000000
--- a/cmd/helm/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/cmd/helm/testdata/testcharts/issue-totoml/Chart.yaml b/cmd/helm/testdata/testcharts/issue-totoml/Chart.yaml
deleted file mode 100644
index 2815d0d21..000000000
--- a/cmd/helm/testdata/testcharts/issue-totoml/Chart.yaml
+++ /dev/null
@@ -1,3 +0,0 @@
-apiVersion: v2
-name: issue-totoml
-version: 0.1.0
\ No newline at end of file
diff --git a/cmd/helm/testdata/testcharts/issue-totoml/templates/configmap.yaml b/cmd/helm/testdata/testcharts/issue-totoml/templates/configmap.yaml
deleted file mode 100644
index 2db705b63..000000000
--- a/cmd/helm/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 }}
\ No newline at end of file
diff --git a/cmd/helm/testdata/testcharts/issue-totoml/values.yaml b/cmd/helm/testdata/testcharts/issue-totoml/values.yaml
deleted file mode 100644
index dd0140449..000000000
--- a/cmd/helm/testdata/testcharts/issue-totoml/values.yaml
+++ /dev/null
@@ -1,2 +0,0 @@
-global:
-  key: 13
\ No newline at end of file
diff --git a/pkg/chartutil/dependencies_test.go b/pkg/chartutil/dependencies_test.go
index bf8b1a9b5..7e035be5f 100644
--- a/pkg/chartutil/dependencies_test.go
+++ b/pkg/chartutil/dependencies_test.go
@@ -15,7 +15,6 @@ limitations under the License.
 package chartutil
 
 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)
@@ -324,10 +309,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)