Skip to content

Commit

Permalink
Fix quote function in template to render pointers properly
Browse files Browse the repository at this point in the history
  • Loading branch information
nabokihms committed Mar 5, 2020
1 parent 99419c7 commit ed30be0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions internal/ingress/controller/template/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@ func quote(input interface{}) string {
inputStr = input
case fmt.Stringer:
inputStr = input.String()
case *string:
inputStr = *input
default:
inputStr = fmt.Sprintf("%v", input)
}
Expand Down
2 changes: 2 additions & 0 deletions internal/ingress/controller/template/template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,10 +256,12 @@ func TestFormatIP(t *testing.T) {
}

func TestQuote(t *testing.T) {
foo := "foo"
cases := map[interface{}]string{
"foo": `"foo"`,
"\"foo\"": `"\"foo\""`,
"foo\nbar": `"foo\nbar"`,
&foo: `"foo"`,
10: `"10"`,
}
for input, output := range cases {
Expand Down

0 comments on commit ed30be0

Please sign in to comment.