Skip to content
This repository has been archived by the owner on Dec 21, 2019. It is now read-only.

Commit

Permalink
fix main: Fix 'kontemplate template' output
Browse files Browse the repository at this point in the history
  • Loading branch information
tazjin committed Jun 11, 2017
1 parent 162b962 commit 3cba344
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
11 changes: 7 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}

Expand Down Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions templater/templater.go
Original file line number Diff line number Diff line change
Expand Up @@ -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!")
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 3cba344

Please sign in to comment.