allow kubectl cmd to process dirs recursively

reqs:
    - the kubectl cmd must support the -f | --filename flag
    - the kubectl cmd must support visiting a dir one level deep,
    or using more than one resource
This commit is contained in:
Mike Metral
2016-03-28 12:44:21 -07:00
parent e01feae75a
commit 7403878ac0
61 changed files with 438 additions and 82 deletions

View File

@@ -52,6 +52,8 @@ type AnnotateOptions struct {
f *cmdutil.Factory
out io.Writer
cmd *cobra.Command
recursive bool
}
const (
@@ -114,6 +116,7 @@ func NewCmdAnnotate(f *cmdutil.Factory, out io.Writer) *cobra.Command {
cmd.Flags().StringVar(&options.resourceVersion, "resource-version", "", "If non-empty, the annotation update will only succeed if this is the current resource-version for the object. Only valid when specifying a single resource.")
usage := "Filename, directory, or URL to a file identifying the resource to update the annotation"
kubectl.AddJsonFilenameFlag(cmd, &options.filenames, usage)
cmdutil.AddRecursiveFlag(cmd, &options.recursive)
cmdutil.AddRecordFlag(cmd)
return cmd
}
@@ -162,7 +165,7 @@ func (o *AnnotateOptions) Complete(f *cmdutil.Factory, out io.Writer, cmd *cobra
o.builder = resource.NewBuilder(mapper, typer, resource.ClientMapperFunc(f.ClientForMapping), f.Decoder(true)).
ContinueOnError().
NamespaceParam(namespace).DefaultNamespace().
FilenameParam(enforceNamespace, o.filenames...).
FilenameParam(enforceNamespace, o.recursive, o.filenames...).
SelectorParam(o.selector).
ResourceTypeOrNameArgs(o.all, o.resources...).
Flatten().