Merge pull request #811 from mouserage/master

Templates partials
pull/842/head
Matt Butcher 8 years ago committed by GitHub
commit e36647d1c3

@ -5,8 +5,10 @@ import (
"errors"
"fmt"
"log"
"path"
"regexp"
"sort"
"strings"
"github.com/technosophos/moniker"
ctx "golang.org/x/net/context"
@ -233,6 +235,11 @@ func (s *releaseServer) InstallRelease(c ctx.Context, req *services.InstallRelea
b := bytes.NewBuffer(nil)
for name, file := range files {
// Ignore templates that starts with underscore to handle them as partials
if strings.HasPrefix(path.Base(name), "_") {
continue
}
// Ignore empty documents because the Kubernetes library can't handle
// them.
if len(file) > 0 {

@ -97,6 +97,8 @@ func TestInstallReleaseDryRun(t *testing.T) {
{Name: "hello", Data: []byte("hello: world")},
{Name: "goodbye", Data: []byte("goodbye: world")},
{Name: "empty", Data: []byte("")},
{Name: "with-partials", Data: []byte("hello: {{ template \"partials/_planet\" . }}")},
{Name: "partials/_planet", Data: []byte("Earth")},
},
},
DryRun: true,
@ -117,6 +119,14 @@ func TestInstallReleaseDryRun(t *testing.T) {
t.Errorf("unexpected output: %s", res.Release.Manifest)
}
if !strings.Contains(res.Release.Manifest, "hello: Earth") {
t.Errorf("Should contain partial content. %s", res.Release.Manifest)
}
if strings.Contains(res.Release.Manifest, "hello: {{ template \"partials/_planet\" . }}") {
t.Errorf("Should not contain partial templates itself. %s", res.Release.Manifest)
}
if strings.Contains(res.Release.Manifest, "empty") {
t.Errorf("Should not contain template data for an empty file. %s", res.Release.Manifest)
}

Loading…
Cancel
Save