Skip to content

Commit

Permalink
Only return valid data
Browse files Browse the repository at this point in the history
  • Loading branch information
Lewis Marshall authored and lewismarshall committed Mar 14, 2019
1 parent 0c87032 commit 24a18bd
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -549,10 +549,11 @@ func updateResFromFlags(c *cli.Context, r *ObjectResource) error {
// splitYamlDocs splits a yaml string into separate yaml documents.
func splitYamlDocs(data string) []string {
r := regexp.MustCompile(`(?m)^---\n`)
s := r.Split(data, -1)
for i, item := range s {
if item == "" {
s = append(s[:i], s[i+1:]...)
rSplit := r.Split(data, -1)
s := make([]string, 0)
for _, item := range rSplit {
if len(strings.TrimSpace(item)) > 0 {
s = append(s, item)
}
}
return s
Expand Down

0 comments on commit 24a18bd

Please sign in to comment.