Only strip surrounding quotes if there are at least two characters.

Otherwise, a value consisting of a single quote character triggers a
panic:

    go test krusty/configmaps_test.go
    --- FAIL: TestDataIsSingleQuote (0.00s)
    panic: runtime error: slice bounds out of range [1:0] [recovered]
    	panic: runtime error: slice bounds out of range [1:0]
This commit is contained in:
Peter Lobsinger
2023-03-01 16:47:53 -08:00
parent e07b8a5d15
commit 633da991d2
2 changed files with 21 additions and 1 deletions

View File

@@ -571,3 +571,23 @@ metadata:
name: test-k9cc55dfm5
`)
}
func TestDataIsSingleQuote(t *testing.T) {
th := kusttest_test.MakeHarness(t)
th.WriteK(".", `
configMapGenerator:
- name: test
literals:
- TEST='
`)
m := th.Run(".", th.MakeDefaultOptions())
th.AssertActualEqualsExpected(
m, `apiVersion: v1
data:
TEST: ''''
kind: ConfigMap
metadata:
name: test-m8t7bmb6g2
`)
}