From 34169174a8e8fbfa1cd01d35a6390c0f8e7ada1c Mon Sep 17 00:00:00 2001 From: Jingfang Liu Date: Thu, 23 Aug 2018 09:28:22 -0700 Subject: [PATCH] fix the double quotation problem in ConfigMapGenerator --- pkg/configmapandsecret/configmapfactory.go | 3 +-- pkg/configmapandsecret/configmapfactory_test.go | 4 +++- pkg/resmap/configmap_test.go | 4 +++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/pkg/configmapandsecret/configmapfactory.go b/pkg/configmapandsecret/configmapfactory.go index 0d11d690d..a12a6bc9e 100644 --- a/pkg/configmapandsecret/configmapfactory.go +++ b/pkg/configmapandsecret/configmapfactory.go @@ -212,6 +212,5 @@ func parseLiteralSource(source string) (keyName, value string, err error) { if len(items) != 2 { return "", "", fmt.Errorf("invalid literal source %v, expected key=value", source) } - - return items[0], items[1], nil + return items[0], strings.Trim(items[1], "\"'"), nil } diff --git a/pkg/configmapandsecret/configmapfactory_test.go b/pkg/configmapandsecret/configmapfactory_test.go index 54d3f8af8..8b89e0e78 100644 --- a/pkg/configmapandsecret/configmapfactory_test.go +++ b/pkg/configmapandsecret/configmapfactory_test.go @@ -90,6 +90,8 @@ func makeLiteralConfigMap(name string) *corev1.ConfigMap { Data: map[string]string{ "a": "x", "b": "y", + "c": "Hello World", + "d": "true", }, } } @@ -127,7 +129,7 @@ func TestConstructConfigMap(t *testing.T) { input: types.ConfigMapArgs{ Name: "literalConfigMap", DataSources: types.DataSources{ - LiteralSources: []string{"a=x", "b=y"}, + LiteralSources: []string{"a=x", "b=y", "c=\"Hello World\"", "d='true'"}, }, }, expected: makeLiteralConfigMap("literalConfigMap"), diff --git a/pkg/resmap/configmap_test.go b/pkg/resmap/configmap_test.go index fe3ab5bc1..c6355ceb9 100644 --- a/pkg/resmap/configmap_test.go +++ b/pkg/resmap/configmap_test.go @@ -104,7 +104,7 @@ BAR=baz { Name: "literalConfigMap", DataSources: types.DataSources{ - LiteralSources: []string{"a=x", "b=y"}, + LiteralSources: []string{"a=x", "b=y", "c=\"Good Morning\"", "d=\"false\""}, }, }, }, @@ -120,6 +120,8 @@ BAR=baz "data": map[string]interface{}{ "a": "x", "b": "y", + "c": "Good Morning", + "d": "false", }, }).SetBehavior(resource.BehaviorCreate), },