Fix up YAML/JSON conversions

Signed-off-by: Ian Howell <ian.howell0@gmail.com>
pull/5350/head
Ian Howell 7 years ago
parent db4d6c857d
commit 1f0f973d5a

@ -135,12 +135,12 @@ func ReadValuesFile(filename string) (Values, error) {
} }
// ValidateAgainstSchema checks that values does not violate the structure laid out in schema // ValidateAgainstSchema checks that values does not violate the structure laid out in schema
func ValidateAgainstSchema(values Values, schema []byte) error { func ValidateAgainstSchema(values Values, schemaJSON []byte) error {
valuesJSON, err := convertYAMLToJSON(values) valuesData, err := yaml.Marshal(values)
if err != nil { if err != nil {
return err return err
} }
schemaJSON, err := yaml.YAMLToJSON(schema) valuesJSON, err := yaml.YAMLToJSON(valuesData)
if err != nil { if err != nil {
return err return err
} }
@ -378,15 +378,6 @@ func istable(v interface{}) bool {
return ok 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. // 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. // 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". // Given the following YAML data the value at path "chapter.one.title" is "Loomings".

Loading…
Cancel
Save