Merge pull request #30884 from mattfarina/revert-toml-change

Reverting fix "renders int as float"
pull/30888/head
Robert Sirchia 4 months ago committed by GitHub
commit 707f1aee42
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -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, &currentMap, func(d *json.Decoder) *json.Decoder {
d.UseNumber()
return d
}); err != nil {
if err := yaml.Unmarshal(raw, &currentMap); err != nil {
return nil, fmt.Errorf("cannot unmarshal yaml document: %w", err)
}
values = MergeMaps(values, currentMap)

@ -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)

@ -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{}
}

@ -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) {

@ -1,8 +0,0 @@
---
# Source: issue-totoml/templates/configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: issue-totoml
data: |
key = 13

@ -1,3 +0,0 @@
apiVersion: v2
name: issue-totoml
version: 0.1.0

@ -1,6 +0,0 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: issue-totoml
data: |
{{ .Values.global | toToml }}
Loading…
Cancel
Save