Make recurse logic public

This commit is contained in:
Phani Teja Marupaka
2020-10-14 14:00:01 -07:00
parent a458ed84f9
commit e9ff26bb1b
33 changed files with 217 additions and 198 deletions

View File

@@ -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 {

View File

@@ -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 {

View File

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

View File

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