From 4afdc439d14d0ae3df5dc61c16441a4ecfebb17a Mon Sep 17 00:00:00 2001 From: yulng Date: Wed, 5 Jul 2023 11:38:20 +0800 Subject: [PATCH] remove PruneWhitelist, use prune-allowlist instead Signed-off-by: yulng Signed-off-by: Paco Xu Kubernetes-commit: 06679402e75d001d54770c9ec67cacbf28794009 --- pkg/cmd/apply/apply.go | 9 ++------- pkg/cmd/diff/diff.go | 2 +- pkg/cmd/util/helpers.go | 4 +--- .../i18n/translations/kubectl/de_DE/LC_MESSAGES/k8s.po | 4 ++-- .../i18n/translations/kubectl/default/LC_MESSAGES/k8s.po | 4 ++-- .../i18n/translations/kubectl/en_US/LC_MESSAGES/k8s.po | 4 ++-- .../i18n/translations/kubectl/it_IT/LC_MESSAGES/k8s.po | 4 ++-- .../i18n/translations/kubectl/ja_JP/LC_MESSAGES/k8s.po | 4 ++-- .../i18n/translations/kubectl/pt_BR/LC_MESSAGES/k8s.po | 4 ++-- .../i18n/translations/kubectl/zh_CN/LC_MESSAGES/k8s.po | 4 ++-- 10 files changed, 18 insertions(+), 25 deletions(-) diff --git a/pkg/cmd/apply/apply.go b/pkg/cmd/apply/apply.go index 88fe07c21..68d21e968 100644 --- a/pkg/cmd/apply/apply.go +++ b/pkg/cmd/apply/apply.go @@ -50,7 +50,6 @@ import ( "k8s.io/kubectl/pkg/util/i18n" "k8s.io/kubectl/pkg/util/openapi" "k8s.io/kubectl/pkg/util/prune" - "k8s.io/kubectl/pkg/util/slice" "k8s.io/kubectl/pkg/util/templates" "k8s.io/kubectl/pkg/validation" ) @@ -73,8 +72,6 @@ type ApplyFlags struct { Overwrite bool OpenAPIPatch bool - // DEPRECATED: Use PruneAllowlist instead - PruneWhitelist []string // TODO: Remove this in kubectl 1.28 or later PruneAllowlist []string genericiooptions.IOStreams @@ -235,8 +232,7 @@ func (flags *ApplyFlags) AddFlags(cmd *cobra.Command) { cmdutil.AddServerSideApplyFlags(cmd) cmdutil.AddFieldManagerFlagVar(cmd, &flags.FieldManager, FieldManagerClientSideApply) cmdutil.AddLabelSelectorFlagVar(cmd, &flags.Selector) - cmdutil.AddPruningFlags(cmd, &flags.Prune, &flags.PruneAllowlist, &flags.PruneWhitelist, &flags.All, &flags.ApplySetRef) - + cmdutil.AddPruningFlags(cmd, &flags.Prune, &flags.PruneAllowlist, &flags.All, &flags.ApplySetRef) cmd.Flags().BoolVar(&flags.Overwrite, "overwrite", flags.Overwrite, "Automatically resolve conflicts between the modified and live configuration by using values from the modified configuration") cmd.Flags().BoolVar(&flags.OpenAPIPatch, "openapi-patch", flags.OpenAPIPatch, "If true, use openapi to calculate diff when the openapi presents and the resource can be found in the openapi spec. Otherwise, fall back to use baked-in types.") } @@ -335,8 +331,7 @@ func (flags *ApplyFlags) ToOptions(f cmdutil.Factory, cmd *cobra.Command, baseNa applySet = NewApplySet(parent, tooling, mapper, restClient) } if flags.Prune { - pruneAllowlist := slice.ToSet(flags.PruneAllowlist, flags.PruneWhitelist) - flags.PruneResources, err = prune.ParseResources(mapper, pruneAllowlist) + flags.PruneResources, err = prune.ParseResources(mapper, flags.PruneAllowlist) if err != nil { return nil, err } diff --git a/pkg/cmd/diff/diff.go b/pkg/cmd/diff/diff.go index e22c6fa9f..2afa6b17e 100644 --- a/pkg/cmd/diff/diff.go +++ b/pkg/cmd/diff/diff.go @@ -166,7 +166,7 @@ func NewCmdDiff(f cmdutil.Factory, streams genericiooptions.IOStreams) *cobra.Co }) usage := "contains the configuration to diff" - cmd.Flags().StringArray("prune-allowlist", []string{}, "Overwrite the default whitelist with for --prune") + cmd.Flags().StringArray("prune-allowlist", []string{}, "Overwrite the default allowlist with for --prune") cmd.Flags().Bool("prune", false, "Include resources that would be deleted by pruning. Can be used with -l and default shows all resources would be pruned") cmd.Flags().BoolVar(&options.ShowManagedFields, "show-managed-fields", options.ShowManagedFields, "If true, include managed fields in the diff.") cmd.Flags().IntVar(&options.Concurrency, "concurrency", 1, "Number of objects to process in parallel when diffing against the live version. Larger number = faster, but more memory, I/O and CPU over that shorter period of time.") diff --git a/pkg/cmd/util/helpers.go b/pkg/cmd/util/helpers.go index 6d38fade3..fe45d1185 100644 --- a/pkg/cmd/util/helpers.go +++ b/pkg/cmd/util/helpers.go @@ -523,11 +523,9 @@ func AddLabelSelectorFlagVar(cmd *cobra.Command, p *string) { cmd.Flags().StringVarP(p, "selector", "l", *p, "Selector (label query) to filter on, supports '=', '==', and '!='.(e.g. -l key1=value1,key2=value2). Matching objects must satisfy all of the specified label constraints.") } -func AddPruningFlags(cmd *cobra.Command, prune *bool, pruneAllowlist *[]string, pruneWhitelist *[]string, all *bool, applySetRef *string) { +func AddPruningFlags(cmd *cobra.Command, prune *bool, pruneAllowlist *[]string, all *bool, applySetRef *string) { // Flags associated with the original allowlist-based alpha cmd.Flags().StringArrayVar(pruneAllowlist, "prune-allowlist", *pruneAllowlist, "Overwrite the default allowlist with for --prune") - cmd.Flags().StringArrayVar(pruneWhitelist, "prune-whitelist", *pruneWhitelist, "Overwrite the default whitelist with for --prune") // TODO: Remove this in kubectl 1.28 or later - _ = cmd.Flags().MarkDeprecated("prune-whitelist", "Use --prune-allowlist instead.") cmd.Flags().BoolVar(all, "all", *all, "Select all resources in the namespace of the specified resource types.") // Flags associated with the new ApplySet-based alpha diff --git a/pkg/util/i18n/translations/kubectl/de_DE/LC_MESSAGES/k8s.po b/pkg/util/i18n/translations/kubectl/de_DE/LC_MESSAGES/k8s.po index cd5d53c88..18b6a6215 100644 --- a/pkg/util/i18n/translations/kubectl/de_DE/LC_MESSAGES/k8s.po +++ b/pkg/util/i18n/translations/kubectl/de_DE/LC_MESSAGES/k8s.po @@ -736,7 +736,7 @@ msgstr "kubectl kontrolliert den Kubernetes-Cluster-Manager" #~ "\n" #~ "\t\t# Apply the configuration in manifest.yaml and delete all the other " #~ "configmaps that are not in the file.\n" -#~ "\t\tkubectl apply --prune -f manifest.yaml --all --prune-whitelist=core/" +#~ "\t\tkubectl apply --prune -f manifest.yaml --all --prune-allowlist=core/" #~ "v1/ConfigMap" #~ msgstr "" #~ "\n" @@ -754,7 +754,7 @@ msgstr "kubectl kontrolliert den Kubernetes-Cluster-Manager" #~ "\n" #~ "\t\t# Wende die Konfiguration im manifest.yaml an und lösche alle " #~ "ConfigMaps, die nicht in der Datei sind.\n" -#~ "\t\tkubectl apply --prune -f manifest.yaml --all --prune-whitelist=core/" +#~ "\t\tkubectl apply --prune -f manifest.yaml --all --prune-allowlist=core/" #~ "v1/ConfigMap" #, c-format diff --git a/pkg/util/i18n/translations/kubectl/default/LC_MESSAGES/k8s.po b/pkg/util/i18n/translations/kubectl/default/LC_MESSAGES/k8s.po index 538c7b2d5..609c85d7c 100644 --- a/pkg/util/i18n/translations/kubectl/default/LC_MESSAGES/k8s.po +++ b/pkg/util/i18n/translations/kubectl/default/LC_MESSAGES/k8s.po @@ -260,7 +260,7 @@ msgid "" "\n" "\t\t# Apply the configuration in manifest.yaml and delete all the other " "config maps that are not in the file\n" -"\t\tkubectl apply --prune -f manifest.yaml --all --prune-whitelist=core/v1/" +"\t\tkubectl apply --prune -f manifest.yaml --all --prune-allowlist=core/v1/" "ConfigMap" msgstr "" "\n" @@ -282,7 +282,7 @@ msgstr "" "\n" "\t\t# Apply the configuration in manifest.yaml and delete all the other " "config maps that are not in the file\n" -"\t\tkubectl apply --prune -f manifest.yaml --all --prune-whitelist=core/v1/" +"\t\tkubectl apply --prune -f manifest.yaml --all --prune-allowlist=core/v1/" "ConfigMap" #: staging/src/k8s.io/kubectl/pkg/cmd/autoscale/autoscale.go:48 diff --git a/pkg/util/i18n/translations/kubectl/en_US/LC_MESSAGES/k8s.po b/pkg/util/i18n/translations/kubectl/en_US/LC_MESSAGES/k8s.po index d07da117b..c4f0e403f 100644 --- a/pkg/util/i18n/translations/kubectl/en_US/LC_MESSAGES/k8s.po +++ b/pkg/util/i18n/translations/kubectl/en_US/LC_MESSAGES/k8s.po @@ -260,7 +260,7 @@ msgid "" "\n" "\t\t# Apply the configuration in manifest.yaml and delete all the other " "config maps that are not in the file\n" -"\t\tkubectl apply --prune -f manifest.yaml --all --prune-whitelist=core/v1/" +"\t\tkubectl apply --prune -f manifest.yaml --all --prune-allowlist=core/v1/" "ConfigMap" msgstr "" "\n" @@ -282,7 +282,7 @@ msgstr "" "\n" "\t\t# Apply the configuration in manifest.yaml and delete all the other " "config maps that are not in the file\n" -"\t\tkubectl apply --prune -f manifest.yaml --all --prune-whitelist=core/v1/" +"\t\tkubectl apply --prune -f manifest.yaml --all --prune-allowlist=core/v1/" "ConfigMap" #: staging/src/k8s.io/kubectl/pkg/cmd/autoscale/autoscale.go:48 diff --git a/pkg/util/i18n/translations/kubectl/it_IT/LC_MESSAGES/k8s.po b/pkg/util/i18n/translations/kubectl/it_IT/LC_MESSAGES/k8s.po index ca119f64f..ff6d83262 100644 --- a/pkg/util/i18n/translations/kubectl/it_IT/LC_MESSAGES/k8s.po +++ b/pkg/util/i18n/translations/kubectl/it_IT/LC_MESSAGES/k8s.po @@ -815,7 +815,7 @@ msgstr "Kubectl controlla il gestore cluster di Kubernetes" #~ "\n" #~ "\t\t# Apply the configuration in manifest.yaml and delete all the other " #~ "configmaps that are not in the file.\n" -#~ "\t\tkubectl apply --prune -f manifest.yaml --all --prune-whitelist=core/" +#~ "\t\tkubectl apply --prune -f manifest.yaml --all --prune-allowlist=core/" #~ "v1/ConfigMap" #~ msgstr "" #~ "\n" @@ -833,7 +833,7 @@ msgstr "Kubectl controlla il gestore cluster di Kubernetes" #~ "\n" #~ "\t\t# Applica la configurazione manifest.yaml ed elimina tutti gli altri " #~ "configmaps non presenti nel file.\n" -#~ "\t\tkubectl apply --prune -f manifest.yaml --all --prune-whitelist=core/" +#~ "\t\tkubectl apply --prune -f manifest.yaml --all --prune-allowlist=core/" #~ "v1/ConfigMap" #, c-format diff --git a/pkg/util/i18n/translations/kubectl/ja_JP/LC_MESSAGES/k8s.po b/pkg/util/i18n/translations/kubectl/ja_JP/LC_MESSAGES/k8s.po index d6f4aa2c4..7036ad59a 100644 --- a/pkg/util/i18n/translations/kubectl/ja_JP/LC_MESSAGES/k8s.po +++ b/pkg/util/i18n/translations/kubectl/ja_JP/LC_MESSAGES/k8s.po @@ -891,7 +891,7 @@ msgstr "kubectl controls the Kubernetes cluster manager" #~ "\n" #~ "\t\t# Apply the configuration in manifest.yaml and delete all the other " #~ "configmaps that are not in the file.\n" -#~ "\t\tkubectl apply --prune -f manifest.yaml --all --prune-whitelist=core/" +#~ "\t\tkubectl apply --prune -f manifest.yaml --all --prune-allowlist=core/" #~ "v1/ConfigMap" #~ msgstr "" #~ "\n" @@ -909,7 +909,7 @@ msgstr "kubectl controls the Kubernetes cluster manager" #~ "\n" #~ "\t\t# Apply the configuration in manifest.yaml and delete all the other " #~ "configmaps that are not in the file.\n" -#~ "\t\tkubectl apply --prune -f manifest.yaml --all --prune-whitelist=core/" +#~ "\t\tkubectl apply --prune -f manifest.yaml --all --prune-allowlist=core/" #~ "v1/ConfigMap" #, c-format diff --git a/pkg/util/i18n/translations/kubectl/pt_BR/LC_MESSAGES/k8s.po b/pkg/util/i18n/translations/kubectl/pt_BR/LC_MESSAGES/k8s.po index dad451281..7fe6d2cf1 100644 --- a/pkg/util/i18n/translations/kubectl/pt_BR/LC_MESSAGES/k8s.po +++ b/pkg/util/i18n/translations/kubectl/pt_BR/LC_MESSAGES/k8s.po @@ -814,7 +814,7 @@ msgstr "kubectl controla o gerenciador de cluster do Kubernetes" #~ "\n" #~ "\t\t# Apply the configuration in manifest.yaml and delete all the other " #~ "configmaps that are not in the file.\n" -#~ "\t\tkubectl apply --prune -f manifest.yaml --all --prune-whitelist=core/" +#~ "\t\tkubectl apply --prune -f manifest.yaml --all --prune-allowlist=core/" #~ "v1/ConfigMap" #~ msgstr "" #~ "\n" @@ -832,7 +832,7 @@ msgstr "kubectl controla o gerenciador de cluster do Kubernetes" #~ "\n" #~ "\t\t# Aplica a configuração do manifest.yaml e remove todos os outros " #~ "configmaps que não estão no arquivo.\n" -#~ "\t\tkubectl apply —prune -f manifest.yaml —all —prune-whitelist=core/v1/" +#~ "\t\tkubectl apply —prune -f manifest.yaml —all —prune-allowlist=core/v1/" #~ "ConfigMap" #, c-format diff --git a/pkg/util/i18n/translations/kubectl/zh_CN/LC_MESSAGES/k8s.po b/pkg/util/i18n/translations/kubectl/zh_CN/LC_MESSAGES/k8s.po index 29bd5844d..ffdf03cb6 100644 --- a/pkg/util/i18n/translations/kubectl/zh_CN/LC_MESSAGES/k8s.po +++ b/pkg/util/i18n/translations/kubectl/zh_CN/LC_MESSAGES/k8s.po @@ -854,7 +854,7 @@ msgstr "kubectl 控制 Kubernetes 集群管理器" #~ "\n" #~ "\t\t# Apply the configuration in manifest.yaml and delete all the other " #~ "configmaps that are not in the file.\n" -#~ "\t\tkubectl apply --prune -f manifest.yaml --all --prune-whitelist=core/v1/" +#~ "\t\tkubectl apply --prune -f manifest.yaml --all --prune-allowlist=core/v1/" #~ "ConfigMap" #~ msgstr "" #~ "\n" @@ -870,7 +870,7 @@ msgstr "kubectl 控制 Kubernetes 集群管理器" #~ "\t\tkubectl apply --prune -f manifest.yaml -l app=nginx\n" #~ "\n" #~ "\t\t# 应用 manifest.yaml 的配置并删除所有不在这个文件中的 ConfigMaps。\n" -#~ "\t\tkubectl apply --prune -f manifest.yaml --all --prune-whitelist=core/v1/" +#~ "\t\tkubectl apply --prune -f manifest.yaml --all --prune-allowlist=core/v1/" #~ "ConfigMap" #, c-format