Skip to content

Commit 6e82b21

Browse files
authored
Merge pull request #4385 from kubernetes-sigs/revert-4329-configMapIssue
Revert "[fix] configMapGenerator: extra space in end of line gives "\n" instead of line breaks"
2 parents 13e2600 + b063645 commit 6e82b21

File tree

3 files changed

+4
-82
lines changed

3 files changed

+4
-82
lines changed

api/internal/generators/utils.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ package generators
55

66
import (
77
"fmt"
8-
"strings"
98

109
"github.com/go-errors/errors"
1110
"sigs.k8s.io/kustomize/api/ifc"
@@ -51,11 +50,7 @@ func makeValidatedDataMap(
5150
return nil, errors.Errorf(
5251
"configmap %s illegally repeats the key `%s`", name, p.Key)
5352
}
54-
lines := strings.Split(p.Value, "\n")
55-
for i := range lines {
56-
lines[i] = strings.TrimSuffix(lines[i], " ")
57-
}
58-
knownKeys[p.Key] = strings.Join(lines, "\n")
53+
knownKeys[p.Key] = p.Value
5954
}
6055
return knownKeys, nil
6156
}

api/krusty/baseandoverlaymedium_test.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -292,10 +292,8 @@ metadata:
292292
---
293293
apiVersion: v1
294294
data:
295-
nonsense: |
296-
Lorem ipsum dolor sit amet, consectetur
297-
adipiscing elit, sed do eiusmod tempor
298-
incididunt ut labore et dolore magna aliqua.
295+
nonsense: "Lorem ipsum dolor sit amet, consectetur\nadipiscing elit, sed do eiusmod
296+
tempor\nincididunt ut labore et dolore magna aliqua. \n"
299297
kind: ConfigMap
300298
metadata:
301299
annotations:
@@ -304,6 +302,6 @@ metadata:
304302
app: mungebot
305303
org: kubernetes
306304
repo: test-infra
307-
name: test-infra-app-config-4thktg822m
305+
name: test-infra-app-config-49d6f5h7b5
308306
`)
309307
}

api/krusty/configmaps_test.go

Lines changed: 0 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -572,74 +572,3 @@ metadata:
572572
name: test-k9cc55dfm5
573573
`)
574574
}
575-
576-
// regression test for https://github.com/kubernetes-sigs/kustomize/issues/4287
577-
func TestMultilineDataEndsWithSpace(t *testing.T) {
578-
th := kusttest_test.MakeHarness(t)
579-
th.WriteK(".", `
580-
apiVersion: kustomize.config.k8s.io/v1beta1
581-
kind: Kustomization
582-
configMapGenerator:
583-
- name: config_bla
584-
files:
585-
- cfg.text=cfg.text
586-
`)
587-
th.WriteF("cfg.text", `bla
588-
bla
589-
bla
590-
`)
591-
592-
m := th.Run(".", th.MakeDefaultOptions())
593-
th.AssertActualEqualsExpected(
594-
m, `apiVersion: v1
595-
data:
596-
cfg.text: |
597-
bla
598-
bla
599-
bla
600-
kind: ConfigMap
601-
metadata:
602-
name: config_bla-4k548khbf5
603-
`)
604-
}
605-
606-
// regression test to record the behavior prior to the fix for https://github.com/kubernetes-sigs/kustomize/issues/4287
607-
// to ensure that the fix does not affect leading and trailing newlines in ConfigMap data
608-
func TestMultilineDataEndsLeadingAndTrailingNewlines(t *testing.T) {
609-
th := kusttest_test.MakeHarness(t)
610-
th.WriteK(".", `
611-
apiVersion: kustomize.config.k8s.io/v1beta1
612-
kind: Kustomization
613-
configMapGenerator:
614-
- name: config_bla
615-
files:
616-
- cfg.text=cfg.text
617-
`)
618-
th.WriteF("cfg.text", `
619-
620-
bla
621-
bla
622-
bla
623-
624-
625-
626-
`)
627-
628-
m := th.Run(".", th.MakeDefaultOptions())
629-
th.AssertActualEqualsExpected(
630-
m, `apiVersion: v1
631-
data:
632-
cfg.text: |2+
633-
634-
635-
bla
636-
bla
637-
bla
638-
639-
640-
641-
kind: ConfigMap
642-
metadata:
643-
name: config_bla-8dm6c68g22
644-
`)
645-
}

0 commit comments

Comments
 (0)