Merge pull request #6032 from icanhazbroccoli/icanhazbroccoli/chartutil-no-scientific-notation-dev-v3

chartutil.ReadValues is forced to unmarshal numbers into json.Number refs #1707 [dev-v3]
pull/6046/head
Matthew Fisher 5 years ago committed by GitHub
commit 3e90602882
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -10,3 +10,4 @@ water:
water:
where: "everywhere"
nor: "any drop to drink"
temperature: 1234567890

@ -17,6 +17,7 @@ limitations under the License.
package chartutil
import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
@ -105,7 +106,10 @@ 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)
err = yaml.Unmarshal(data, &vals, func(d *json.Decoder) *json.Decoder {
d.UseNumber()
return d
})
if len(vals) == 0 {
vals = Values{}
}

@ -45,6 +45,7 @@ water:
water:
where: "everywhere"
nor: "any drop to drink"
temperature: 1234567890
`
data, err := ReadValues([]byte(doc))
@ -237,6 +238,12 @@ func matchValues(t *testing.T, data map[string]interface{}) {
} else if o != "everywhere" {
t.Errorf("Expected water water everywhere")
}
if o, err := ttpl("{{.water.water.temperature}}", data); err != nil {
t.Errorf(".water.water.temperature: %s", err)
} else if o != "1234567890" {
t.Errorf("Expected water water temperature: 1234567890, got: %s", o)
}
}
func ttpl(tpl string, v map[string]interface{}) (string, error) {

Loading…
Cancel
Save