Skip to content
This repository has been archived by the owner on Oct 13, 2021. It is now read-only.

Commit

Permalink
Simplify YAMLToUnstructuredSlice slightly
Browse files Browse the repository at this point in the history
Avoid named returns as they're not as explicit as explicitly created
ones.
  • Loading branch information
Mathias Söderberg committed Sep 23, 2019
1 parent 59daa97 commit dfba959
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions pkg/utils/decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,14 @@ func YAMLToUnstructured(in []byte) (u unstructured.Unstructured, err error) {
}

// YAMLToUnstructuredSlice converts a raw yaml document into a slice of pointers to Unstructured objects
func YAMLToUnstructuredSlice(in []byte) (us []*unstructured.Unstructured, err error) {
func YAMLToUnstructuredSlice(in []byte) ([]*unstructured.Unstructured, error) {
var us []*unstructured.Unstructured
for _, yaml := range splitYAML(in) {
var u unstructured.Unstructured
u, err = YAMLToUnstructured(yaml)
u, err := YAMLToUnstructured(yaml)
if err != nil {
// unable to parse properly, bail
break
return us, err
}
if u.IsList() {
err = u.EachListItem(func(obj runtime.Object) error {
Expand All @@ -89,7 +90,7 @@ func YAMLToUnstructuredSlice(in []byte) (us []*unstructured.Unstructured, err er
us = append(us, &u)
}
}
return us, err
return us, nil
}

// splitYAML will take raw yaml from a file and split yaml documents on the
Expand Down

0 comments on commit dfba959

Please sign in to comment.