diff options
author | Vincent Ambo <tazjin@gmail.com> | 2017-06-11T19·43+0200 |
---|---|---|
committer | Vincent Ambo <tazjin@gmail.com> | 2017-06-11T20·09+0200 |
commit | 3cba344fbec32d4570c6b1a8758426009dfb8173 (patch) | |
tree | 1fd3014009ea32fdaac34b59a2260d81b7e462e7 | |
parent | 162b962fad4e9d4f99b865aa4d22e7c3581756e8 (diff) |
fix main: Fix 'kontemplate template' output
-rw-r--r-- | main.go | 11 | ||||
-rw-r--r-- | templater/templater.go | 4 |
2 files changed, 9 insertions, 6 deletions
diff --git a/main.go b/main.go index 57dd62068b0b..5ece1183d412 100644 --- a/main.go +++ b/main.go @@ -80,10 +80,13 @@ func versionCommand() { } func templateCommand() { - _, resources := loadContextAndResources(templateFile) + _, resourceSets := loadContextAndResources(templateFile) - for _, r := range *resources { - fmt.Println(r) + for _, rs := range *resourceSets { + for _, r := range rs.Resources { + fmt.Fprintf(os.Stderr, "Rendered file %s/%s:\n", rs.Name, r.Filename) + fmt.Println(r.Rendered) + } } } @@ -163,7 +166,7 @@ func runKubectlWithResources(c *context.Context, kubectlArgs *[]string, resource } for _, r := range resourceSet.Resources { - fmt.Printf("Passing file %s/%s to kubectl", resourceSet.Name, r.Filename) + fmt.Printf("Passing file %s/%s to kubectl\n", resourceSet.Name, r.Filename) fmt.Fprintln(stdin, r.Rendered) } stdin.Close() diff --git a/templater/templater.go b/templater/templater.go index afb96423e62e..9054ebac4089 100644 --- a/templater/templater.go +++ b/templater/templater.go @@ -42,7 +42,7 @@ type RenderedResourceSet struct { func LoadAndApplyTemplates(include *[]string, exclude *[]string, c *context.Context) ([]RenderedResourceSet, error) { limitedResourceSets := applyLimits(&c.ResourceSets, include, exclude) - renderedResourceSets := make([]RenderedResourceSet, len(c.ResourceSets)) + renderedResourceSets := make([]RenderedResourceSet, 0) if len(*limitedResourceSets) == 0 { return renderedResourceSets, fmt.Errorf("No valid resource sets included!") @@ -83,7 +83,7 @@ func processResourceSet(c *context.Context, rs *context.ResourceSet) (*RenderedR } func processFiles(c *context.Context, rs *context.ResourceSet, rp string, files []os.FileInfo) ([]RenderedResource, error) { - resources := make([]RenderedResource, len(c.ResourceSets)) + resources := make([]RenderedResource, 0) for _, file := range files { if !file.IsDir() && isResourceFile(file) { |