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

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