From 1f0f973d5a7e2c654c297de6619b6aea1d7e0380 Mon Sep 17 00:00:00 2001 From: Ian Howell Date: Thu, 25 Apr 2019 09:23:47 -0500 Subject: [PATCH] Fix up YAML/JSON conversions Signed-off-by: Ian Howell --- pkg/chartutil/values.go | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/pkg/chartutil/values.go b/pkg/chartutil/values.go index 9b6168597..2f00473a8 100644 --- a/pkg/chartutil/values.go +++ b/pkg/chartutil/values.go @@ -135,12 +135,12 @@ func ReadValuesFile(filename string) (Values, error) { } // ValidateAgainstSchema checks that values does not violate the structure laid out in schema -func ValidateAgainstSchema(values Values, schema []byte) error { - valuesJSON, err := convertYAMLToJSON(values) +func ValidateAgainstSchema(values Values, schemaJSON []byte) error { + valuesData, err := yaml.Marshal(values) if err != nil { return err } - schemaJSON, err := yaml.YAMLToJSON(schema) + valuesJSON, err := yaml.YAMLToJSON(valuesData) if err != nil { return err } @@ -378,15 +378,6 @@ func istable(v interface{}) bool { return ok } -// convertToJSON takes YAML data and returns a []byte representation of the same object as JSON -func convertYAMLToJSON(data interface{}) ([]byte, error) { - yamlData, err := yaml.Marshal(data) - if err != nil { - return nil, err - } - return yaml.YAMLToJSON(yamlData) -} - // PathValue takes a path that traverses a YAML structure and returns the value at the end of that path. // The path starts at the root of the YAML structure and is comprised of YAML keys separated by periods. // Given the following YAML data the value at path "chapter.one.title" is "Loomings".