From 7e681490ec30a64626b359b7346d891240155794 Mon Sep 17 00:00:00 2001 From: Kevin Delgado Date: Wed, 9 Mar 2022 14:51:50 +0000 Subject: [PATCH] Generalize dry run verify to arbitrary query param Kubernetes-commit: d6c83281bc696474a76365a879f2255b8b568786 --- pkg/cmd/annotate/annotate.go | 4 ++-- pkg/cmd/apply/apply.go | 4 ++-- pkg/cmd/apply/apply_set_last_applied.go | 4 ++-- pkg/cmd/autoscale/autoscale.go | 4 ++-- pkg/cmd/create/create.go | 8 ++++---- pkg/cmd/create/create_clusterrolebinding.go | 4 ++-- pkg/cmd/create/create_configmap.go | 5 ++--- pkg/cmd/create/create_cronjob.go | 4 ++-- pkg/cmd/create/create_deployment.go | 4 ++-- pkg/cmd/create/create_ingress.go | 4 ++-- pkg/cmd/create/create_job.go | 4 ++-- pkg/cmd/create/create_namespace.go | 5 +++-- pkg/cmd/create/create_pdb.go | 5 +++-- pkg/cmd/create/create_priorityclass.go | 4 ++-- pkg/cmd/create/create_quota.go | 5 +++-- pkg/cmd/create/create_role.go | 4 ++-- pkg/cmd/create/create_rolebinding.go | 6 +++--- pkg/cmd/create/create_secret.go | 4 ++-- pkg/cmd/create/create_secret_docker.go | 4 ++-- pkg/cmd/create/create_secret_tls.go | 4 ++-- pkg/cmd/create/create_service.go | 4 ++-- pkg/cmd/create/create_serviceaccount.go | 4 ++-- pkg/cmd/delete/delete.go | 4 ++-- pkg/cmd/diff/diff.go | 4 ++-- pkg/cmd/drain/drain.go | 2 +- pkg/cmd/expose/expose.go | 4 ++-- pkg/cmd/label/label.go | 4 ++-- pkg/cmd/patch/patch.go | 4 ++-- pkg/cmd/replace/replace.go | 4 ++-- pkg/cmd/rollout/rollout_undo.go | 4 ++-- pkg/cmd/run/run.go | 4 ++-- pkg/cmd/scale/scale.go | 4 ++-- pkg/cmd/set/set_env.go | 4 ++-- pkg/cmd/set/set_image.go | 4 ++-- pkg/cmd/set/set_resources.go | 4 ++-- pkg/cmd/set/set_selector.go | 4 ++-- pkg/cmd/set/set_serviceaccount.go | 4 ++-- pkg/cmd/set/set_subject.go | 4 ++-- pkg/cmd/taint/taint.go | 4 ++-- pkg/drain/drain.go | 2 +- 40 files changed, 84 insertions(+), 82 deletions(-) diff --git a/pkg/cmd/annotate/annotate.go b/pkg/cmd/annotate/annotate.go index be4678b29..9ebfd97da 100644 --- a/pkg/cmd/annotate/annotate.go +++ b/pkg/cmd/annotate/annotate.go @@ -57,7 +57,7 @@ type AnnotateOptions struct { list bool local bool dryRunStrategy cmdutil.DryRunStrategy - dryRunVerifier *resource.DryRunVerifier + dryRunVerifier *resource.QueryParamVerifier fieldManager string all bool allNamespaces bool @@ -182,7 +182,7 @@ func (o *AnnotateOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args [ if err != nil { return err } - o.dryRunVerifier = resource.NewDryRunVerifier(dynamicClient, f.OpenAPIGetter()) + o.dryRunVerifier = resource.NewQueryParamVerifier(dynamicClient, f.OpenAPIGetter(), resource.QueryParamDryRun) cmdutil.PrintFlagsWithDryRunStrategy(o.PrintFlags, o.dryRunStrategy) printer, err := o.PrintFlags.ToPrinter() diff --git a/pkg/cmd/apply/apply.go b/pkg/cmd/apply/apply.go index aba4cd388..ccffc4012 100644 --- a/pkg/cmd/apply/apply.go +++ b/pkg/cmd/apply/apply.go @@ -85,7 +85,7 @@ type ApplyOptions struct { FieldManager string Selector string DryRunStrategy cmdutil.DryRunStrategy - DryRunVerifier *resource.DryRunVerifier + DryRunVerifier *resource.QueryParamVerifier Prune bool PruneResources []prune.Resource cmdBaseName string @@ -237,7 +237,7 @@ func (flags *ApplyFlags) ToOptions(cmd *cobra.Command, baseName string, args []s return nil, err } - dryRunVerifier := resource.NewDryRunVerifier(dynamicClient, flags.Factory.OpenAPIGetter()) + dryRunVerifier := resource.NewQueryParamVerifier(dynamicClient, flags.Factory.OpenAPIGetter(), resource.QueryParamDryRun) fieldManager := GetApplyFieldManagerFlag(cmd, serverSideApply) // allow for a success message operation to be specified at print time diff --git a/pkg/cmd/apply/apply_set_last_applied.go b/pkg/cmd/apply/apply_set_last_applied.go index 3bf097a78..86b49f490 100644 --- a/pkg/cmd/apply/apply_set_last_applied.go +++ b/pkg/cmd/apply/apply_set_last_applied.go @@ -50,7 +50,7 @@ type SetLastAppliedOptions struct { namespace string enforceNamespace bool dryRunStrategy cmdutil.DryRunStrategy - dryRunVerifier *resource.DryRunVerifier + dryRunVerifier *resource.QueryParamVerifier shortOutput bool output string patchBufferList []PatchBuffer @@ -128,7 +128,7 @@ func (o *SetLastAppliedOptions) Complete(f cmdutil.Factory, cmd *cobra.Command) if err != nil { return err } - o.dryRunVerifier = resource.NewDryRunVerifier(dynamicClient, f.OpenAPIGetter()) + o.dryRunVerifier = resource.NewQueryParamVerifier(dynamicClient, f.OpenAPIGetter(), resource.QueryParamDryRun) o.output = cmdutil.GetFlagString(cmd, "output") o.shortOutput = o.output == "name" diff --git a/pkg/cmd/autoscale/autoscale.go b/pkg/cmd/autoscale/autoscale.go index 4598cb478..72426a7d8 100644 --- a/pkg/cmd/autoscale/autoscale.go +++ b/pkg/cmd/autoscale/autoscale.go @@ -73,7 +73,7 @@ type AutoscaleOptions struct { enforceNamespace bool namespace string dryRunStrategy cmdutil.DryRunStrategy - dryRunVerifier *resource.DryRunVerifier + dryRunVerifier *resource.QueryParamVerifier builder *resource.Builder fieldManager string @@ -145,7 +145,7 @@ func (o *AutoscaleOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args if err != nil { return err } - o.dryRunVerifier = resource.NewDryRunVerifier(dynamicClient, f.OpenAPIGetter()) + o.dryRunVerifier = resource.NewQueryParamVerifier(dynamicClient, f.OpenAPIGetter(), resource.QueryParamDryRun) o.createAnnotation = cmdutil.GetFlagBool(cmd, cmdutil.ApplyAnnotationsFlag) o.builder = f.NewBuilder() o.scaleKindResolver = scale.NewDiscoveryScaleKindResolver(discoveryClient) diff --git a/pkg/cmd/create/create.go b/pkg/cmd/create/create.go index e45215cc9..f26e9a0a8 100644 --- a/pkg/cmd/create/create.go +++ b/pkg/cmd/create/create.go @@ -52,7 +52,7 @@ type CreateOptions struct { RecordFlags *genericclioptions.RecordFlags DryRunStrategy cmdutil.DryRunStrategy - DryRunVerifier *resource.DryRunVerifier + DryRunVerifier *resource.QueryParamVerifier fieldManager string @@ -207,7 +207,7 @@ func (o *CreateOptions) Complete(f cmdutil.Factory, cmd *cobra.Command) error { if err != nil { return err } - o.DryRunVerifier = resource.NewDryRunVerifier(dynamicClient, f.OpenAPIGetter()) + o.DryRunVerifier = resource.NewQueryParamVerifier(dynamicClient, f.OpenAPIGetter(), resource.QueryParamDryRun) printer, err := o.PrintFlags.ToPrinter() if err != nil { @@ -344,7 +344,7 @@ type CreateSubcommandOptions struct { // StructuredGenerator is the resource generator for the object being created StructuredGenerator generate.StructuredGenerator DryRunStrategy cmdutil.DryRunStrategy - DryRunVerifier *resource.DryRunVerifier + DryRunVerifier *resource.QueryParamVerifier CreateAnnotation bool FieldManager string @@ -384,7 +384,7 @@ func (o *CreateSubcommandOptions) Complete(f cmdutil.Factory, cmd *cobra.Command if err != nil { return err } - o.DryRunVerifier = resource.NewDryRunVerifier(dynamicClient, f.OpenAPIGetter()) + o.DryRunVerifier = resource.NewQueryParamVerifier(dynamicClient, f.OpenAPIGetter(), resource.QueryParamDryRun) o.CreateAnnotation = cmdutil.GetFlagBool(cmd, cmdutil.ApplyAnnotationsFlag) cmdutil.PrintFlagsWithDryRunStrategy(o.PrintFlags, o.DryRunStrategy) diff --git a/pkg/cmd/create/create_clusterrolebinding.go b/pkg/cmd/create/create_clusterrolebinding.go index ec5570817..1115f79d8 100644 --- a/pkg/cmd/create/create_clusterrolebinding.go +++ b/pkg/cmd/create/create_clusterrolebinding.go @@ -61,7 +61,7 @@ type ClusterRoleBindingOptions struct { Client rbacclientv1.RbacV1Interface DryRunStrategy cmdutil.DryRunStrategy - DryRunVerifier *resource.DryRunVerifier + DryRunVerifier *resource.QueryParamVerifier genericclioptions.IOStreams } @@ -139,7 +139,7 @@ func (o *ClusterRoleBindingOptions) Complete(f cmdutil.Factory, cmd *cobra.Comma if err != nil { return err } - o.DryRunVerifier = resource.NewDryRunVerifier(dynamicClient, f.OpenAPIGetter()) + o.DryRunVerifier = resource.NewQueryParamVerifier(dynamicClient, f.OpenAPIGetter(), resource.QueryParamDryRun) cmdutil.PrintFlagsWithDryRunStrategy(o.PrintFlags, o.DryRunStrategy) printer, err := o.PrintFlags.ToPrinter() diff --git a/pkg/cmd/create/create_configmap.go b/pkg/cmd/create/create_configmap.go index 5fba15e54..8d7837c92 100644 --- a/pkg/cmd/create/create_configmap.go +++ b/pkg/cmd/create/create_configmap.go @@ -98,7 +98,7 @@ type ConfigMapOptions struct { Client corev1client.CoreV1Interface DryRunStrategy cmdutil.DryRunStrategy - DryRunVerifier *resource.DryRunVerifier + DryRunVerifier *resource.QueryParamVerifier genericclioptions.IOStreams } @@ -173,13 +173,12 @@ func (o *ConfigMapOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args if err != nil { return err } - discoveryClient, err := f.ToDiscoveryClient() if err != nil { return err } - o.DryRunVerifier = resource.NewDryRunVerifier(dynamicClient, discoveryClient) + o.DryRunVerifier = resource.NewQueryParamVerifier(dynamicClient, discoveryClient, resource.QueryParamDryRun) o.Namespace, o.EnforceNamespace, err = f.ToRawKubeConfigLoader().Namespace() if err != nil { diff --git a/pkg/cmd/create/create_cronjob.go b/pkg/cmd/create/create_cronjob.go index da7500dc3..ba29705a0 100644 --- a/pkg/cmd/create/create_cronjob.go +++ b/pkg/cmd/create/create_cronjob.go @@ -64,7 +64,7 @@ type CreateCronJobOptions struct { EnforceNamespace bool Client batchv1client.BatchV1Interface DryRunStrategy cmdutil.DryRunStrategy - DryRunVerifier *resource.DryRunVerifier + DryRunVerifier *resource.QueryParamVerifier Builder *resource.Builder FieldManager string CreateAnnotation bool @@ -150,7 +150,7 @@ func (o *CreateCronJobOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, a if err != nil { return err } - o.DryRunVerifier = resource.NewDryRunVerifier(dynamicClient, f.OpenAPIGetter()) + o.DryRunVerifier = resource.NewQueryParamVerifier(dynamicClient, f.OpenAPIGetter(), resource.QueryParamDryRun) cmdutil.PrintFlagsWithDryRunStrategy(o.PrintFlags, o.DryRunStrategy) printer, err := o.PrintFlags.ToPrinter() if err != nil { diff --git a/pkg/cmd/create/create_deployment.go b/pkg/cmd/create/create_deployment.go index da3c70467..1b69cbc71 100644 --- a/pkg/cmd/create/create_deployment.go +++ b/pkg/cmd/create/create_deployment.go @@ -74,7 +74,7 @@ type CreateDeploymentOptions struct { Client appsv1client.AppsV1Interface DryRunStrategy cmdutil.DryRunStrategy - DryRunVerifier *resource.DryRunVerifier + DryRunVerifier *resource.QueryParamVerifier genericclioptions.IOStreams } @@ -156,7 +156,7 @@ func (o *CreateDeploymentOptions) Complete(f cmdutil.Factory, cmd *cobra.Command if err != nil { return err } - o.DryRunVerifier = resource.NewDryRunVerifier(dynamicClient, f.OpenAPIGetter()) + o.DryRunVerifier = resource.NewQueryParamVerifier(dynamicClient, f.OpenAPIGetter(), resource.QueryParamDryRun) cmdutil.PrintFlagsWithDryRunStrategy(o.PrintFlags, o.DryRunStrategy) printer, err := o.PrintFlags.ToPrinter() diff --git a/pkg/cmd/create/create_ingress.go b/pkg/cmd/create/create_ingress.go index bd6a5d2ff..3906a91a2 100644 --- a/pkg/cmd/create/create_ingress.go +++ b/pkg/cmd/create/create_ingress.go @@ -118,7 +118,7 @@ type CreateIngressOptions struct { Client networkingv1client.NetworkingV1Interface DryRunStrategy cmdutil.DryRunStrategy - DryRunVerifier *resource.DryRunVerifier + DryRunVerifier *resource.QueryParamVerifier FieldManager string @@ -198,7 +198,7 @@ func (o *CreateIngressOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, a if err != nil { return err } - o.DryRunVerifier = resource.NewDryRunVerifier(dynamicClient, f.OpenAPIGetter()) + o.DryRunVerifier = resource.NewQueryParamVerifier(dynamicClient, f.OpenAPIGetter(), resource.QueryParamDryRun) cmdutil.PrintFlagsWithDryRunStrategy(o.PrintFlags, o.DryRunStrategy) printer, err := o.PrintFlags.ToPrinter() diff --git a/pkg/cmd/create/create_job.go b/pkg/cmd/create/create_job.go index 44fd497a4..fbe686d45 100644 --- a/pkg/cmd/create/create_job.go +++ b/pkg/cmd/create/create_job.go @@ -66,7 +66,7 @@ type CreateJobOptions struct { EnforceNamespace bool Client batchv1client.BatchV1Interface DryRunStrategy cmdutil.DryRunStrategy - DryRunVerifier *resource.DryRunVerifier + DryRunVerifier *resource.QueryParamVerifier Builder *resource.Builder FieldManager string CreateAnnotation bool @@ -145,7 +145,7 @@ func (o *CreateJobOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args if err != nil { return err } - o.DryRunVerifier = resource.NewDryRunVerifier(dynamicClient, f.OpenAPIGetter()) + o.DryRunVerifier = resource.NewQueryParamVerifier(dynamicClient, f.OpenAPIGetter(), resource.QueryParamDryRun) cmdutil.PrintFlagsWithDryRunStrategy(o.PrintFlags, o.DryRunStrategy) printer, err := o.PrintFlags.ToPrinter() if err != nil { diff --git a/pkg/cmd/create/create_namespace.go b/pkg/cmd/create/create_namespace.go index cb7fdb7e0..a0e49b169 100644 --- a/pkg/cmd/create/create_namespace.go +++ b/pkg/cmd/create/create_namespace.go @@ -19,6 +19,7 @@ package create import ( "context" "fmt" + "github.com/spf13/cobra" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -52,7 +53,7 @@ type NamespaceOptions struct { Name string DryRunStrategy cmdutil.DryRunStrategy - DryRunVerifier *resource.DryRunVerifier + DryRunVerifier *resource.QueryParamVerifier CreateAnnotation bool FieldManager string @@ -129,7 +130,7 @@ func (o *NamespaceOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args if err != nil { return err } - o.DryRunVerifier = resource.NewDryRunVerifier(dynamicClient, discoveryClient) + o.DryRunVerifier = resource.NewQueryParamVerifier(dynamicClient, discoveryClient, resource.QueryParamDryRun) o.CreateAnnotation = cmdutil.GetFlagBool(cmd, cmdutil.ApplyAnnotationsFlag) cmdutil.PrintFlagsWithDryRunStrategy(o.PrintFlags, o.DryRunStrategy) printer, err := o.PrintFlags.ToPrinter() diff --git a/pkg/cmd/create/create_pdb.go b/pkg/cmd/create/create_pdb.go index c5db39fd5..e97a6e6e7 100644 --- a/pkg/cmd/create/create_pdb.go +++ b/pkg/cmd/create/create_pdb.go @@ -28,6 +28,7 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/cli-runtime/pkg/genericclioptions" + "k8s.io/cli-runtime/pkg/resource" resourcecli "k8s.io/cli-runtime/pkg/resource" policyv1client "k8s.io/client-go/kubernetes/typed/policy/v1" cmdutil "k8s.io/kubectl/pkg/cmd/util" @@ -71,7 +72,7 @@ type PodDisruptionBudgetOpts struct { Client *policyv1client.PolicyV1Client DryRunStrategy cmdutil.DryRunStrategy - DryRunVerifier *resourcecli.DryRunVerifier + DryRunVerifier *resourcecli.QueryParamVerifier genericclioptions.IOStreams } @@ -146,7 +147,7 @@ func (o *PodDisruptionBudgetOpts) Complete(f cmdutil.Factory, cmd *cobra.Command if err != nil { return err } - o.DryRunVerifier = resourcecli.NewDryRunVerifier(dynamicClient, discoveryClient) + o.DryRunVerifier = resource.NewQueryParamVerifier(dynamicClient, discoveryClient, resource.QueryParamDryRun) o.Namespace, o.EnforceNamespace, err = f.ToRawKubeConfigLoader().Namespace() if err != nil { diff --git a/pkg/cmd/create/create_priorityclass.go b/pkg/cmd/create/create_priorityclass.go index 4b54fd241..31c70b4e7 100644 --- a/pkg/cmd/create/create_priorityclass.go +++ b/pkg/cmd/create/create_priorityclass.go @@ -66,7 +66,7 @@ type PriorityClassOptions struct { Client *schedulingv1client.SchedulingV1Client DryRunStrategy cmdutil.DryRunStrategy - DryRunVerifier *resource.DryRunVerifier + DryRunVerifier *resource.QueryParamVerifier genericclioptions.IOStreams } @@ -138,7 +138,7 @@ func (o *PriorityClassOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, a if err != nil { return err } - o.DryRunVerifier = resource.NewDryRunVerifier(dynamicClient, f.OpenAPIGetter()) + o.DryRunVerifier = resource.NewQueryParamVerifier(dynamicClient, f.OpenAPIGetter(), resource.QueryParamDryRun) cmdutil.PrintFlagsWithDryRunStrategy(o.PrintFlags, o.DryRunStrategy) printer, err := o.PrintFlags.ToPrinter() diff --git a/pkg/cmd/create/create_quota.go b/pkg/cmd/create/create_quota.go index 6d67c38b0..3494c908b 100644 --- a/pkg/cmd/create/create_quota.go +++ b/pkg/cmd/create/create_quota.go @@ -28,6 +28,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/cli-runtime/pkg/genericclioptions" + "k8s.io/cli-runtime/pkg/resource" resourcecli "k8s.io/cli-runtime/pkg/resource" coreclient "k8s.io/client-go/kubernetes/typed/core/v1" cmdutil "k8s.io/kubectl/pkg/cmd/util" @@ -67,7 +68,7 @@ type QuotaOpts struct { Client *coreclient.CoreV1Client DryRunStrategy cmdutil.DryRunStrategy - DryRunVerifier *resourcecli.DryRunVerifier + DryRunVerifier *resourcecli.QueryParamVerifier genericclioptions.IOStreams } @@ -136,7 +137,7 @@ func (o *QuotaOpts) Complete(f cmdutil.Factory, cmd *cobra.Command, args []strin if err != nil { return err } - o.DryRunVerifier = resourcecli.NewDryRunVerifier(dynamicClient, f.OpenAPIGetter()) + o.DryRunVerifier = resourcecli.NewQueryParamVerifier(dynamicClient, f.OpenAPIGetter(), resource.QueryParamDryRun) o.Namespace, o.EnforceNamespace, err = f.ToRawKubeConfigLoader().Namespace() if err != nil { diff --git a/pkg/cmd/create/create_role.go b/pkg/cmd/create/create_role.go index 20b8876fe..1b4b2edd4 100644 --- a/pkg/cmd/create/create_role.go +++ b/pkg/cmd/create/create_role.go @@ -137,7 +137,7 @@ type CreateRoleOptions struct { ResourceNames []string DryRunStrategy cmdutil.DryRunStrategy - DryRunVerifier *resource.DryRunVerifier + DryRunVerifier *resource.QueryParamVerifier OutputFormat string Namespace string EnforceNamespace bool @@ -258,7 +258,7 @@ func (o *CreateRoleOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args if err != nil { return err } - o.DryRunVerifier = resource.NewDryRunVerifier(dynamicClient, f.OpenAPIGetter()) + o.DryRunVerifier = resource.NewQueryParamVerifier(dynamicClient, f.OpenAPIGetter(), resource.QueryParamDryRun) o.OutputFormat = cmdutil.GetFlagString(cmd, "output") o.CreateAnnotation = cmdutil.GetFlagBool(cmd, cmdutil.ApplyAnnotationsFlag) diff --git a/pkg/cmd/create/create_rolebinding.go b/pkg/cmd/create/create_rolebinding.go index beef08b05..fdef4cc72 100644 --- a/pkg/cmd/create/create_rolebinding.go +++ b/pkg/cmd/create/create_rolebinding.go @@ -63,7 +63,7 @@ type RoleBindingOptions struct { Client rbacclientv1.RbacV1Interface DryRunStrategy cmdutil.DryRunStrategy - DryRunVerifier *resource.DryRunVerifier + DryRunVerifier *resource.QueryParamVerifier genericclioptions.IOStreams } @@ -136,11 +136,11 @@ func (o *RoleBindingOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, arg if err != nil { return err } - dynamicCient, err := f.DynamicClient() + dynamicClient, err := f.DynamicClient() if err != nil { return err } - o.DryRunVerifier = resource.NewDryRunVerifier(dynamicCient, f.OpenAPIGetter()) + o.DryRunVerifier = resource.NewQueryParamVerifier(dynamicClient, f.OpenAPIGetter(), resource.QueryParamDryRun) cmdutil.PrintFlagsWithDryRunStrategy(o.PrintFlags, o.DryRunStrategy) printer, err := o.PrintFlags.ToPrinter() if err != nil { diff --git a/pkg/cmd/create/create_secret.go b/pkg/cmd/create/create_secret.go index be990fc8a..346690ac8 100644 --- a/pkg/cmd/create/create_secret.go +++ b/pkg/cmd/create/create_secret.go @@ -114,7 +114,7 @@ type CreateSecretOptions struct { Client corev1client.CoreV1Interface DryRunStrategy cmdutil.DryRunStrategy - DryRunVerifier *resource.DryRunVerifier + DryRunVerifier *resource.QueryParamVerifier genericclioptions.IOStreams } @@ -195,7 +195,7 @@ func (o *CreateSecretOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, ar return err } - o.DryRunVerifier = resource.NewDryRunVerifier(dynamicClient, discoveryClient) + o.DryRunVerifier = resource.NewQueryParamVerifier(dynamicClient, discoveryClient, resource.QueryParamDryRun) o.Namespace, o.EnforceNamespace, err = f.ToRawKubeConfigLoader().Namespace() if err != nil { diff --git a/pkg/cmd/create/create_secret_docker.go b/pkg/cmd/create/create_secret_docker.go index 6cf36b43a..26fd5dd54 100644 --- a/pkg/cmd/create/create_secret_docker.go +++ b/pkg/cmd/create/create_secret_docker.go @@ -110,7 +110,7 @@ type CreateSecretDockerRegistryOptions struct { Client corev1client.CoreV1Interface DryRunStrategy cmdutil.DryRunStrategy - DryRunVerifier *resource.DryRunVerifier + DryRunVerifier *resource.QueryParamVerifier genericclioptions.IOStreams } @@ -194,7 +194,7 @@ func (o *CreateSecretDockerRegistryOptions) Complete(f cmdutil.Factory, cmd *cob return err } - o.DryRunVerifier = resource.NewDryRunVerifier(dynamicClient, discoveryClient) + o.DryRunVerifier = resource.NewQueryParamVerifier(dynamicClient, discoveryClient, resource.QueryParamDryRun) o.Namespace, o.EnforceNamespace, err = f.ToRawKubeConfigLoader().Namespace() if err != nil { diff --git a/pkg/cmd/create/create_secret_tls.go b/pkg/cmd/create/create_secret_tls.go index 11641c8b9..2091a3285 100644 --- a/pkg/cmd/create/create_secret_tls.go +++ b/pkg/cmd/create/create_secret_tls.go @@ -71,7 +71,7 @@ type CreateSecretTLSOptions struct { Client corev1client.CoreV1Interface DryRunStrategy cmdutil.DryRunStrategy - DryRunVerifier *resource.DryRunVerifier + DryRunVerifier *resource.QueryParamVerifier genericclioptions.IOStreams } @@ -151,7 +151,7 @@ func (o *CreateSecretTLSOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, return err } - o.DryRunVerifier = resource.NewDryRunVerifier(dynamicClient, discoveryClient) + o.DryRunVerifier = resource.NewQueryParamVerifier(dynamicClient, discoveryClient, resource.QueryParamDryRun) o.Namespace, o.EnforceNamespace, err = f.ToRawKubeConfigLoader().Namespace() if err != nil { diff --git a/pkg/cmd/create/create_service.go b/pkg/cmd/create/create_service.go index ff2f2b0bc..95f41fbdd 100644 --- a/pkg/cmd/create/create_service.go +++ b/pkg/cmd/create/create_service.go @@ -76,7 +76,7 @@ type ServiceOptions struct { Client corev1client.CoreV1Interface DryRunStrategy cmdutil.DryRunStrategy - DryRunVerifier *resource.DryRunVerifier + DryRunVerifier *resource.QueryParamVerifier genericclioptions.IOStreams } @@ -119,7 +119,7 @@ func (o *ServiceOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args [] if err != nil { return err } - o.DryRunVerifier = resource.NewDryRunVerifier(dynamicClient, f.OpenAPIGetter()) + o.DryRunVerifier = resource.NewQueryParamVerifier(dynamicClient, f.OpenAPIGetter(), resource.QueryParamDryRun) cmdutil.PrintFlagsWithDryRunStrategy(o.PrintFlags, o.DryRunStrategy) printer, err := o.PrintFlags.ToPrinter() diff --git a/pkg/cmd/create/create_serviceaccount.go b/pkg/cmd/create/create_serviceaccount.go index f35649a69..2bc796937 100644 --- a/pkg/cmd/create/create_serviceaccount.go +++ b/pkg/cmd/create/create_serviceaccount.go @@ -53,7 +53,7 @@ type ServiceAccountOpts struct { // Name of resource being created Name string DryRunStrategy cmdutil.DryRunStrategy - DryRunVerifier *resource.DryRunVerifier + DryRunVerifier *resource.QueryParamVerifier CreateAnnotation bool FieldManager string @@ -128,7 +128,7 @@ func (o *ServiceAccountOpts) Complete(f cmdutil.Factory, cmd *cobra.Command, arg if err != nil { return err } - o.DryRunVerifier = resource.NewDryRunVerifier(dynamicClient, f.OpenAPIGetter()) + o.DryRunVerifier = resource.NewQueryParamVerifier(dynamicClient, f.OpenAPIGetter(), resource.QueryParamDryRun) o.Namespace, o.EnforceNamespace, err = f.ToRawKubeConfigLoader().Namespace() if err != nil { diff --git a/pkg/cmd/delete/delete.go b/pkg/cmd/delete/delete.go index cd3df4280..7af71a767 100644 --- a/pkg/cmd/delete/delete.go +++ b/pkg/cmd/delete/delete.go @@ -121,7 +121,7 @@ type DeleteOptions struct { Timeout time.Duration DryRunStrategy cmdutil.DryRunStrategy - DryRunVerifier *resource.DryRunVerifier + DryRunVerifier *resource.QueryParamVerifier Output string @@ -195,7 +195,7 @@ func (o *DeleteOptions) Complete(f cmdutil.Factory, args []string, cmd *cobra.Co if err != nil { return err } - o.DryRunVerifier = resource.NewDryRunVerifier(dynamicClient, f.OpenAPIGetter()) + o.DryRunVerifier = resource.NewQueryParamVerifier(dynamicClient, f.OpenAPIGetter(), resource.QueryParamDryRun) if len(o.Raw) == 0 { r := f.NewBuilder(). diff --git a/pkg/cmd/diff/diff.go b/pkg/cmd/diff/diff.go index 79c26075c..15aef59ed 100644 --- a/pkg/cmd/diff/diff.go +++ b/pkg/cmd/diff/diff.go @@ -112,7 +112,7 @@ type DiffOptions struct { OpenAPISchema openapi.Resources DiscoveryClient discovery.DiscoveryInterface DynamicClient dynamic.Interface - DryRunVerifier *resource.DryRunVerifier + DryRunVerifier *resource.QueryParamVerifier CmdNamespace string EnforceNamespace bool Builder *resource.Builder @@ -639,7 +639,7 @@ func (o *DiffOptions) Complete(f cmdutil.Factory, cmd *cobra.Command) error { return err } - o.DryRunVerifier = resource.NewDryRunVerifier(o.DynamicClient, f.OpenAPIGetter()) + o.DryRunVerifier = resource.NewQueryParamVerifier(o.DynamicClient, f.OpenAPIGetter(), resource.QueryParamDryRun) o.CmdNamespace, o.EnforceNamespace, err = f.ToRawKubeConfigLoader().Namespace() if err != nil { diff --git a/pkg/cmd/drain/drain.go b/pkg/cmd/drain/drain.go index 31398362a..1f32a1597 100644 --- a/pkg/cmd/drain/drain.go +++ b/pkg/cmd/drain/drain.go @@ -227,7 +227,7 @@ func (o *DrainCmdOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args [ if err != nil { return err } - o.drainer.DryRunVerifier = resource.NewDryRunVerifier(dynamicClient, f.OpenAPIGetter()) + o.drainer.DryRunVerifier = resource.NewQueryParamVerifier(dynamicClient, f.OpenAPIGetter(), resource.QueryParamDryRun) if o.drainer.Client, err = f.KubernetesClientSet(); err != nil { return err diff --git a/pkg/cmd/expose/expose.go b/pkg/cmd/expose/expose.go index 7ba07fe2c..312c6efd7 100644 --- a/pkg/cmd/expose/expose.go +++ b/pkg/cmd/expose/expose.go @@ -91,7 +91,7 @@ type ExposeServiceOptions struct { PrintObj printers.ResourcePrinterFunc DryRunStrategy cmdutil.DryRunStrategy - DryRunVerifier *resource.DryRunVerifier + DryRunVerifier *resource.QueryParamVerifier EnforceNamespace bool fieldManager string @@ -181,7 +181,7 @@ func (o *ExposeServiceOptions) Complete(f cmdutil.Factory, cmd *cobra.Command) e if err != nil { return err } - o.DryRunVerifier = resource.NewDryRunVerifier(dynamicClient, f.OpenAPIGetter()) + o.DryRunVerifier = resource.NewQueryParamVerifier(dynamicClient, f.OpenAPIGetter(), resource.QueryParamDryRun) cmdutil.PrintFlagsWithDryRunStrategy(o.PrintFlags, o.DryRunStrategy) printer, err := o.PrintFlags.ToPrinter() diff --git a/pkg/cmd/label/label.go b/pkg/cmd/label/label.go index ac79e07bb..c1c652925 100644 --- a/pkg/cmd/label/label.go +++ b/pkg/cmd/label/label.go @@ -83,7 +83,7 @@ type LabelOptions struct { enforceNamespace bool builder *resource.Builder unstructuredClientForMapping func(mapping *meta.RESTMapping) (resource.RESTClient, error) - dryRunVerifier *resource.DryRunVerifier + dryRunVerifier *resource.QueryParamVerifier // Common shared fields genericclioptions.IOStreams @@ -185,7 +185,7 @@ func (o *LabelOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []st if err != nil { return err } - o.dryRunVerifier = resource.NewDryRunVerifier(dynamicClient, f.OpenAPIGetter()) + o.dryRunVerifier = resource.NewQueryParamVerifier(dynamicClient, f.OpenAPIGetter(), resource.QueryParamDryRun) cmdutil.PrintFlagsWithDryRunStrategy(o.PrintFlags, o.dryRunStrategy) o.ToPrinter = func(operation string) (printers.ResourcePrinter, error) { diff --git a/pkg/cmd/patch/patch.go b/pkg/cmd/patch/patch.go index 457ce9df4..b39404961 100644 --- a/pkg/cmd/patch/patch.go +++ b/pkg/cmd/patch/patch.go @@ -64,7 +64,7 @@ type PatchOptions struct { namespace string enforceNamespace bool dryRunStrategy cmdutil.DryRunStrategy - dryRunVerifier *resource.DryRunVerifier + dryRunVerifier *resource.QueryParamVerifier outputFormat string args []string builder *resource.Builder @@ -169,7 +169,7 @@ func (o *PatchOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []st if err != nil { return err } - o.dryRunVerifier = resource.NewDryRunVerifier(dynamicClient, f.OpenAPIGetter()) + o.dryRunVerifier = resource.NewQueryParamVerifier(dynamicClient, f.OpenAPIGetter(), resource.QueryParamDryRun) return nil } diff --git a/pkg/cmd/replace/replace.go b/pkg/cmd/replace/replace.go index a5e33103b..53c911b5d 100644 --- a/pkg/cmd/replace/replace.go +++ b/pkg/cmd/replace/replace.go @@ -75,7 +75,7 @@ type ReplaceOptions struct { DeleteOptions *delete.DeleteOptions DryRunStrategy cmdutil.DryRunStrategy - DryRunVerifier *resource.DryRunVerifier + DryRunVerifier *resource.QueryParamVerifier PrintObj func(obj runtime.Object) error @@ -156,7 +156,7 @@ func (o *ReplaceOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args [] if err != nil { return err } - o.DryRunVerifier = resource.NewDryRunVerifier(dynamicClient, f.OpenAPIGetter()) + o.DryRunVerifier = resource.NewQueryParamVerifier(dynamicClient, f.OpenAPIGetter(), resource.QueryParamDryRun) cmdutil.PrintFlagsWithDryRunStrategy(o.PrintFlags, o.DryRunStrategy) printer, err := o.PrintFlags.ToPrinter() diff --git a/pkg/cmd/rollout/rollout_undo.go b/pkg/cmd/rollout/rollout_undo.go index 267c01a13..c12c55dd5 100644 --- a/pkg/cmd/rollout/rollout_undo.go +++ b/pkg/cmd/rollout/rollout_undo.go @@ -41,7 +41,7 @@ type UndoOptions struct { Builder func() *resource.Builder ToRevision int64 DryRunStrategy cmdutil.DryRunStrategy - DryRunVerifier *resource.DryRunVerifier + DryRunVerifier *resource.QueryParamVerifier Resources []string Namespace string LabelSelector string @@ -117,7 +117,7 @@ func (o *UndoOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []str if err != nil { return err } - o.DryRunVerifier = resource.NewDryRunVerifier(dynamicClient, f.OpenAPIGetter()) + o.DryRunVerifier = resource.NewQueryParamVerifier(dynamicClient, f.OpenAPIGetter(), resource.QueryParamDryRun) if o.Namespace, o.EnforceNamespace, err = f.ToRawKubeConfigLoader().Namespace(); err != nil { return err diff --git a/pkg/cmd/run/run.go b/pkg/cmd/run/run.go index 627b8ef10..e1d27a0d3 100644 --- a/pkg/cmd/run/run.go +++ b/pkg/cmd/run/run.go @@ -109,7 +109,7 @@ type RunOptions struct { DeleteOptions *cmddelete.DeleteOptions DryRunStrategy cmdutil.DryRunStrategy - DryRunVerifier *resource.DryRunVerifier + DryRunVerifier *resource.QueryParamVerifier PrintObj func(runtime.Object) error Recorder genericclioptions.Recorder @@ -218,7 +218,7 @@ func (o *RunOptions) Complete(f cmdutil.Factory, cmd *cobra.Command) error { if err != nil { return err } - o.DryRunVerifier = resource.NewDryRunVerifier(dynamicClient, f.OpenAPIGetter()) + o.DryRunVerifier = resource.NewQueryParamVerifier(dynamicClient, f.OpenAPIGetter(), resource.QueryParamDryRun) attachFlag := cmd.Flags().Lookup("attach") if !attachFlag.Changed && o.Interactive { diff --git a/pkg/cmd/scale/scale.go b/pkg/cmd/scale/scale.go index dfe14e6c6..aedfd8971 100644 --- a/pkg/cmd/scale/scale.go +++ b/pkg/cmd/scale/scale.go @@ -87,7 +87,7 @@ type ScaleOptions struct { unstructuredClientForMapping func(mapping *meta.RESTMapping) (resource.RESTClient, error) parent string dryRunStrategy cmdutil.DryRunStrategy - dryRunVerifier *resource.DryRunVerifier + dryRunVerifier *resource.QueryParamVerifier genericclioptions.IOStreams } @@ -158,7 +158,7 @@ func (o *ScaleOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []st if err != nil { return err } - o.dryRunVerifier = resource.NewDryRunVerifier(dynamicClient, f.OpenAPIGetter()) + o.dryRunVerifier = resource.NewQueryParamVerifier(dynamicClient, f.OpenAPIGetter(), resource.QueryParamDryRun) o.namespace, o.enforceNamespace, err = f.ToRawKubeConfigLoader().Namespace() if err != nil { diff --git a/pkg/cmd/set/set_env.go b/pkg/cmd/set/set_env.go index a27dfc40a..b45fcfde2 100644 --- a/pkg/cmd/set/set_env.go +++ b/pkg/cmd/set/set_env.go @@ -122,7 +122,7 @@ type EnvOptions struct { resources []string output string dryRunStrategy cmdutil.DryRunStrategy - dryRunVerifier *resource.DryRunVerifier + dryRunVerifier *resource.QueryParamVerifier builder func() *resource.Builder updatePodSpecForObject polymorphichelpers.UpdatePodSpecForObjectFunc namespace string @@ -233,7 +233,7 @@ func (o *EnvOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []stri if err != nil { return err } - o.dryRunVerifier = resource.NewDryRunVerifier(dynamicClient, f.OpenAPIGetter()) + o.dryRunVerifier = resource.NewQueryParamVerifier(dynamicClient, f.OpenAPIGetter(), resource.QueryParamDryRun) cmdutil.PrintFlagsWithDryRunStrategy(o.PrintFlags, o.dryRunStrategy) printer, err := o.PrintFlags.ToPrinter() diff --git a/pkg/cmd/set/set_image.go b/pkg/cmd/set/set_image.go index c59ec1bdf..b3bbb311a 100644 --- a/pkg/cmd/set/set_image.go +++ b/pkg/cmd/set/set_image.go @@ -47,7 +47,7 @@ type SetImageOptions struct { Infos []*resource.Info Selector string DryRunStrategy cmdutil.DryRunStrategy - DryRunVerifier *resource.DryRunVerifier + DryRunVerifier *resource.QueryParamVerifier All bool Output string Local bool @@ -158,7 +158,7 @@ func (o *SetImageOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args [ if err != nil { return err } - o.DryRunVerifier = resource.NewDryRunVerifier(dynamicClient, f.OpenAPIGetter()) + o.DryRunVerifier = resource.NewQueryParamVerifier(dynamicClient, f.OpenAPIGetter(), resource.QueryParamDryRun) o.Output = cmdutil.GetFlagString(cmd, "output") o.ResolveImage = ImageResolver diff --git a/pkg/cmd/set/set_resources.go b/pkg/cmd/set/set_resources.go index 0745108c2..a3caf4a80 100644 --- a/pkg/cmd/set/set_resources.go +++ b/pkg/cmd/set/set_resources.go @@ -86,7 +86,7 @@ type SetResourcesOptions struct { UpdatePodSpecForObject polymorphichelpers.UpdatePodSpecForObjectFunc Resources []string - DryRunVerifier *resource.DryRunVerifier + DryRunVerifier *resource.QueryParamVerifier genericclioptions.IOStreams } @@ -161,7 +161,7 @@ func (o *SetResourcesOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, ar if err != nil { return err } - o.DryRunVerifier = resource.NewDryRunVerifier(dynamicClient, f.OpenAPIGetter()) + o.DryRunVerifier = resource.NewQueryParamVerifier(dynamicClient, f.OpenAPIGetter(), resource.QueryParamDryRun) cmdutil.PrintFlagsWithDryRunStrategy(o.PrintFlags, o.DryRunStrategy) printer, err := o.PrintFlags.ToPrinter() diff --git a/pkg/cmd/set/set_selector.go b/pkg/cmd/set/set_selector.go index 62bd64ccc..7fbd21228 100644 --- a/pkg/cmd/set/set_selector.go +++ b/pkg/cmd/set/set_selector.go @@ -45,7 +45,7 @@ type SetSelectorOptions struct { PrintFlags *genericclioptions.PrintFlags RecordFlags *genericclioptions.RecordFlags dryRunStrategy cmdutil.DryRunStrategy - dryRunVerifier *resource.DryRunVerifier + dryRunVerifier *resource.QueryParamVerifier fieldManager string // set by args @@ -140,7 +140,7 @@ func (o *SetSelectorOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, arg if err != nil { return err } - o.dryRunVerifier = resource.NewDryRunVerifier(dynamicClient, f.OpenAPIGetter()) + o.dryRunVerifier = resource.NewQueryParamVerifier(dynamicClient, f.OpenAPIGetter(), resource.QueryParamDryRun) o.resources, o.selector, err = getResourcesAndSelector(args) if err != nil { diff --git a/pkg/cmd/set/set_serviceaccount.go b/pkg/cmd/set/set_serviceaccount.go index bdaef2566..d037f5bed 100644 --- a/pkg/cmd/set/set_serviceaccount.go +++ b/pkg/cmd/set/set_serviceaccount.go @@ -63,7 +63,7 @@ type SetServiceAccountOptions struct { fileNameOptions resource.FilenameOptions dryRunStrategy cmdutil.DryRunStrategy - dryRunVerifier *resource.DryRunVerifier + dryRunVerifier *resource.QueryParamVerifier shortOutput bool all bool output string @@ -142,7 +142,7 @@ func (o *SetServiceAccountOptions) Complete(f cmdutil.Factory, cmd *cobra.Comman if err != nil { return err } - o.dryRunVerifier = resource.NewDryRunVerifier(dynamicClient, f.OpenAPIGetter()) + o.dryRunVerifier = resource.NewQueryParamVerifier(dynamicClient, f.OpenAPIGetter(), resource.QueryParamDryRun) o.output = cmdutil.GetFlagString(cmd, "output") o.updatePodSpecForObject = polymorphichelpers.UpdatePodSpecForObjectFn diff --git a/pkg/cmd/set/set_subject.go b/pkg/cmd/set/set_subject.go index b9979dd3c..f6f6e79ae 100644 --- a/pkg/cmd/set/set_subject.go +++ b/pkg/cmd/set/set_subject.go @@ -66,7 +66,7 @@ type SubjectOptions struct { Output string All bool DryRunStrategy cmdutil.DryRunStrategy - DryRunVerifier *resource.DryRunVerifier + DryRunVerifier *resource.QueryParamVerifier Local bool fieldManager string @@ -132,7 +132,7 @@ func (o *SubjectOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args [] if err != nil { return err } - o.DryRunVerifier = resource.NewDryRunVerifier(dynamicClient, f.OpenAPIGetter()) + o.DryRunVerifier = resource.NewQueryParamVerifier(dynamicClient, f.OpenAPIGetter(), resource.QueryParamDryRun) cmdutil.PrintFlagsWithDryRunStrategy(o.PrintFlags, o.DryRunStrategy) printer, err := o.PrintFlags.ToPrinter() diff --git a/pkg/cmd/taint/taint.go b/pkg/cmd/taint/taint.go index 403a05d8f..f8273ac3d 100644 --- a/pkg/cmd/taint/taint.go +++ b/pkg/cmd/taint/taint.go @@ -48,7 +48,7 @@ type TaintOptions struct { ToPrinter func(string) (printers.ResourcePrinter, error) DryRunStrategy cmdutil.DryRunStrategy - DryRunVerifier *resource.DryRunVerifier + DryRunVerifier *resource.QueryParamVerifier resources []string taintsToAdd []v1.Taint @@ -147,7 +147,7 @@ func (o *TaintOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []st if err != nil { return err } - o.DryRunVerifier = resource.NewDryRunVerifier(dynamicClient, f.OpenAPIGetter()) + o.DryRunVerifier = resource.NewQueryParamVerifier(dynamicClient, f.OpenAPIGetter(), resource.QueryParamDryRun) cmdutil.PrintFlagsWithDryRunStrategy(o.PrintFlags, o.DryRunStrategy) // retrieves resource and taint args from args diff --git a/pkg/drain/drain.go b/pkg/drain/drain.go index 53e7bfa62..b36692eb4 100644 --- a/pkg/drain/drain.go +++ b/pkg/drain/drain.go @@ -83,7 +83,7 @@ type Helper struct { ErrOut io.Writer DryRunStrategy cmdutil.DryRunStrategy - DryRunVerifier *resource.DryRunVerifier + DryRunVerifier *resource.QueryParamVerifier // OnPodDeletedOrEvicted is called when a pod is evicted/deleted; for printing progress output OnPodDeletedOrEvicted func(pod *corev1.Pod, usingEviction bool)