mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-14 10:30:59 +00:00
Merge pull request #2129 from phanimarupaka/FixTrimmingNewLines
Do not remove empty lines in configmap/secret
This commit is contained in:
@@ -153,7 +153,8 @@ FRUIT=banana
|
|||||||
LEGUME=chickpea
|
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.
|
||||||
`)
|
`)
|
||||||
@@ -294,6 +295,7 @@ apiVersion: v1
|
|||||||
data:
|
data:
|
||||||
nonsense: |
|
nonsense: |
|
||||||
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.
|
||||||
kind: ConfigMap
|
kind: ConfigMap
|
||||||
@@ -304,6 +306,6 @@ metadata:
|
|||||||
app: mungebot
|
app: mungebot
|
||||||
org: kubernetes
|
org: kubernetes
|
||||||
repo: test-infra
|
repo: test-infra
|
||||||
name: test-infra-app-config-4mt28b5bg2
|
name: test-infra-app-config-hh272bg5d4
|
||||||
`)
|
`)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ func (kvl *loader) keyValuesFromFileSources(sources []string) ([]types.Pair, err
|
|||||||
|
|
||||||
// trimTrailingSpacesInLines takes string with multiple lines and trims the trailing white spaces and tabs from each line.
|
// trimTrailingSpacesInLines takes string with multiple lines and trims the trailing white spaces and tabs from each line.
|
||||||
func trimTrailingSpacesInLines(str string) string {
|
func trimTrailingSpacesInLines(str string) string {
|
||||||
re := regexp.MustCompile(`\s*\n`)
|
re := regexp.MustCompile(`[ \t]*\n`)
|
||||||
return re.ReplaceAllString(str, "\n")
|
return re.ReplaceAllString(str, "\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -97,8 +97,8 @@ func TestKeyValuesFromFileSources(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestTrimTrailingSpacesInLines(t *testing.T) {
|
func TestTrimTrailingSpacesInLines(t *testing.T) {
|
||||||
input := "\"fooKey\": \"fooValue\" \t\n\t\"barKey\": \"barValue\""
|
input := "\"fooKey\": \"fooValue\" \t\n \t\t \n\t\"barKey\": \"barValue\""
|
||||||
expected := "\"fooKey\": \"fooValue\"\n\t\"barKey\": \"barValue\""
|
expected := "\"fooKey\": \"fooValue\"\n\n\t\"barKey\": \"barValue\""
|
||||||
res := trimTrailingSpacesInLines(input)
|
res := trimTrailingSpacesInLines(input)
|
||||||
if !reflect.DeepEqual(res, expected) {
|
if !reflect.DeepEqual(res, expected) {
|
||||||
t.Errorf("Trim trailing spaces in lines should succeed, got: %s exptected: %s", res, expected)
|
t.Errorf("Trim trailing spaces in lines should succeed, got: %s exptected: %s", res, expected)
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ exclude (
|
|||||||
)
|
)
|
||||||
|
|
||||||
replace (
|
replace (
|
||||||
|
sigs.k8s.io/kustomize/api v0.3.2 => ../api
|
||||||
sigs.k8s.io/kustomize/cmd/kubectl v0.0.3 => ../cmd/kubectl
|
sigs.k8s.io/kustomize/cmd/kubectl v0.0.3 => ../cmd/kubectl
|
||||||
sigs.k8s.io/kustomize/kstatus v0.0.1 => ../kstatus
|
sigs.k8s.io/kustomize/kstatus v0.0.1 => ../kstatus
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user