Skip to content

Commit bec6609

Browse files
committed
Revert "fix (helm) : toToml` renders int as float [ backport to v3 ]"
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. Closes #30880 Signed-off-by: Matt Farina <[email protected]> (cherry picked from commit c5249c1)
1 parent cc58e3f commit bec6609

File tree

8 files changed

+2
-53
lines changed

8 files changed

+2
-53
lines changed

cmd/helm/template_test.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,6 @@ func TestTemplateCmd(t *testing.T) {
161161
cmd: fmt.Sprintf("template '%s' -f %s/extra_values.yaml", chartPath, chartPath),
162162
golden: "output/template-subchart-cm-set-file.txt",
163163
},
164-
{
165-
name: "check toToml function rendering",
166-
cmd: fmt.Sprintf("template '%s'", "testdata/testcharts/issue-totoml"),
167-
golden: "output/issue-totoml.txt",
168-
},
169164
}
170165
runTestCmd(t, tests)
171166
}

cmd/helm/testdata/output/issue-totoml.txt

Lines changed: 0 additions & 8 deletions
This file was deleted.

cmd/helm/testdata/testcharts/issue-totoml/Chart.yaml

Lines changed: 0 additions & 3 deletions
This file was deleted.

cmd/helm/testdata/testcharts/issue-totoml/templates/configmap.yaml

Lines changed: 0 additions & 6 deletions
This file was deleted.

cmd/helm/testdata/testcharts/issue-totoml/values.yaml

Lines changed: 0 additions & 2 deletions
This file was deleted.

pkg/chart/loader/load.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ package loader
1818

1919
import (
2020
"bytes"
21-
"encoding/json"
2221
"log"
2322
"os"
2423
"path/filepath"
@@ -105,10 +104,7 @@ func LoadFiles(files []*BufferedFile) (*chart.Chart, error) {
105104
}
106105
case f.Name == "values.yaml":
107106
c.Values = make(map[string]interface{})
108-
if err := yaml.Unmarshal(f.Data, &c.Values, func(d *json.Decoder) *json.Decoder {
109-
d.UseNumber()
110-
return d
111-
}); err != nil {
107+
if err := yaml.Unmarshal(f.Data, &c.Values); err != nil {
112108
return c, errors.Wrap(err, "cannot load values.yaml")
113109
}
114110
case f.Name == "values.schema.json":

pkg/chartutil/dependencies_test.go

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ limitations under the License.
1515
package chartutil
1616

1717
import (
18-
"encoding/json"
1918
"os"
2019
"path/filepath"
2120
"sort"
@@ -238,20 +237,6 @@ func TestProcessDependencyImportValues(t *testing.T) {
238237
if b := strconv.FormatBool(pv); b != vv {
239238
t.Errorf("failed to match imported bool value %v with expected %v for key %q", b, vv, kk)
240239
}
241-
case json.Number:
242-
if fv, err := pv.Float64(); err == nil {
243-
if sfv := strconv.FormatFloat(fv, 'f', -1, 64); sfv != vv {
244-
t.Errorf("failed to match imported float value %v with expected %v for key %q", sfv, vv, kk)
245-
}
246-
}
247-
if iv, err := pv.Int64(); err == nil {
248-
if siv := strconv.FormatInt(iv, 10); siv != vv {
249-
t.Errorf("failed to match imported int value %v with expected %v for key %q", siv, vv, kk)
250-
}
251-
}
252-
if pv.String() != vv {
253-
t.Errorf("failed to match imported string value %q with expected %q for key %q", pv, vv, kk)
254-
}
255240
default:
256241
if pv != vv {
257242
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) {
324309
if s := strconv.FormatFloat(pv, 'f', -1, 64); s != vv {
325310
t.Errorf("failed to match imported float value %v with expected %v", s, vv)
326311
}
327-
case json.Number:
328-
if pv.String() != vv {
329-
t.Errorf("failed to match imported string value %q with expected %q", pv, vv)
330-
}
331312
default:
332313
if pv != vv {
333314
t.Errorf("failed to match imported string value %q with expected %q", pv, vv)

pkg/chartutil/values.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ limitations under the License.
1717
package chartutil
1818

1919
import (
20-
"encoding/json"
2120
"fmt"
2221
"io"
2322
"os"
@@ -106,10 +105,7 @@ func tableLookup(v Values, simple string) (Values, error) {
106105

107106
// ReadValues will parse YAML byte data into a Values.
108107
func ReadValues(data []byte) (vals Values, err error) {
109-
err = yaml.Unmarshal(data, &vals, func(d *json.Decoder) *json.Decoder {
110-
d.UseNumber()
111-
return d
112-
})
108+
err = yaml.Unmarshal(data, &vals)
113109
if len(vals) == 0 {
114110
vals = Values{}
115111
}

0 commit comments

Comments
 (0)