mirror of
https://github.com/optim-enterprises-bv/kubernetes.git
synced 2025-11-01 18:58:18 +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:
@@ -35,6 +35,7 @@ import (
|
||||
// referencing the cmd.Flags()
|
||||
type DeleteOptions struct {
|
||||
Filenames []string
|
||||
Recursive bool
|
||||
}
|
||||
|
||||
const (
|
||||
@@ -91,6 +92,7 @@ func NewCmdDelete(f *cmdutil.Factory, out io.Writer) *cobra.Command {
|
||||
}
|
||||
usage := "Filename, directory, or URL to a file containing the resource to delete."
|
||||
kubectl.AddJsonFilenameFlag(cmd, &options.Filenames, usage)
|
||||
cmdutil.AddRecursiveFlag(cmd, &options.Recursive)
|
||||
cmd.Flags().StringP("selector", "l", "", "Selector (label query) to filter on.")
|
||||
cmd.Flags().Bool("all", false, "[-all] to select all the specified resources.")
|
||||
cmd.Flags().Bool("ignore-not-found", false, "Treat \"resource not found\" as a successful delete. Defaults to \"true\" when --all is specified.")
|
||||
@@ -111,7 +113,7 @@ func RunDelete(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []str
|
||||
r := 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(cmdutil.GetFlagString(cmd, "selector")).
|
||||
SelectAllParam(deleteAll).
|
||||
ResourceTypeOrNameArgs(false, args...).RequireObject(false).
|
||||
|
||||
Reference in New Issue
Block a user