diff --git a/pkg/kubectl/cmd/delete/delete_flags.go b/pkg/kubectl/cmd/delete/delete_flags.go index ecad7d35c2c..f6dcc74d95f 100644 --- a/pkg/kubectl/cmd/delete/delete_flags.go +++ b/pkg/kubectl/cmd/delete/delete_flags.go @@ -90,7 +90,6 @@ func (f *DeleteFlags) ToOptions(dynamicClient dynamic.Interface, streams generic options.WaitForDeletion = *f.Wait } - options.FilenameOptions.EnableKustomization = true return options } diff --git a/pkg/kubectl/cmd/util/helpers.go b/pkg/kubectl/cmd/util/helpers.go index 516f6b17086..9a392cde59b 100644 --- a/pkg/kubectl/cmd/util/helpers.go +++ b/pkg/kubectl/cmd/util/helpers.go @@ -385,7 +385,6 @@ func AddValidateOptionFlags(cmd *cobra.Command, options *ValidateOptions) { func AddFilenameOptionFlags(cmd *cobra.Command, options *resource.FilenameOptions, usage string) { AddJsonFilenameFlag(cmd.Flags(), &options.Filenames, "Filename, directory, or URL to files "+usage) cmd.Flags().BoolVarP(&options.Recursive, "recursive", "R", options.Recursive, "Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory.") - options.EnableKustomization = true } func AddJsonFilenameFlag(flags *pflag.FlagSet, value *[]string, usage string) { diff --git a/staging/src/k8s.io/cli-runtime/pkg/genericclioptions/resource/builder.go b/staging/src/k8s.io/cli-runtime/pkg/genericclioptions/resource/builder.go index c67be8651f7..42f660a4e53 100644 --- a/staging/src/k8s.io/cli-runtime/pkg/genericclioptions/resource/builder.go +++ b/staging/src/k8s.io/cli-runtime/pkg/genericclioptions/resource/builder.go @@ -130,9 +130,8 @@ func IsUsageError(err error) bool { } type FilenameOptions struct { - Filenames []string - Recursive bool - EnableKustomization bool + Filenames []string + Recursive bool } type resourceTuple struct { @@ -198,7 +197,6 @@ func (b *Builder) AddError(err error) *Builder { // recognized will be ignored (but logged at V(2)). func (b *Builder) FilenameParam(enforceNamespace bool, filenameOptions *FilenameOptions) *Builder { recursive := filenameOptions.Recursive - enableKustomization := filenameOptions.EnableKustomization paths := filenameOptions.Filenames for _, s := range paths { switch { @@ -215,7 +213,7 @@ func (b *Builder) FilenameParam(enforceNamespace bool, filenameOptions *Filename if !recursive { b.singleItemImplied = true } - b.Path(recursive, enableKustomization, s) + b.Path(recursive, s) } } @@ -334,7 +332,7 @@ func (b *Builder) Stream(r io.Reader, name string) *Builder { // FileVisitor is streaming the content to a StreamVisitor. If ContinueOnError() is set // prior to this method being called, objects on the path that are unrecognized will be // ignored (but logged at V(2)). -func (b *Builder) Path(recursive, enableKustomization bool, paths ...string) *Builder { +func (b *Builder) Path(recursive bool, paths ...string) *Builder { for _, p := range paths { _, err := os.Stat(p) if os.IsNotExist(err) { @@ -346,7 +344,7 @@ func (b *Builder) Path(recursive, enableKustomization bool, paths ...string) *Bu continue } - visitors, err := ExpandPathsToFileVisitors(b.mapper, p, recursive, enableKustomization, FileExtensions, b.schema) + visitors, err := ExpandPathsToFileVisitors(b.mapper, p, recursive, FileExtensions, b.schema) if err != nil { b.errs = append(b.errs, fmt.Errorf("error reading %q: %v", p, err)) } diff --git a/staging/src/k8s.io/cli-runtime/pkg/genericclioptions/resource/builder_test.go b/staging/src/k8s.io/cli-runtime/pkg/genericclioptions/resource/builder_test.go index b41d49580c1..801f13f7723 100644 --- a/staging/src/k8s.io/cli-runtime/pkg/genericclioptions/resource/builder_test.go +++ b/staging/src/k8s.io/cli-runtime/pkg/genericclioptions/resource/builder_test.go @@ -478,7 +478,7 @@ func TestDirectoryBuilder(t *testing.T) { for _, tt := range tests { b := newDefaultBuilder(). - FilenameParam(false, &FilenameOptions{Recursive: false, EnableKustomization: true, Filenames: tt.directories}). + FilenameParam(false, &FilenameOptions{Recursive: false, Filenames: tt.directories}). NamespaceParam("test").DefaultNamespace() test := &testVisitor{} diff --git a/staging/src/k8s.io/cli-runtime/pkg/genericclioptions/resource/visitor.go b/staging/src/k8s.io/cli-runtime/pkg/genericclioptions/resource/visitor.go index 1b21c38d394..15a9ff30728 100644 --- a/staging/src/k8s.io/cli-runtime/pkg/genericclioptions/resource/visitor.go +++ b/staging/src/k8s.io/cli-runtime/pkg/genericclioptions/resource/visitor.go @@ -451,13 +451,13 @@ func FileVisitorForSTDIN(mapper *mapper, schema ContentValidator) Visitor { // ExpandPathsToFileVisitors will return a slice of FileVisitors that will handle files from the provided path. // After FileVisitors open the files, they will pass an io.Reader to a StreamVisitor to do the reading. (stdin // is also taken care of). Paths argument also accepts a single file, and will return a single visitor -func ExpandPathsToFileVisitors(mapper *mapper, paths string, recursive bool, enableKustomize bool, extensions []string, schema ContentValidator) ([]Visitor, error) { +func ExpandPathsToFileVisitors(mapper *mapper, paths string, recursive bool, extensions []string, schema ContentValidator) ([]Visitor, error) { var visitors []Visitor err := filepath.Walk(paths, func(path string, fi os.FileInfo, err error) error { if err != nil { return err } - if enableKustomize && isKustomizationDir(path) { + if isKustomizationDir(path) { visitors = append(visitors, NewKustomizationVisitor(mapper, path, schema)) return filepath.SkipDir } @@ -471,7 +471,7 @@ func ExpandPathsToFileVisitors(mapper *mapper, paths string, recursive bool, ena if path != paths && ignoreFile(path, extensions) { return nil } - if enableKustomize && filepath.Base(path) == constants.KustomizationFileName { + if filepath.Base(path) == constants.KustomizationFileName { visitors = append(visitors, NewKustomizationVisitor(mapper, filepath.Dir(path), schema)) return nil }