mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-05-17 18:25:26 +00:00
Merge pull request #2700 from jijiew/win-seperator
modify the byteioreader to handler windows line ending.
This commit is contained in:
@@ -115,7 +115,9 @@ func (r *ByteReader) Read() ([]*yaml.RNode, error) {
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err)
|
||||
}
|
||||
values := strings.Split(input.String(), "\n---\n")
|
||||
|
||||
// replace the ending \r\n (line ending used in windows) with \n and then separate by \n---\n
|
||||
values := strings.Split(strings.Replace(input.String(), "\r\n", "\n", -1), "\n---\n")
|
||||
|
||||
index := 0
|
||||
for i := range values {
|
||||
|
||||
@@ -299,6 +299,38 @@ metadata:
|
||||
SetAnnotations: map[string]string{"foo": "bar"}},
|
||||
},
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
{
|
||||
name: "windows_line_ending",
|
||||
input: "\r\n---\r\na: b # first resource\r\nc: d\r\n---\r\n# second resource\r\ne: f\r\ng:\r\n- h\r\n---\r\n\r\n---\r\n i: j",
|
||||
expectedItems: []string{
|
||||
`a: b # first resource
|
||||
c: d
|
||||
metadata:
|
||||
annotations:
|
||||
foo: 'bar'
|
||||
`,
|
||||
`# second resource
|
||||
e: f
|
||||
g:
|
||||
- h
|
||||
metadata:
|
||||
annotations:
|
||||
foo: 'bar'
|
||||
`,
|
||||
`i: j
|
||||
metadata:
|
||||
annotations:
|
||||
foo: 'bar'
|
||||
`,
|
||||
},
|
||||
instance: ByteReader{
|
||||
OmitReaderAnnotations: true,
|
||||
SetAnnotations: map[string]string{"foo": "bar"}},
|
||||
},
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user