mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-11 17:12:51 +00:00
Make recurse logic public
This commit is contained in:
@@ -117,7 +117,7 @@ func (r *ByteReader) Read() ([]*yaml.RNode, error) {
|
||||
}
|
||||
|
||||
// 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")
|
||||
values := strings.Split(strings.ReplaceAll(input.String(), "\r\n", "\n"), "\n---\n")
|
||||
|
||||
index := 0
|
||||
for i := range values {
|
||||
|
||||
@@ -170,9 +170,9 @@ func (f *FileSetter) Filter(input []*yaml.RNode) ([]*yaml.RNode, error) {
|
||||
return nil, err
|
||||
}
|
||||
file := f.FilenamePattern
|
||||
file = strings.Replace(file, string(KindFmt), strings.ToLower(m.Kind), -1)
|
||||
file = strings.Replace(file, string(NameFmt), strings.ToLower(m.Name), -1)
|
||||
file = strings.Replace(file, string(NamespaceFmt), strings.ToLower(m.Namespace), -1)
|
||||
file = strings.ReplaceAll(file, string(KindFmt), strings.ToLower(m.Kind))
|
||||
file = strings.ReplaceAll(file, string(NameFmt), strings.ToLower(m.Name))
|
||||
file = strings.ReplaceAll(file, string(NamespaceFmt), strings.ToLower(m.Namespace))
|
||||
|
||||
if _, found := m.Annotations[kioutil.PathAnnotation]; !found || f.Override {
|
||||
if _, err := input[i].Pipe(yaml.SetAnnotation(kioutil.PathAnnotation, file)); err != nil {
|
||||
|
||||
@@ -68,7 +68,7 @@ func (f GrepFilter) Filter(input []*yaml.RNode) ([]*yaml.RNode, error) {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
str = strings.TrimSpace(strings.Replace(str, `"`, "", -1))
|
||||
str = strings.TrimSpace(strings.ReplaceAll(str, `"`, ""))
|
||||
} else {
|
||||
// if not regexp, then it needs to parse into a quantity and comments will
|
||||
// break that
|
||||
|
||||
@@ -5,7 +5,6 @@ package kio_test
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
@@ -69,7 +68,7 @@ spec:
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
if !assert.Equal(t, fmt.Sprintf(`
|
||||
if !assert.Equal(t, `
|
||||
├── bar-package
|
||||
│ └── [f2.yaml] Deployment bar
|
||||
└── foo-package
|
||||
@@ -77,7 +76,7 @@ spec:
|
||||
├── [f1.yaml] Service default/foo
|
||||
└── 3
|
||||
└── [f3.yaml] Deployment default/foo
|
||||
`), out.String()) {
|
||||
`, out.String()) {
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user