remove the opt out choice of kustomize

This commit is contained in:
Jingfang Liu 2018-12-17 14:52:07 -08:00
parent 0ce8427b46
commit ac209ccdc0
5 changed files with 9 additions and 13 deletions

View File

@ -90,7 +90,6 @@ func (f *DeleteFlags) ToOptions(dynamicClient dynamic.Interface, streams generic
options.WaitForDeletion = *f.Wait
}
options.FilenameOptions.EnableKustomization = true
return options
}

View File

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

View File

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

View File

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

View File

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