Skip to content

Commit

Permalink
Merge pull request #275 from jrasell/missing-key-zero
Browse files Browse the repository at this point in the history
Use missingkey=zero rather than error in template rendering.
  • Loading branch information
jrasell committed Mar 17, 2019
2 parents 06c1c67 + aa731fc commit f0496fb
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 12 deletions.
11 changes: 0 additions & 11 deletions template/render_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package template

import (
"os"
"strings"
"testing"

nomad "github.com/hashicorp/nomad/api"
Expand Down Expand Up @@ -108,14 +107,4 @@ func TestTemplater_RenderTemplate(t *testing.T) {
if *job.TaskGroups[0].Name != testEnvValue {
t.Fatalf("expected %s but got %v", testEnvValue, *job.TaskGroups[0].Name)
}

// Test var-args only render.
fVars["job_name"] = testJobName
_, err = RenderTemplate("test-fixtures/missing_var.nomad", []string{}, "", &fVars)
if err == nil {
t.Fatal("expected err to not be nil")
}
if !strings.Contains(err.Error(), "binary_url") {
t.Fatal("expected err to mention missing var (binary_url)")
}
}
2 changes: 1 addition & 1 deletion template/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const (
func (t *tmpl) newTemplate() *template.Template {
tmpl := template.New("jobTemplate")
tmpl.Delims(leftDelim, rightDelim)
tmpl.Option("missingkey=error")
tmpl.Option("missingkey=zero")
tmpl.Funcs(funcMap(t.consulClient))
return tmpl
}

0 comments on commit f0496fb

Please sign in to comment.