Merge pull request #3119 from phanimarupaka/MakeRecurseLogicPublic

Make recurse logic public
This commit is contained in:
Kubernetes Prow Robot
2020-10-19 17:28:07 -07:00
committed by GitHub
33 changed files with 217 additions and 198 deletions

View File

@@ -8,7 +8,7 @@ import (
)
// EnabkeAlphaCommmandsEnvName is the environment variable used to enable Alpha kustomize commands.
//If set to "true" alpha commands will be enabled.
// If set to "true" alpha commands will be enabled.
const EnableAlphaCommmandsEnvName = "KUSTOMIZE_ENABLE_ALPHA_COMMANDS"
// GetAlphaEnabled returns true if alpha commands should be enabled.

View File

@@ -64,7 +64,7 @@ run(ctx.resource_list["items"])
Filters: []kio.Filter{fltr},
Outputs: []kio.Writer{&kio.ByteWriter{Writer: output}}}.Execute()
if err != nil {
log.Fatal(err)
log.Println(err)
}
fmt.Println(output.String())
@@ -131,7 +131,7 @@ spec:
value: "hello world"
`)
if err != nil {
log.Fatal(err)
log.Println(err)
}
// fltr transforms the input using a starlark program
@@ -156,7 +156,7 @@ run(ctx.resource_list["items"], ctx.resource_list["functionConfig"]["spec"]["val
Filters: []kio.Filter{fltr},
Outputs: []kio.Writer{&kio.ByteWriter{Writer: output}}}.Execute()
if err != nil {
log.Fatal(err)
log.Println(err)
}
fmt.Println(output.String())
@@ -197,7 +197,7 @@ func ExampleFilter_Filter_file() {
// setup the configuration
d, err := ioutil.TempDir("", "")
if err != nil {
log.Fatal(err)
log.Println(err)
}
defer os.RemoveAll(d)
@@ -214,7 +214,7 @@ spec:
image: nginx:1.8.1 # {"$ref": "#/definitions/io.k8s.cli.substitutions.image-1"}
`), 0600)
if err != nil {
log.Fatal(err)
log.Println(err)
}
err = ioutil.WriteFile(filepath.Join(d, "deploy2.yaml"), []byte(`
@@ -230,7 +230,7 @@ spec:
image: nginx:1.7.9 # {"$ref": "#/definitions/io.k8s.cli.substitutions.image-2"}
`), 0600)
if err != nil {
log.Fatal(err)
log.Println(err)
}
err = ioutil.WriteFile(filepath.Join(d, "annotate.star"), []byte(`
@@ -241,7 +241,7 @@ def run(items):
run(ctx.resource_list["items"])
`), 0600)
if err != nil {
log.Fatal(err)
log.Println(err)
}
fltr := &starlark.Filter{
@@ -261,7 +261,7 @@ run(ctx.resource_list["items"])
ClearAnnotations: []string{"config.kubernetes.io/path"},
}}}.Execute()
if err != nil {
log.Fatal(err)
log.Println(err)
}
fmt.Println(output.String())

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

View File

@@ -114,7 +114,7 @@ func (fs *fieldSetter) set(
}
// be sure to set the tag to the matching type so the yaml doesn't incorrectly quote
//integers or booleans as strings
// integers or booleans as strings
fType := fieldmeta.FieldValueType(f.Schema.Type[0])
if err := fType.Validate(field.YNode().Value); err != nil {
return err

View File

@@ -281,13 +281,13 @@ packageMetadata:
func TestAdd_Filter2(t *testing.T) {
path := filepath.Join(os.TempDir(), "resourcefile")
//write initial resourcefile to temp path
// write initial resourcefile to temp path
err := ioutil.WriteFile(path, []byte(resourcefile), 0666)
if !assert.NoError(t, err) {
t.FailNow()
}
//add a setter definition
// add a setter definition
sd := SetterDefinition{
Name: "image",
Value: "1",

View File

@@ -36,7 +36,7 @@ type substitutionSetterReference struct {
Marker string `yaml:"marker,omitempty" json:"marker,omitempty"`
}
//K8sCliExtensionKey is the name of the OpenAPI field containing the setter extensions
// K8sCliExtensionKey is the name of the OpenAPI field containing the setter extensions
const K8sCliExtensionKey = "x-k8s-cli"
// GetExtFromSchema returns the cliExtension openAPI extension if it is present in schema

View File

@@ -15,7 +15,7 @@ var fieldSortOrder = []string{
// secret and configmap
"stringData", "data", "binaryData",
//cronjobspec, daemonsetspec, deploymentspec, statefulsetspec,
// cronjobspec, daemonsetspec, deploymentspec, statefulsetspec,
// jobspec fields
"parallelism", "completions", "activeDeadlineSeconds", "backoffLimit",
"replicas", "selector", "manualSelector", "template",