Merge pull request #5213 from flant/fix-quote-function

Make quote function to render pointers in the template properly
This commit is contained in:
Kubernetes Prow Robot 2020-03-05 12:10:37 -08:00 committed by GitHub
commit 07c37bd4d3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 0 deletions

View file

@ -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)
}

View file

@ -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 {