diff --git a/staging/src/k8s.io/kubectl/pkg/cmd/apply/apply.go b/staging/src/k8s.io/kubectl/pkg/cmd/apply/apply.go index 88fe07c210f..68d21e968ff 100644 --- a/staging/src/k8s.io/kubectl/pkg/cmd/apply/apply.go +++ b/staging/src/k8s.io/kubectl/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/staging/src/k8s.io/kubectl/pkg/cmd/diff/diff.go b/staging/src/k8s.io/kubectl/pkg/cmd/diff/diff.go index e22c6fa9f99..2afa6b17e9b 100644 --- a/staging/src/k8s.io/kubectl/pkg/cmd/diff/diff.go +++ b/staging/src/k8s.io/kubectl/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/staging/src/k8s.io/kubectl/pkg/cmd/util/helpers.go b/staging/src/k8s.io/kubectl/pkg/cmd/util/helpers.go index 6d38fade3e7..fe45d118563 100644 --- a/staging/src/k8s.io/kubectl/pkg/cmd/util/helpers.go +++ b/staging/src/k8s.io/kubectl/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/staging/src/k8s.io/kubectl/pkg/util/i18n/translations/kubectl/de_DE/LC_MESSAGES/k8s.po b/staging/src/k8s.io/kubectl/pkg/util/i18n/translations/kubectl/de_DE/LC_MESSAGES/k8s.po index cd5d53c888f..18b6a6215e0 100644 --- a/staging/src/k8s.io/kubectl/pkg/util/i18n/translations/kubectl/de_DE/LC_MESSAGES/k8s.po +++ b/staging/src/k8s.io/kubectl/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/staging/src/k8s.io/kubectl/pkg/util/i18n/translations/kubectl/default/LC_MESSAGES/k8s.po b/staging/src/k8s.io/kubectl/pkg/util/i18n/translations/kubectl/default/LC_MESSAGES/k8s.po index 538c7b2d58c..609c85d7cee 100644 --- a/staging/src/k8s.io/kubectl/pkg/util/i18n/translations/kubectl/default/LC_MESSAGES/k8s.po +++ b/staging/src/k8s.io/kubectl/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/staging/src/k8s.io/kubectl/pkg/util/i18n/translations/kubectl/en_US/LC_MESSAGES/k8s.po b/staging/src/k8s.io/kubectl/pkg/util/i18n/translations/kubectl/en_US/LC_MESSAGES/k8s.po index d07da117b24..c4f0e403f9c 100644 --- a/staging/src/k8s.io/kubectl/pkg/util/i18n/translations/kubectl/en_US/LC_MESSAGES/k8s.po +++ b/staging/src/k8s.io/kubectl/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/staging/src/k8s.io/kubectl/pkg/util/i18n/translations/kubectl/it_IT/LC_MESSAGES/k8s.po b/staging/src/k8s.io/kubectl/pkg/util/i18n/translations/kubectl/it_IT/LC_MESSAGES/k8s.po index ca119f64f41..ff6d83262f6 100644 --- a/staging/src/k8s.io/kubectl/pkg/util/i18n/translations/kubectl/it_IT/LC_MESSAGES/k8s.po +++ b/staging/src/k8s.io/kubectl/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/staging/src/k8s.io/kubectl/pkg/util/i18n/translations/kubectl/ja_JP/LC_MESSAGES/k8s.po b/staging/src/k8s.io/kubectl/pkg/util/i18n/translations/kubectl/ja_JP/LC_MESSAGES/k8s.po index d6f4aa2c4b2..7036ad59aab 100644 --- a/staging/src/k8s.io/kubectl/pkg/util/i18n/translations/kubectl/ja_JP/LC_MESSAGES/k8s.po +++ b/staging/src/k8s.io/kubectl/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/staging/src/k8s.io/kubectl/pkg/util/i18n/translations/kubectl/pt_BR/LC_MESSAGES/k8s.po b/staging/src/k8s.io/kubectl/pkg/util/i18n/translations/kubectl/pt_BR/LC_MESSAGES/k8s.po index dad451281f0..7fe6d2cf17f 100644 --- a/staging/src/k8s.io/kubectl/pkg/util/i18n/translations/kubectl/pt_BR/LC_MESSAGES/k8s.po +++ b/staging/src/k8s.io/kubectl/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/staging/src/k8s.io/kubectl/pkg/util/i18n/translations/kubectl/zh_CN/LC_MESSAGES/k8s.po b/staging/src/k8s.io/kubectl/pkg/util/i18n/translations/kubectl/zh_CN/LC_MESSAGES/k8s.po index 29bd5844d56..ffdf03cb6dc 100644 --- a/staging/src/k8s.io/kubectl/pkg/util/i18n/translations/kubectl/zh_CN/LC_MESSAGES/k8s.po +++ b/staging/src/k8s.io/kubectl/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 diff --git a/test/cmd/apply.sh b/test/cmd/apply.sh index 0b2878d978b..de690e61c9d 100755 --- a/test/cmd/apply.sh +++ b/test/cmd/apply.sh @@ -231,18 +231,18 @@ __EOF__ kube::test::get_object_assert pods "{{range.items}}{{${id_field:?}}}:{{end}}" '' kubectl delete pvc b-pvc 2>&1 "${kube_flags[@]:?}" - ## kubectl apply --prune --prune-whitelist + ## kubectl apply --prune --prune-allowlist # Pre-Condition: no POD exists kube::test::get_object_assert pods "{{range.items}}{{${id_field:?}}}:{{end}}" '' # apply pod a kubectl apply --prune -l prune-group=true -f hack/testdata/prune/a.yaml "${kube_flags[@]:?}" # check right pod exists kube::test::get_object_assert 'pods a' "{{${id_field:?}}}" 'a' - # apply svc and don't prune pod a by overwriting whitelist - kubectl apply --prune -l prune-group=true -f hack/testdata/prune/svc.yaml --prune-whitelist core/v1/Service 2>&1 "${kube_flags[@]:?}" + # apply svc and don't prune pod a by overwriting allowlist + kubectl apply --prune -l prune-group=true -f hack/testdata/prune/svc.yaml --prune-allowlist core/v1/Service 2>&1 "${kube_flags[@]:?}" kube::test::get_object_assert 'service prune-svc' "{{${id_field:?}}}" 'prune-svc' kube::test::get_object_assert 'pods a' "{{${id_field:?}}}" 'a' - # apply svc and prune pod a with default whitelist + # apply svc and prune pod a with default allowlist kubectl apply --prune -l prune-group=true -f hack/testdata/prune/svc.yaml 2>&1 "${kube_flags[@]:?}" kube::test::get_object_assert 'service prune-svc' "{{${id_field:?}}}" 'prune-svc' kube::test::get_object_assert pods "{{range.items}}{{${id_field:?}}}:{{end}}" '' diff --git a/test/cmd/crd.sh b/test/cmd/crd.sh index bbb3b4b7e19..5e10c2af9a4 100755 --- a/test/cmd/crd.sh +++ b/test/cmd/crd.sh @@ -500,13 +500,13 @@ run_non_native_resource_tests() { kube::test::get_object_assert bars "{{range.items}}{{$id_field}}:{{end}}" '' # apply --prune on foo.yaml that has foo/test - kubectl apply --prune -l pruneGroup=true -f hack/testdata/CRD/foo.yaml "${kube_flags[@]}" --prune-whitelist=company.com/v1/Foo --prune-whitelist=company.com/v1/Bar + kubectl apply --prune -l pruneGroup=true -f hack/testdata/CRD/foo.yaml "${kube_flags[@]}" --prune-allowlist=company.com/v1/Foo --prune-allowlist=company.com/v1/Bar # check right crds exist kube::test::get_object_assert foos "{{range.items}}{{$id_field}}:{{end}}" 'test:' kube::test::get_object_assert bars "{{range.items}}{{$id_field}}:{{end}}" '' # apply --prune on bar.yaml that has bar/test - kubectl apply --prune -l pruneGroup=true -f hack/testdata/CRD/bar.yaml "${kube_flags[@]}" --prune-whitelist=company.com/v1/Foo --prune-whitelist=company.com/v1/Bar + kubectl apply --prune -l pruneGroup=true -f hack/testdata/CRD/bar.yaml "${kube_flags[@]}" --prune-allowlist=company.com/v1/Foo --prune-allowlist=company.com/v1/Bar # check right crds exist kube::test::wait_object_assert foos "{{range.items}}{{$id_field}}:{{end}}" '' kube::test::get_object_assert bars "{{range.items}}{{$id_field}}:{{end}}" 'test:'