Skip to content

Commit

Permalink
Make goml set work with arrays on top-level
Browse files Browse the repository at this point in the history
This fixes issues when manipulating ops-files which are an array on top-level, not a map.
  • Loading branch information
petergtz committed Jul 30, 2018
1 parent 8c36e02 commit b21d037
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,18 @@ func convertValueType(val interface{}) interface{} {
}

func WriteYaml(yml *simpleyaml.Yaml, file string) error {
goml, err := yml.Map()
var (
err error
goml interface{}
)
switch {
case yml.IsMap():
goml, err = yml.Map()
case yml.IsArray():
goml, err = yml.Array()
default:
err = errors.New("Unexpected yml structure after manipulation")
}
if err != nil {
return err
}
Expand Down

0 comments on commit b21d037

Please sign in to comment.