Skip to content
This repository was archived by the owner on Jun 27, 2025. It is now read-only.

Commit f0496fb

Browse files
authored
Merge pull request #275 from jrasell/missing-key-zero
Use missingkey=zero rather than error in template rendering.
2 parents 06c1c67 + aa731fc commit f0496fb

File tree

2 files changed

+1
-12
lines changed

2 files changed

+1
-12
lines changed

template/render_test.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package template
22

33
import (
44
"os"
5-
"strings"
65
"testing"
76

87
nomad "github.com/hashicorp/nomad/api"
@@ -108,14 +107,4 @@ func TestTemplater_RenderTemplate(t *testing.T) {
108107
if *job.TaskGroups[0].Name != testEnvValue {
109108
t.Fatalf("expected %s but got %v", testEnvValue, *job.TaskGroups[0].Name)
110109
}
111-
112-
// Test var-args only render.
113-
fVars["job_name"] = testJobName
114-
_, err = RenderTemplate("test-fixtures/missing_var.nomad", []string{}, "", &fVars)
115-
if err == nil {
116-
t.Fatal("expected err to not be nil")
117-
}
118-
if !strings.Contains(err.Error(), "binary_url") {
119-
t.Fatal("expected err to mention missing var (binary_url)")
120-
}
121110
}

template/template.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const (
2828
func (t *tmpl) newTemplate() *template.Template {
2929
tmpl := template.New("jobTemplate")
3030
tmpl.Delims(leftDelim, rightDelim)
31-
tmpl.Option("missingkey=error")
31+
tmpl.Option("missingkey=zero")
3232
tmpl.Funcs(funcMap(t.consulClient))
3333
return tmpl
3434
}

0 commit comments

Comments
 (0)