diff --git a/api/krusty/baseandoverlaymedium_test.go b/api/krusty/baseandoverlaymedium_test.go index 569dc6c27..19bd3d8da 100644 --- a/api/krusty/baseandoverlaymedium_test.go +++ b/api/krusty/baseandoverlaymedium_test.go @@ -154,9 +154,8 @@ LEGUME=chickpea `) th.WriteF("/app/overlay/configmap/dummy.txt", `Lorem ipsum dolor sit amet, consectetur - -adipiscing elit, sed do eiusmod tempor -incididunt ut labore et dolore magna aliqua. +adipiscing elit, sed do eiusmod tempor +incididunt ut labore et dolore magna aliqua. `) th.WriteF("/app/overlay/deployment/deployment.yaml", ` apiVersion: apps/v1 @@ -293,11 +292,8 @@ metadata: --- apiVersion: v1 data: - nonsense: | - Lorem ipsum dolor sit amet, consectetur - - adipiscing elit, sed do eiusmod tempor - incididunt ut labore et dolore magna aliqua. + nonsense: "Lorem ipsum dolor sit amet, consectetur\nadipiscing elit, sed do eiusmod + tempor\nincididunt ut labore et dolore magna aliqua. \n" kind: ConfigMap metadata: annotations: @@ -306,6 +302,6 @@ metadata: app: mungebot org: kubernetes repo: test-infra - name: test-infra-app-config-hh272bg5d4 + name: test-infra-app-config-f462h769f9 `) } diff --git a/api/kv/kv.go b/api/kv/kv.go index 7bda10fd7..b887e583c 100644 --- a/api/kv/kv.go +++ b/api/kv/kv.go @@ -9,7 +9,6 @@ import ( "fmt" "os" "path" - "regexp" "strings" "unicode" "unicode/utf8" @@ -86,17 +85,11 @@ func (kvl *loader) keyValuesFromFileSources(sources []string) ([]types.Pair, err if err != nil { return nil, err } - kvs = append(kvs, types.Pair{Key: k, Value: trimTrailingSpacesInLines(string(content))}) + kvs = append(kvs, types.Pair{Key: k, Value: string(content)}) } return kvs, nil } -// trimTrailingSpacesInLines takes string with multiple lines and trims the trailing white spaces and tabs from each line. -func trimTrailingSpacesInLines(str string) string { - re := regexp.MustCompile(`[ \t]*\n`) - return re.ReplaceAllString(str, "\n") -} - func (kvl *loader) keyValuesFromEnvFiles(paths []string) ([]types.Pair, error) { var kvs []types.Pair for _, p := range paths { diff --git a/api/kv/kv_test.go b/api/kv/kv_test.go index 7241fcd98..bc362adce 100644 --- a/api/kv/kv_test.go +++ b/api/kv/kv_test.go @@ -95,12 +95,3 @@ func TestKeyValuesFromFileSources(t *testing.T) { } } } - -func TestTrimTrailingSpacesInLines(t *testing.T) { - input := "\"fooKey\": \"fooValue\" \t\n \t\t \n\t\"barKey\": \"barValue\"" - expected := "\"fooKey\": \"fooValue\"\n\n\t\"barKey\": \"barValue\"" - res := trimTrailingSpacesInLines(input) - if !reflect.DeepEqual(res, expected) { - t.Errorf("Trim trailing spaces in lines should succeed, got: %s exptected: %s", res, expected) - } -}