Revert "List and set setters in folders recursively"

This commit is contained in:
phani
2020-07-22 13:51:42 -07:00
committed by GitHub
parent 8b9829f222
commit d9fe98a289
9 changed files with 60 additions and 153 deletions

View File

@@ -1,35 +0,0 @@
// Copyright 2019 The Kubernetes Authors.
// SPDX-License-Identifier: Apache-2.0
package pathutil
import (
"os"
"path/filepath"
"strings"
"sigs.k8s.io/kustomize/kyaml/errors"
)
// SubDirsWithFile takes the root directory path and returns all the paths of
// sub-directories which contain file with input fileName including itself
func SubDirsWithFile(root, fileName string) ([]string, error) {
var res []string
err := filepath.Walk(root,
func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}
if strings.HasSuffix(path, fileName) {
if root == "." {
path = root + "/" + path
}
res = append(res, path)
}
return nil
})
if err != nil {
return res, errors.Wrap(err)
}
return res, nil
}

View File

@@ -1,23 +0,0 @@
// Copyright 2019 The Kubernetes Authors.
// SPDX-License-Identifier: Apache-2.0
package printutil
import (
"fmt"
"io"
)
// GreenPrintf formats according to a format specifier and prints the resulting string
// in green color to the writer
func GreenPrintf(w io.Writer, format string, args ...string) {
msg := fmt.Sprintf(format, args)
fmt.Fprintf(w, "\033[1;32m%s\033[0m", msg)
}
// WarnPrintf formats according to a format specifier and prints the resulting string
// in yellow color to the writer
func WarnPrintf(w io.Writer, format string, args ...string) {
msg := fmt.Sprintf(format, args)
fmt.Fprintf(w, "\033[1;33m%s\033[0m", msg)
}

View File

@@ -34,8 +34,6 @@ type Set struct {
SetAll bool
}
const SetterNotFoundWarn = "unable to find setter with name "
// Filter implements Set as a yaml.Filter
func (s *Set) Filter(object *yaml.RNode) (*yaml.RNode, error) {
return object, accept(s, object)
@@ -330,14 +328,14 @@ func (s SetOpenAPI) Filter(object *yaml.RNode) (*yaml.RNode, error) {
return nil, err
}
if oa == nil {
return nil, errors.Errorf(SetterNotFoundWarn + s.Name)
return nil, errors.Errorf("no setter %s found", s.Name)
}
def, err := oa.Pipe(yaml.Lookup("x-k8s-cli", "setter"))
if err != nil {
return nil, err
}
if def == nil {
return nil, errors.Errorf(SetterNotFoundWarn + s.Name)
return nil, errors.Errorf("no setter %s found", s.Name)
}
// record the OpenAPI type for the setter

View File

@@ -1209,7 +1209,7 @@ openAPI:
{
name: "error",
setter: "replicas",
err: "unable to find setter with name replicas",
err: "no setter replicas found",
input: `
openAPI:
definitions: