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

Commit

Permalink
support multiple manifests per file
Browse files Browse the repository at this point in the history
  • Loading branch information
svenwltr committed Aug 10, 2017
1 parent 049bed1 commit d07f301
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions pkg/api/render.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package api

import (
"regexp"
"strings"

"github.com/pkg/errors"
Expand Down Expand Up @@ -39,24 +40,28 @@ func (app *App) Render(fetched *FetchResult) ([]runtime.Object, error) {
continue
}

if strings.TrimSpace(data) == "" {
log.WithFields(log.Fields{
"Name": name,
}).Debug("Ignoring empty file.")
continue
}
splitted := regexp.MustCompile("[\n\r]---").Split(data, -1)

obj, _, err := decode([]byte(data), nil, nil)
if err != nil {
return nil, errors.Wrapf(err, "unable to decode file '%s'", name)
}
for _, part := range splitted {
if strings.TrimSpace(part) == "" {
log.WithFields(log.Fields{
"Name": name,
}).Debug("Ignoring empty file.")
continue
}

obj, err = app.Interceptors.PostManifestRender(obj)
if err != nil {
return nil, errors.WithStack(err)
}
obj, _, err := decode([]byte(part), nil, nil)
if err != nil {
return nil, errors.Wrapf(err, "unable to decode file '%s'", name)
}

objects = append(objects, obj)
obj, err = app.Interceptors.PostManifestRender(obj)
if err != nil {
return nil, errors.WithStack(err)
}

objects = append(objects, obj)
}
}

return objects, nil
Expand Down

0 comments on commit d07f301

Please sign in to comment.