Do not modify CM and Secrets Generator

This commit is contained in:
Phani Teja Marupaka
2020-05-06 09:30:12 -07:00
parent 212ec66e91
commit 7d600c1c5a
3 changed files with 6 additions and 26 deletions

View File

@@ -154,9 +154,8 @@ LEGUME=chickpea
`) `)
th.WriteF("/app/overlay/configmap/dummy.txt", th.WriteF("/app/overlay/configmap/dummy.txt",
`Lorem ipsum dolor sit amet, consectetur `Lorem ipsum dolor sit amet, consectetur
adipiscing elit, sed do eiusmod tempor
adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
incididunt ut labore et dolore magna aliqua.
`) `)
th.WriteF("/app/overlay/deployment/deployment.yaml", ` th.WriteF("/app/overlay/deployment/deployment.yaml", `
apiVersion: apps/v1 apiVersion: apps/v1
@@ -293,11 +292,8 @@ metadata:
--- ---
apiVersion: v1 apiVersion: v1
data: data:
nonsense: | nonsense: "Lorem ipsum dolor sit amet, consectetur\nadipiscing elit, sed do eiusmod
Lorem ipsum dolor sit amet, consectetur tempor\nincididunt ut labore et dolore magna aliqua. \n"
adipiscing elit, sed do eiusmod tempor
incididunt ut labore et dolore magna aliqua.
kind: ConfigMap kind: ConfigMap
metadata: metadata:
annotations: annotations:
@@ -306,6 +302,6 @@ metadata:
app: mungebot app: mungebot
org: kubernetes org: kubernetes
repo: test-infra repo: test-infra
name: test-infra-app-config-hh272bg5d4 name: test-infra-app-config-f462h769f9
`) `)
} }

View File

@@ -9,7 +9,6 @@ import (
"fmt" "fmt"
"os" "os"
"path" "path"
"regexp"
"strings" "strings"
"unicode" "unicode"
"unicode/utf8" "unicode/utf8"
@@ -86,17 +85,11 @@ func (kvl *loader) keyValuesFromFileSources(sources []string) ([]types.Pair, err
if err != nil { if err != nil {
return nil, err 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 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) { func (kvl *loader) keyValuesFromEnvFiles(paths []string) ([]types.Pair, error) {
var kvs []types.Pair var kvs []types.Pair
for _, p := range paths { for _, p := range paths {

View File

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