mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-04 23:17:50 +00:00
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:
@@ -39,6 +39,7 @@ import (
|
||||
// referencing the cmd.Flags()
|
||||
type LabelOptions struct {
|
||||
Filenames []string
|
||||
Recursive bool
|
||||
}
|
||||
|
||||
const (
|
||||
@@ -96,6 +97,7 @@ func NewCmdLabel(f *cmdutil.Factory, out io.Writer) *cobra.Command {
|
||||
cmd.Flags().String("resource-version", "", "If non-empty, the labels 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 labels"
|
||||
kubectl.AddJsonFilenameFlag(cmd, &options.Filenames, usage)
|
||||
cmdutil.AddRecursiveFlag(cmd, &options.Recursive)
|
||||
cmd.Flags().Bool("dry-run", false, "If true, only print the object that would be sent, without sending it.")
|
||||
cmdutil.AddRecordFlag(cmd)
|
||||
|
||||
@@ -203,10 +205,11 @@ func RunLabel(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []stri
|
||||
return cmdutil.UsageError(cmd, err.Error())
|
||||
}
|
||||
mapper, typer := f.Object()
|
||||
|
||||
b := resource.NewBuilder(mapper, typer, resource.ClientMapperFunc(f.ClientForMapping), f.Decoder(true)).
|
||||
ContinueOnError().
|
||||
NamespaceParam(cmdNamespace).DefaultNamespace().
|
||||
FilenameParam(enforceNamespace, options.Filenames...).
|
||||
FilenameParam(enforceNamespace, options.Recursive, options.Filenames...).
|
||||
SelectorParam(selector).
|
||||
ResourceTypeOrNameArgs(all, resources...).
|
||||
Flatten().
|
||||
|
||||
Reference in New Issue
Block a user