mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-11 00:52:55 +00:00
Merge pull request #3119 from phanimarupaka/MakeRecurseLogicPublic
Make recurse logic public
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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())
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user