mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 04:33:26 +00:00
Removes unnecessary dry run verifier
This commit is contained in:
parent
63ff4a2659
commit
530f65d6fd
@ -38,16 +38,10 @@ func NewQueryParamVerifier(dynamicClient dynamic.Interface, openAPIGetter discov
|
||||
// QueryParamVerifier verifies if a given group-version-kind supports a
|
||||
// given VerifiableQueryParam against the current server.
|
||||
//
|
||||
// Currently supported query params are:
|
||||
// 1. dryRun
|
||||
// 2. fieldValidation
|
||||
// Currently supported query params are: fieldValidation
|
||||
//
|
||||
// Support for each of these query params needs to be verified because:
|
||||
//
|
||||
// 1. Sending dryRun requests to apiserver that
|
||||
// don't support it will result in objects being unwillingly persisted.
|
||||
//
|
||||
// 2. We determine whether or not to perform server-side or client-side
|
||||
// Support for each of these query params needs to be verified because
|
||||
// we determine whether or not to perform server-side or client-side
|
||||
// schema validation based on whether the fieldValidation query param is
|
||||
// supported or not.
|
||||
//
|
||||
@ -73,7 +67,6 @@ type Verifier interface {
|
||||
type VerifiableQueryParam string
|
||||
|
||||
const (
|
||||
QueryParamDryRun VerifiableQueryParam = "dryRun"
|
||||
QueryParamFieldValidation VerifiableQueryParam = "fieldValidation"
|
||||
)
|
||||
|
||||
|
@ -39,16 +39,6 @@ func TestSupportsQueryParam(t *testing.T) {
|
||||
supports bool
|
||||
queryParam VerifiableQueryParam
|
||||
}{
|
||||
{
|
||||
gvk: schema.GroupVersionKind{
|
||||
Group: "",
|
||||
Version: "v1",
|
||||
Kind: "Pod",
|
||||
},
|
||||
success: true,
|
||||
supports: true,
|
||||
queryParam: QueryParamDryRun,
|
||||
},
|
||||
{
|
||||
gvk: schema.GroupVersionKind{
|
||||
Group: "",
|
||||
@ -59,16 +49,6 @@ func TestSupportsQueryParam(t *testing.T) {
|
||||
supports: true,
|
||||
queryParam: QueryParamFieldValidation,
|
||||
},
|
||||
{
|
||||
gvk: schema.GroupVersionKind{
|
||||
Group: "",
|
||||
Version: "v1",
|
||||
Kind: "UnknownKind",
|
||||
},
|
||||
success: false,
|
||||
supports: false,
|
||||
queryParam: QueryParamDryRun,
|
||||
},
|
||||
{
|
||||
gvk: schema.GroupVersionKind{
|
||||
Group: "",
|
||||
@ -79,16 +59,6 @@ func TestSupportsQueryParam(t *testing.T) {
|
||||
supports: false,
|
||||
queryParam: QueryParamFieldValidation,
|
||||
},
|
||||
{
|
||||
gvk: schema.GroupVersionKind{
|
||||
Group: "",
|
||||
Version: "v1",
|
||||
Kind: "NodeProxyOptions",
|
||||
},
|
||||
success: true,
|
||||
supports: false,
|
||||
queryParam: QueryParamDryRun,
|
||||
},
|
||||
{
|
||||
gvk: schema.GroupVersionKind{
|
||||
Group: "",
|
||||
@ -117,45 +87,6 @@ func TestSupportsQueryParam(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestDryRunVerifier(t *testing.T) {
|
||||
dryRunVerifier := QueryParamVerifier{
|
||||
finder: NewCRDFinder(func() ([]schema.GroupKind, error) {
|
||||
return []schema.GroupKind{
|
||||
{
|
||||
Group: "crd.com",
|
||||
Kind: "MyCRD",
|
||||
},
|
||||
{
|
||||
Group: "crd.com",
|
||||
Kind: "MyNewCRD",
|
||||
},
|
||||
}, nil
|
||||
}),
|
||||
openAPIGetter: &fakeSchema,
|
||||
queryParam: QueryParamDryRun,
|
||||
}
|
||||
|
||||
err := dryRunVerifier.HasSupport(schema.GroupVersionKind{Group: "", Version: "v1", Kind: "NodeProxyOptions"})
|
||||
if err == nil {
|
||||
t.Fatalf("NodeProxyOptions doesn't support dry-run, yet no error found")
|
||||
}
|
||||
|
||||
err = dryRunVerifier.HasSupport(schema.GroupVersionKind{Group: "", Version: "v1", Kind: "Pod"})
|
||||
if err != nil {
|
||||
t.Fatalf("Pod should support dry-run: %v", err)
|
||||
}
|
||||
|
||||
err = dryRunVerifier.HasSupport(schema.GroupVersionKind{Group: "crd.com", Version: "v1", Kind: "MyCRD"})
|
||||
if err != nil {
|
||||
t.Fatalf("MyCRD should support dry-run: %v", err)
|
||||
}
|
||||
|
||||
err = dryRunVerifier.HasSupport(schema.GroupVersionKind{Group: "crd.com", Version: "v1", Kind: "Random"})
|
||||
if err == nil {
|
||||
t.Fatalf("Random doesn't support dry-run, yet no error found")
|
||||
}
|
||||
}
|
||||
|
||||
func TestFieldValidationVerifier(t *testing.T) {
|
||||
fieldValidationVerifier := QueryParamVerifier{
|
||||
finder: NewCRDFinder(func() ([]schema.GroupKind, error) {
|
||||
@ -201,35 +132,6 @@ func (EmptyOpenAPI) OpenAPISchema() (*openapi_v2.Document, error) {
|
||||
return &openapi_v2.Document{}, nil
|
||||
}
|
||||
|
||||
func TestDryRunVerifierNoOpenAPI(t *testing.T) {
|
||||
dryRunVerifier := QueryParamVerifier{
|
||||
finder: NewCRDFinder(func() ([]schema.GroupKind, error) {
|
||||
return []schema.GroupKind{
|
||||
{
|
||||
Group: "crd.com",
|
||||
Kind: "MyCRD",
|
||||
},
|
||||
{
|
||||
Group: "crd.com",
|
||||
Kind: "MyNewCRD",
|
||||
},
|
||||
}, nil
|
||||
}),
|
||||
openAPIGetter: EmptyOpenAPI{},
|
||||
queryParam: QueryParamDryRun,
|
||||
}
|
||||
|
||||
err := dryRunVerifier.HasSupport(schema.GroupVersionKind{Group: "", Version: "v1", Kind: "Pod"})
|
||||
if err == nil {
|
||||
t.Fatalf("Pod doesn't support dry-run, yet no error found")
|
||||
}
|
||||
|
||||
err = dryRunVerifier.HasSupport(schema.GroupVersionKind{Group: "crd.com", Version: "v1", Kind: "MyCRD"})
|
||||
if err == nil {
|
||||
t.Fatalf("MyCRD doesn't support dry-run, yet no error found")
|
||||
}
|
||||
}
|
||||
|
||||
func TestFieldValidationVerifierNoOpenAPI(t *testing.T) {
|
||||
fieldValidationVerifier := QueryParamVerifier{
|
||||
finder: NewCRDFinder(func() ([]schema.GroupKind, error) {
|
||||
|
@ -48,11 +48,9 @@ import (
|
||||
// the logic itself easy to unit test
|
||||
type AnnotateFlags struct {
|
||||
// Common user flags
|
||||
All bool
|
||||
AllNamespaces bool
|
||||
|
||||
All bool
|
||||
AllNamespaces bool
|
||||
DryRunStrategy cmdutil.DryRunStrategy
|
||||
DryRunVerifier *resource.QueryParamVerifier
|
||||
FieldManager string
|
||||
FieldSelector string
|
||||
resource.FilenameOptions
|
||||
@ -84,7 +82,6 @@ type AnnotateOptions struct {
|
||||
|
||||
builder *resource.Builder
|
||||
dryRunStrategy cmdutil.DryRunStrategy
|
||||
dryRunVerifier *resource.QueryParamVerifier
|
||||
|
||||
enforceNamespace bool
|
||||
fieldSelector string
|
||||
@ -219,13 +216,6 @@ func (flags *AnnotateFlags) ToOptions(f cmdutil.Factory, cmd *cobra.Command, arg
|
||||
return nil, err
|
||||
}
|
||||
|
||||
dynamicClient, err := f.DynamicClient()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
options.dryRunVerifier = resource.NewQueryParamVerifier(dynamicClient, f.OpenAPIGetter(), resource.QueryParamDryRun)
|
||||
|
||||
cmdutil.PrintFlagsWithDryRunStrategy(flags.PrintFlags, options.dryRunStrategy)
|
||||
printer, err := flags.PrintFlags.ToPrinter()
|
||||
if err != nil {
|
||||
@ -340,11 +330,6 @@ func (o AnnotateOptions) RunAnnotate() error {
|
||||
outputObj = obj
|
||||
} else {
|
||||
mapping := info.ResourceMapping()
|
||||
if o.dryRunStrategy == cmdutil.DryRunServer {
|
||||
if err := o.dryRunVerifier.HasSupport(mapping.GroupVersionKind); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
name, namespace := info.Name, info.Namespace
|
||||
|
||||
if len(o.resourceVersion) != 0 {
|
||||
|
@ -91,7 +91,6 @@ type ApplyOptions struct {
|
||||
FieldManager string
|
||||
Selector string
|
||||
DryRunStrategy cmdutil.DryRunStrategy
|
||||
DryRunVerifier *resource.QueryParamVerifier
|
||||
FieldValidationVerifier *resource.QueryParamVerifier
|
||||
Prune bool
|
||||
PruneResources []prune.Resource
|
||||
@ -256,7 +255,6 @@ func (flags *ApplyFlags) ToOptions(cmd *cobra.Command, baseName string, args []s
|
||||
return nil, err
|
||||
}
|
||||
|
||||
dryRunVerifier := resource.NewQueryParamVerifier(dynamicClient, flags.Factory.OpenAPIGetter(), resource.QueryParamDryRun)
|
||||
fieldValidationVerifier := resource.NewQueryParamVerifier(dynamicClient, flags.Factory.OpenAPIGetter(), resource.QueryParamFieldValidation)
|
||||
fieldManager := GetApplyFieldManagerFlag(cmd, serverSideApply)
|
||||
|
||||
@ -326,7 +324,6 @@ func (flags *ApplyFlags) ToOptions(cmd *cobra.Command, baseName string, args []s
|
||||
FieldManager: fieldManager,
|
||||
Selector: flags.Selector,
|
||||
DryRunStrategy: dryRunStrategy,
|
||||
DryRunVerifier: dryRunVerifier,
|
||||
Prune: flags.Prune,
|
||||
PruneResources: flags.PruneResources,
|
||||
All: flags.All,
|
||||
@ -502,16 +499,6 @@ func (o *ApplyOptions) applyOneObject(info *resource.Info) error {
|
||||
WithFieldManager(o.FieldManager).
|
||||
WithFieldValidation(o.ValidationDirective)
|
||||
|
||||
if o.DryRunStrategy == cmdutil.DryRunServer {
|
||||
// Ensure the APIServer supports server-side dry-run for the resource,
|
||||
// otherwise fail early.
|
||||
// For APIServers that don't support server-side dry-run will persist
|
||||
// changes.
|
||||
if err := o.DryRunVerifier.HasSupport(info.Mapping.GroupVersionKind); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if o.ServerSideApply {
|
||||
// Send the full object to be applied on the server side.
|
||||
data, err := runtime.Encode(unstructured.UnstructuredJSONScheme, info.Object)
|
||||
|
@ -50,7 +50,6 @@ type SetLastAppliedOptions struct {
|
||||
namespace string
|
||||
enforceNamespace bool
|
||||
dryRunStrategy cmdutil.DryRunStrategy
|
||||
dryRunVerifier *resource.QueryParamVerifier
|
||||
shortOutput bool
|
||||
output string
|
||||
patchBufferList []PatchBuffer
|
||||
@ -124,11 +123,6 @@ func (o *SetLastAppliedOptions) Complete(f cmdutil.Factory, cmd *cobra.Command)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
dynamicClient, err := f.DynamicClient()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
o.dryRunVerifier = resource.NewQueryParamVerifier(dynamicClient, f.OpenAPIGetter(), resource.QueryParamDryRun)
|
||||
o.output = cmdutil.GetFlagString(cmd, "output")
|
||||
o.shortOutput = o.output == "name"
|
||||
|
||||
@ -208,11 +202,6 @@ func (o *SetLastAppliedOptions) RunSetLastApplied() error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if o.dryRunStrategy == cmdutil.DryRunServer {
|
||||
if err := o.dryRunVerifier.HasSupport(mapping.GroupVersionKind); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
helper := resource.
|
||||
NewHelper(client, mapping).
|
||||
DryRun(o.dryRunStrategy == cmdutil.DryRunServer)
|
||||
|
@ -74,7 +74,6 @@ type AutoscaleOptions struct {
|
||||
enforceNamespace bool
|
||||
namespace string
|
||||
dryRunStrategy cmdutil.DryRunStrategy
|
||||
dryRunVerifier *resource.QueryParamVerifier
|
||||
builder *resource.Builder
|
||||
fieldManager string
|
||||
|
||||
@ -138,15 +137,10 @@ func (o *AutoscaleOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
dynamicClient, err := f.DynamicClient()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
discoveryClient, err := f.ToDiscoveryClient()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
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)
|
||||
@ -242,9 +236,6 @@ func (o *AutoscaleOptions) Run() error {
|
||||
createOptions.FieldManager = o.fieldManager
|
||||
}
|
||||
if o.dryRunStrategy == cmdutil.DryRunServer {
|
||||
if err := o.dryRunVerifier.HasSupport(hpa.GroupVersionKind()); err != nil {
|
||||
return err
|
||||
}
|
||||
createOptions.DryRun = []string{metav1.DryRunAll}
|
||||
}
|
||||
actualHPA, err := o.HPAClient.HorizontalPodAutoscalers(o.namespace).Create(context.TODO(), hpa, createOptions)
|
||||
|
@ -52,7 +52,6 @@ type CreateOptions struct {
|
||||
RecordFlags *genericclioptions.RecordFlags
|
||||
|
||||
DryRunStrategy cmdutil.DryRunStrategy
|
||||
DryRunVerifier *resource.QueryParamVerifier
|
||||
FieldValidationVerifier *resource.QueryParamVerifier
|
||||
|
||||
ValidationDirective string
|
||||
@ -210,7 +209,6 @@ func (o *CreateOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []s
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
o.DryRunVerifier = resource.NewQueryParamVerifier(dynamicClient, f.OpenAPIGetter(), resource.QueryParamDryRun)
|
||||
o.FieldValidationVerifier = resource.NewQueryParamVerifier(dynamicClient, f.OpenAPIGetter(), resource.QueryParamFieldValidation)
|
||||
|
||||
o.ValidationDirective, err = cmdutil.GetValidationDirective(cmd)
|
||||
@ -284,11 +282,6 @@ func (o *CreateOptions) RunCreate(f cmdutil.Factory, cmd *cobra.Command) error {
|
||||
}
|
||||
|
||||
if o.DryRunStrategy != cmdutil.DryRunClient {
|
||||
if o.DryRunStrategy == cmdutil.DryRunServer {
|
||||
if err := o.DryRunVerifier.HasSupport(info.Mapping.GroupVersionKind); err != nil {
|
||||
return cmdutil.AddSourceToErr("creating", info.Source, err)
|
||||
}
|
||||
}
|
||||
obj, err := resource.
|
||||
NewHelper(info.Client, info.Mapping).
|
||||
DryRun(o.DryRunStrategy == cmdutil.DryRunServer).
|
||||
@ -359,7 +352,6 @@ type CreateSubcommandOptions struct {
|
||||
// StructuredGenerator is the resource generator for the object being created
|
||||
StructuredGenerator generate.StructuredGenerator
|
||||
DryRunStrategy cmdutil.DryRunStrategy
|
||||
DryRunVerifier *resource.QueryParamVerifier
|
||||
CreateAnnotation bool
|
||||
FieldManager string
|
||||
ValidationDirective string
|
||||
@ -396,11 +388,6 @@ func (o *CreateSubcommandOptions) Complete(f cmdutil.Factory, cmd *cobra.Command
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
dynamicClient, err := f.DynamicClient()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
o.DryRunVerifier = resource.NewQueryParamVerifier(dynamicClient, f.OpenAPIGetter(), resource.QueryParamDryRun)
|
||||
o.CreateAnnotation = cmdutil.GetFlagBool(cmd, cmdutil.ApplyAnnotationsFlag)
|
||||
|
||||
cmdutil.PrintFlagsWithDryRunStrategy(o.PrintFlags, o.DryRunStrategy)
|
||||
@ -471,9 +458,6 @@ func (o *CreateSubcommandOptions) Run() error {
|
||||
createOptions.FieldValidation = o.ValidationDirective
|
||||
|
||||
if o.DryRunStrategy == cmdutil.DryRunServer {
|
||||
if err := o.DryRunVerifier.HasSupport(mapping.GroupVersionKind); err != nil {
|
||||
return err
|
||||
}
|
||||
createOptions.DryRun = []string{metav1.DryRunAll}
|
||||
}
|
||||
actualObject, err := o.DynamicClient.Resource(mapping.Resource).Namespace(o.Namespace).Create(context.TODO(), asUnstructured, createOptions)
|
||||
|
@ -215,9 +215,6 @@ func (c *CreateClusterRoleOptions) RunCreateRole() error {
|
||||
}
|
||||
createOptions.FieldValidation = c.ValidationDirective
|
||||
if c.DryRunStrategy == cmdutil.DryRunServer {
|
||||
if err := c.DryRunVerifier.HasSupport(clusterRole.GroupVersionKind()); err != nil {
|
||||
return err
|
||||
}
|
||||
createOptions.DryRun = []string{metav1.DryRunAll}
|
||||
}
|
||||
clusterRole, err = c.Client.ClusterRoles().Create(context.TODO(), clusterRole, createOptions)
|
||||
|
@ -27,7 +27,6 @@ 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"
|
||||
rbacclientv1 "k8s.io/client-go/kubernetes/typed/rbac/v1"
|
||||
cmdutil "k8s.io/kubectl/pkg/cmd/util"
|
||||
"k8s.io/kubectl/pkg/scheme"
|
||||
@ -61,7 +60,6 @@ type ClusterRoleBindingOptions struct {
|
||||
|
||||
Client rbacclientv1.RbacV1Interface
|
||||
DryRunStrategy cmdutil.DryRunStrategy
|
||||
DryRunVerifier *resource.QueryParamVerifier
|
||||
ValidationDirective string
|
||||
|
||||
genericclioptions.IOStreams
|
||||
@ -136,11 +134,6 @@ func (o *ClusterRoleBindingOptions) Complete(f cmdutil.Factory, cmd *cobra.Comma
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
dynamicClient, err := f.DynamicClient()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
o.DryRunVerifier = resource.NewQueryParamVerifier(dynamicClient, f.OpenAPIGetter(), resource.QueryParamDryRun)
|
||||
cmdutil.PrintFlagsWithDryRunStrategy(o.PrintFlags, o.DryRunStrategy)
|
||||
|
||||
printer, err := o.PrintFlags.ToPrinter()
|
||||
@ -176,9 +169,6 @@ func (o *ClusterRoleBindingOptions) Run() error {
|
||||
}
|
||||
createOptions.FieldValidation = o.ValidationDirective
|
||||
if o.DryRunStrategy == cmdutil.DryRunServer {
|
||||
if err := o.DryRunVerifier.HasSupport(clusterRoleBinding.GroupVersionKind()); err != nil {
|
||||
return err
|
||||
}
|
||||
createOptions.DryRun = []string{metav1.DryRunAll}
|
||||
}
|
||||
var err error
|
||||
|
@ -31,7 +31,6 @@ import (
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/util/validation"
|
||||
"k8s.io/cli-runtime/pkg/genericclioptions"
|
||||
"k8s.io/cli-runtime/pkg/resource"
|
||||
corev1client "k8s.io/client-go/kubernetes/typed/core/v1"
|
||||
cmdutil "k8s.io/kubectl/pkg/cmd/util"
|
||||
"k8s.io/kubectl/pkg/scheme"
|
||||
@ -97,7 +96,6 @@ type ConfigMapOptions struct {
|
||||
|
||||
Client corev1client.CoreV1Interface
|
||||
DryRunStrategy cmdutil.DryRunStrategy
|
||||
DryRunVerifier *resource.QueryParamVerifier
|
||||
ValidationDirective string
|
||||
|
||||
genericclioptions.IOStreams
|
||||
@ -169,17 +167,6 @@ func (o *ConfigMapOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args
|
||||
return err
|
||||
}
|
||||
|
||||
dynamicClient, err := f.DynamicClient()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
discoveryClient, err := f.ToDiscoveryClient()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
o.DryRunVerifier = resource.NewQueryParamVerifier(dynamicClient, discoveryClient, resource.QueryParamDryRun)
|
||||
|
||||
o.Namespace, o.EnforceNamespace, err = f.ToRawKubeConfigLoader().Namespace()
|
||||
if err != nil {
|
||||
return err
|
||||
@ -229,9 +216,6 @@ func (o *ConfigMapOptions) Run() error {
|
||||
}
|
||||
createOptions.FieldValidation = o.ValidationDirective
|
||||
if o.DryRunStrategy == cmdutil.DryRunServer {
|
||||
if err := o.DryRunVerifier.HasSupport(configMap.GroupVersionKind()); err != nil {
|
||||
return err
|
||||
}
|
||||
createOptions.DryRun = []string{metav1.DryRunAll}
|
||||
}
|
||||
configMap, err = o.Client.ConfigMaps(o.Namespace).Create(context.TODO(), configMap, createOptions)
|
||||
|
@ -64,7 +64,6 @@ type CreateCronJobOptions struct {
|
||||
EnforceNamespace bool
|
||||
Client batchv1client.BatchV1Interface
|
||||
DryRunStrategy cmdutil.DryRunStrategy
|
||||
DryRunVerifier *resource.QueryParamVerifier
|
||||
ValidationDirective string
|
||||
Builder *resource.Builder
|
||||
FieldManager string
|
||||
@ -147,11 +146,6 @@ func (o *CreateCronJobOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, a
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
dynamicClient, err := f.DynamicClient()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
o.DryRunVerifier = resource.NewQueryParamVerifier(dynamicClient, f.OpenAPIGetter(), resource.QueryParamDryRun)
|
||||
cmdutil.PrintFlagsWithDryRunStrategy(o.PrintFlags, o.DryRunStrategy)
|
||||
printer, err := o.PrintFlags.ToPrinter()
|
||||
if err != nil {
|
||||
@ -183,9 +177,6 @@ func (o *CreateCronJobOptions) Run() error {
|
||||
}
|
||||
createOptions.FieldValidation = o.ValidationDirective
|
||||
if o.DryRunStrategy == cmdutil.DryRunServer {
|
||||
if err := o.DryRunVerifier.HasSupport(cronJob.GroupVersionKind()); err != nil {
|
||||
return err
|
||||
}
|
||||
createOptions.DryRun = []string{metav1.DryRunAll}
|
||||
}
|
||||
var err error
|
||||
|
@ -29,7 +29,6 @@ import (
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
utilrand "k8s.io/apimachinery/pkg/util/rand"
|
||||
"k8s.io/cli-runtime/pkg/genericclioptions"
|
||||
"k8s.io/cli-runtime/pkg/resource"
|
||||
appsv1client "k8s.io/client-go/kubernetes/typed/apps/v1"
|
||||
cmdutil "k8s.io/kubectl/pkg/cmd/util"
|
||||
"k8s.io/kubectl/pkg/scheme"
|
||||
@ -74,7 +73,6 @@ type CreateDeploymentOptions struct {
|
||||
|
||||
Client appsv1client.AppsV1Interface
|
||||
DryRunStrategy cmdutil.DryRunStrategy
|
||||
DryRunVerifier *resource.QueryParamVerifier
|
||||
ValidationDirective string
|
||||
|
||||
genericclioptions.IOStreams
|
||||
@ -153,11 +151,6 @@ func (o *CreateDeploymentOptions) Complete(f cmdutil.Factory, cmd *cobra.Command
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
dynamicClient, err := f.DynamicClient()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
o.DryRunVerifier = resource.NewQueryParamVerifier(dynamicClient, f.OpenAPIGetter(), resource.QueryParamDryRun)
|
||||
cmdutil.PrintFlagsWithDryRunStrategy(o.PrintFlags, o.DryRunStrategy)
|
||||
|
||||
printer, err := o.PrintFlags.ToPrinter()
|
||||
@ -199,9 +192,6 @@ func (o *CreateDeploymentOptions) Run() error {
|
||||
}
|
||||
createOptions.FieldValidation = o.ValidationDirective
|
||||
if o.DryRunStrategy == cmdutil.DryRunServer {
|
||||
if err := o.DryRunVerifier.HasSupport(deploy.GroupVersionKind()); err != nil {
|
||||
return err
|
||||
}
|
||||
createOptions.DryRun = []string{metav1.DryRunAll}
|
||||
}
|
||||
var err error
|
||||
|
@ -29,7 +29,6 @@ import (
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/util/intstr"
|
||||
"k8s.io/cli-runtime/pkg/genericclioptions"
|
||||
"k8s.io/cli-runtime/pkg/resource"
|
||||
networkingv1client "k8s.io/client-go/kubernetes/typed/networking/v1"
|
||||
cmdutil "k8s.io/kubectl/pkg/cmd/util"
|
||||
"k8s.io/kubectl/pkg/scheme"
|
||||
@ -118,7 +117,6 @@ type CreateIngressOptions struct {
|
||||
|
||||
Client networkingv1client.NetworkingV1Interface
|
||||
DryRunStrategy cmdutil.DryRunStrategy
|
||||
DryRunVerifier *resource.QueryParamVerifier
|
||||
ValidationDirective string
|
||||
|
||||
FieldManager string
|
||||
@ -195,11 +193,6 @@ func (o *CreateIngressOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, a
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
dynamicClient, err := f.DynamicClient()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
o.DryRunVerifier = resource.NewQueryParamVerifier(dynamicClient, f.OpenAPIGetter(), resource.QueryParamDryRun)
|
||||
cmdutil.PrintFlagsWithDryRunStrategy(o.PrintFlags, o.DryRunStrategy)
|
||||
|
||||
printer, err := o.PrintFlags.ToPrinter()
|
||||
@ -259,9 +252,6 @@ func (o *CreateIngressOptions) Run() error {
|
||||
}
|
||||
createOptions.FieldValidation = o.ValidationDirective
|
||||
if o.DryRunStrategy == cmdutil.DryRunServer {
|
||||
if err := o.DryRunVerifier.HasSupport(ingress.GroupVersionKind()); err != nil {
|
||||
return err
|
||||
}
|
||||
createOptions.DryRun = []string{metav1.DryRunAll}
|
||||
}
|
||||
var err error
|
||||
|
@ -66,7 +66,6 @@ type CreateJobOptions struct {
|
||||
EnforceNamespace bool
|
||||
Client batchv1client.BatchV1Interface
|
||||
DryRunStrategy cmdutil.DryRunStrategy
|
||||
DryRunVerifier *resource.QueryParamVerifier
|
||||
ValidationDirective string
|
||||
Builder *resource.Builder
|
||||
FieldManager string
|
||||
@ -142,11 +141,6 @@ func (o *CreateJobOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
dynamicClient, err := f.DynamicClient()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
o.DryRunVerifier = resource.NewQueryParamVerifier(dynamicClient, f.OpenAPIGetter(), resource.QueryParamDryRun)
|
||||
cmdutil.PrintFlagsWithDryRunStrategy(o.PrintFlags, o.DryRunStrategy)
|
||||
printer, err := o.PrintFlags.ToPrinter()
|
||||
if err != nil {
|
||||
@ -215,9 +209,6 @@ func (o *CreateJobOptions) Run() error {
|
||||
}
|
||||
createOptions.FieldValidation = o.ValidationDirective
|
||||
if o.DryRunStrategy == cmdutil.DryRunServer {
|
||||
if err := o.DryRunVerifier.HasSupport(job.GroupVersionKind()); err != nil {
|
||||
return err
|
||||
}
|
||||
createOptions.DryRun = []string{metav1.DryRunAll}
|
||||
}
|
||||
var err error
|
||||
|
@ -25,7 +25,6 @@ import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/cli-runtime/pkg/resource"
|
||||
coreclient "k8s.io/client-go/kubernetes/typed/core/v1"
|
||||
"k8s.io/kubectl/pkg/scheme"
|
||||
"k8s.io/kubectl/pkg/util"
|
||||
@ -53,7 +52,6 @@ type NamespaceOptions struct {
|
||||
Name string
|
||||
|
||||
DryRunStrategy cmdutil.DryRunStrategy
|
||||
DryRunVerifier *resource.QueryParamVerifier
|
||||
ValidationDirective string
|
||||
CreateAnnotation bool
|
||||
FieldManager string
|
||||
@ -123,15 +121,6 @@ func (o *NamespaceOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
dynamicClient, err := f.DynamicClient()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
discoveryClient, err := f.ToDiscoveryClient()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
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()
|
||||
@ -160,9 +149,6 @@ func (o *NamespaceOptions) Run() error {
|
||||
}
|
||||
createOptions.FieldValidation = o.ValidationDirective
|
||||
if o.DryRunStrategy == cmdutil.DryRunServer {
|
||||
if err := o.DryRunVerifier.HasSupport(namespace.GroupVersionKind()); err != nil {
|
||||
return err
|
||||
}
|
||||
createOptions.DryRun = []string{metav1.DryRunAll}
|
||||
}
|
||||
var err error
|
||||
|
@ -28,7 +28,6 @@ import (
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/util/intstr"
|
||||
"k8s.io/cli-runtime/pkg/genericclioptions"
|
||||
"k8s.io/cli-runtime/pkg/resource"
|
||||
policyv1client "k8s.io/client-go/kubernetes/typed/policy/v1"
|
||||
cmdutil "k8s.io/kubectl/pkg/cmd/util"
|
||||
"k8s.io/kubectl/pkg/scheme"
|
||||
@ -71,7 +70,6 @@ type PodDisruptionBudgetOpts struct {
|
||||
|
||||
Client *policyv1client.PolicyV1Client
|
||||
DryRunStrategy cmdutil.DryRunStrategy
|
||||
DryRunVerifier *resource.QueryParamVerifier
|
||||
ValidationDirective string
|
||||
|
||||
genericclioptions.IOStreams
|
||||
@ -139,15 +137,6 @@ func (o *PodDisruptionBudgetOpts) Complete(f cmdutil.Factory, cmd *cobra.Command
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
dynamicClient, err := f.DynamicClient()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
discoveryClient, err := f.ToDiscoveryClient()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
o.DryRunVerifier = resource.NewQueryParamVerifier(dynamicClient, discoveryClient, resource.QueryParamDryRun)
|
||||
|
||||
o.Namespace, o.EnforceNamespace, err = f.ToRawKubeConfigLoader().Namespace()
|
||||
if err != nil {
|
||||
@ -224,9 +213,6 @@ func (o *PodDisruptionBudgetOpts) Run() error {
|
||||
}
|
||||
createOptions.FieldValidation = o.ValidationDirective
|
||||
if o.DryRunStrategy == cmdutil.DryRunServer {
|
||||
if err := o.DryRunVerifier.HasSupport(podDisruptionBudget.GroupVersionKind()); err != nil {
|
||||
return err
|
||||
}
|
||||
createOptions.DryRun = []string{metav1.DryRunAll}
|
||||
}
|
||||
podDisruptionBudget, err = o.Client.PodDisruptionBudgets(o.Namespace).Create(context.TODO(), podDisruptionBudget, createOptions)
|
||||
|
@ -27,7 +27,6 @@ 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"
|
||||
schedulingv1client "k8s.io/client-go/kubernetes/typed/scheduling/v1"
|
||||
cmdutil "k8s.io/kubectl/pkg/cmd/util"
|
||||
"k8s.io/kubectl/pkg/scheme"
|
||||
@ -66,7 +65,6 @@ type PriorityClassOptions struct {
|
||||
|
||||
Client *schedulingv1client.SchedulingV1Client
|
||||
DryRunStrategy cmdutil.DryRunStrategy
|
||||
DryRunVerifier *resource.QueryParamVerifier
|
||||
ValidationDirective string
|
||||
|
||||
genericclioptions.IOStreams
|
||||
@ -135,11 +133,6 @@ func (o *PriorityClassOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, a
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
dynamicClient, err := f.DynamicClient()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
o.DryRunVerifier = resource.NewQueryParamVerifier(dynamicClient, f.OpenAPIGetter(), resource.QueryParamDryRun)
|
||||
cmdutil.PrintFlagsWithDryRunStrategy(o.PrintFlags, o.DryRunStrategy)
|
||||
|
||||
printer, err := o.PrintFlags.ToPrinter()
|
||||
@ -176,9 +169,6 @@ func (o *PriorityClassOptions) Run() error {
|
||||
}
|
||||
createOptions.FieldValidation = o.ValidationDirective
|
||||
if o.DryRunStrategy == cmdutil.DryRunServer {
|
||||
if err := o.DryRunVerifier.HasSupport(priorityClass.GroupVersionKind()); err != nil {
|
||||
return err
|
||||
}
|
||||
createOptions.DryRun = []string{metav1.DryRunAll}
|
||||
}
|
||||
var err error
|
||||
|
@ -28,7 +28,6 @@ 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"
|
||||
coreclient "k8s.io/client-go/kubernetes/typed/core/v1"
|
||||
cmdutil "k8s.io/kubectl/pkg/cmd/util"
|
||||
"k8s.io/kubectl/pkg/scheme"
|
||||
@ -67,7 +66,6 @@ type QuotaOpts struct {
|
||||
|
||||
Client *coreclient.CoreV1Client
|
||||
DryRunStrategy cmdutil.DryRunStrategy
|
||||
DryRunVerifier *resource.QueryParamVerifier
|
||||
ValidationDirective string
|
||||
|
||||
genericclioptions.IOStreams
|
||||
@ -133,11 +131,6 @@ func (o *QuotaOpts) Complete(f cmdutil.Factory, cmd *cobra.Command, args []strin
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
dynamicClient, err := f.DynamicClient()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
o.DryRunVerifier = resource.NewQueryParamVerifier(dynamicClient, f.OpenAPIGetter(), resource.QueryParamDryRun)
|
||||
|
||||
o.Namespace, o.EnforceNamespace, err = f.ToRawKubeConfigLoader().Namespace()
|
||||
if err != nil {
|
||||
@ -189,9 +182,6 @@ func (o *QuotaOpts) Run() error {
|
||||
}
|
||||
createOptions.FieldValidation = o.ValidationDirective
|
||||
if o.DryRunStrategy == cmdutil.DryRunServer {
|
||||
if err := o.DryRunVerifier.HasSupport(resourceQuota.GroupVersionKind()); err != nil {
|
||||
return err
|
||||
}
|
||||
createOptions.DryRun = []string{metav1.DryRunAll}
|
||||
}
|
||||
resourceQuota, err = o.Client.ResourceQuotas(o.Namespace).Create(context.TODO(), resourceQuota, createOptions)
|
||||
|
@ -30,7 +30,6 @@ import (
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/apimachinery/pkg/util/sets"
|
||||
"k8s.io/cli-runtime/pkg/genericclioptions"
|
||||
"k8s.io/cli-runtime/pkg/resource"
|
||||
clientgorbacv1 "k8s.io/client-go/kubernetes/typed/rbac/v1"
|
||||
cmdutil "k8s.io/kubectl/pkg/cmd/util"
|
||||
"k8s.io/kubectl/pkg/scheme"
|
||||
@ -139,7 +138,6 @@ type CreateRoleOptions struct {
|
||||
ResourceNames []string
|
||||
|
||||
DryRunStrategy cmdutil.DryRunStrategy
|
||||
DryRunVerifier *resource.QueryParamVerifier
|
||||
ValidationDirective string
|
||||
OutputFormat string
|
||||
Namespace string
|
||||
@ -257,11 +255,6 @@ func (o *CreateRoleOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
dynamicClient, err := f.DynamicClient()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
o.DryRunVerifier = resource.NewQueryParamVerifier(dynamicClient, f.OpenAPIGetter(), resource.QueryParamDryRun)
|
||||
o.OutputFormat = cmdutil.GetFlagString(cmd, "output")
|
||||
o.CreateAnnotation = cmdutil.GetFlagBool(cmd, cmdutil.ApplyAnnotationsFlag)
|
||||
|
||||
@ -384,9 +377,6 @@ func (o *CreateRoleOptions) RunCreateRole() error {
|
||||
}
|
||||
createOptions.FieldValidation = o.ValidationDirective
|
||||
if o.DryRunStrategy == cmdutil.DryRunServer {
|
||||
if err := o.DryRunVerifier.HasSupport(role.GroupVersionKind()); err != nil {
|
||||
return err
|
||||
}
|
||||
createOptions.DryRun = []string{metav1.DryRunAll}
|
||||
}
|
||||
role, err = o.Client.Roles(o.Namespace).Create(context.TODO(), role, createOptions)
|
||||
|
@ -27,7 +27,6 @@ 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"
|
||||
rbacclientv1 "k8s.io/client-go/kubernetes/typed/rbac/v1"
|
||||
cmdutil "k8s.io/kubectl/pkg/cmd/util"
|
||||
"k8s.io/kubectl/pkg/scheme"
|
||||
@ -63,7 +62,6 @@ type RoleBindingOptions struct {
|
||||
|
||||
Client rbacclientv1.RbacV1Interface
|
||||
DryRunStrategy cmdutil.DryRunStrategy
|
||||
DryRunVerifier *resource.QueryParamVerifier
|
||||
ValidationDirective string
|
||||
|
||||
genericclioptions.IOStreams
|
||||
@ -137,11 +135,6 @@ func (o *RoleBindingOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, arg
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
dynamicClient, err := f.DynamicClient()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
o.DryRunVerifier = resource.NewQueryParamVerifier(dynamicClient, f.OpenAPIGetter(), resource.QueryParamDryRun)
|
||||
cmdutil.PrintFlagsWithDryRunStrategy(o.PrintFlags, o.DryRunStrategy)
|
||||
printer, err := o.PrintFlags.ToPrinter()
|
||||
if err != nil {
|
||||
@ -183,9 +176,6 @@ func (o *RoleBindingOptions) Run() error {
|
||||
}
|
||||
createOptions.FieldValidation = o.ValidationDirective
|
||||
if o.DryRunStrategy == cmdutil.DryRunServer {
|
||||
if err := o.DryRunVerifier.HasSupport(roleBinding.GroupVersionKind()); err != nil {
|
||||
return err
|
||||
}
|
||||
createOptions.DryRun = []string{metav1.DryRunAll}
|
||||
}
|
||||
roleBinding, err = o.Client.RoleBindings(o.Namespace).Create(context.TODO(), roleBinding, createOptions)
|
||||
|
@ -30,7 +30,6 @@ import (
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/util/validation"
|
||||
"k8s.io/cli-runtime/pkg/genericclioptions"
|
||||
"k8s.io/cli-runtime/pkg/resource"
|
||||
corev1client "k8s.io/client-go/kubernetes/typed/core/v1"
|
||||
cmdutil "k8s.io/kubectl/pkg/cmd/util"
|
||||
"k8s.io/kubectl/pkg/scheme"
|
||||
@ -113,7 +112,6 @@ type CreateSecretOptions struct {
|
||||
|
||||
Client corev1client.CoreV1Interface
|
||||
DryRunStrategy cmdutil.DryRunStrategy
|
||||
DryRunVerifier *resource.QueryParamVerifier
|
||||
ValidationDirective string
|
||||
|
||||
genericclioptions.IOStreams
|
||||
@ -185,18 +183,6 @@ func (o *CreateSecretOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, ar
|
||||
return err
|
||||
}
|
||||
|
||||
dynamicClient, err := f.DynamicClient()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
discoveryClient, err := f.ToDiscoveryClient()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
o.DryRunVerifier = resource.NewQueryParamVerifier(dynamicClient, discoveryClient, resource.QueryParamDryRun)
|
||||
|
||||
o.Namespace, o.EnforceNamespace, err = f.ToRawKubeConfigLoader().Namespace()
|
||||
if err != nil {
|
||||
return err
|
||||
@ -249,10 +235,6 @@ func (o *CreateSecretOptions) Run() error {
|
||||
}
|
||||
createOptions.FieldValidation = o.ValidationDirective
|
||||
if o.DryRunStrategy == cmdutil.DryRunServer {
|
||||
err := o.DryRunVerifier.HasSupport(secret.GroupVersionKind())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
createOptions.DryRun = []string{metav1.DryRunAll}
|
||||
}
|
||||
secret, err = o.Client.Secrets(o.Namespace).Create(context.TODO(), secret, createOptions)
|
||||
|
@ -27,7 +27,6 @@ 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"
|
||||
corev1client "k8s.io/client-go/kubernetes/typed/core/v1"
|
||||
cmdutil "k8s.io/kubectl/pkg/cmd/util"
|
||||
"k8s.io/kubectl/pkg/scheme"
|
||||
@ -110,7 +109,6 @@ type CreateSecretDockerRegistryOptions struct {
|
||||
|
||||
Client corev1client.CoreV1Interface
|
||||
DryRunStrategy cmdutil.DryRunStrategy
|
||||
DryRunVerifier *resource.QueryParamVerifier
|
||||
ValidationDirective string
|
||||
|
||||
genericclioptions.IOStreams
|
||||
@ -185,18 +183,6 @@ func (o *CreateSecretDockerRegistryOptions) Complete(f cmdutil.Factory, cmd *cob
|
||||
return err
|
||||
}
|
||||
|
||||
dynamicClient, err := f.DynamicClient()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
discoveryClient, err := f.ToDiscoveryClient()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
o.DryRunVerifier = resource.NewQueryParamVerifier(dynamicClient, discoveryClient, resource.QueryParamDryRun)
|
||||
|
||||
o.Namespace, o.EnforceNamespace, err = f.ToRawKubeConfigLoader().Namespace()
|
||||
if err != nil {
|
||||
return err
|
||||
@ -249,10 +235,6 @@ func (o *CreateSecretDockerRegistryOptions) Run() error {
|
||||
}
|
||||
createOptions.FieldValidation = o.ValidationDirective
|
||||
if o.DryRunStrategy == cmdutil.DryRunServer {
|
||||
err := o.DryRunVerifier.HasSupport(secretDockerRegistry.GroupVersionKind())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
createOptions.DryRun = []string{metav1.DryRunAll}
|
||||
}
|
||||
secretDockerRegistry, err = o.Client.Secrets(o.Namespace).Create(context.TODO(), secretDockerRegistry, createOptions)
|
||||
|
@ -27,7 +27,6 @@ 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"
|
||||
corev1client "k8s.io/client-go/kubernetes/typed/core/v1"
|
||||
cmdutil "k8s.io/kubectl/pkg/cmd/util"
|
||||
"k8s.io/kubectl/pkg/scheme"
|
||||
@ -71,7 +70,6 @@ type CreateSecretTLSOptions struct {
|
||||
|
||||
Client corev1client.CoreV1Interface
|
||||
DryRunStrategy cmdutil.DryRunStrategy
|
||||
DryRunVerifier *resource.QueryParamVerifier
|
||||
ValidationDirective string
|
||||
|
||||
genericclioptions.IOStreams
|
||||
@ -142,18 +140,6 @@ func (o *CreateSecretTLSOptions) Complete(f cmdutil.Factory, cmd *cobra.Command,
|
||||
return err
|
||||
}
|
||||
|
||||
dynamicClient, err := f.DynamicClient()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
discoveryClient, err := f.ToDiscoveryClient()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
o.DryRunVerifier = resource.NewQueryParamVerifier(dynamicClient, discoveryClient, resource.QueryParamDryRun)
|
||||
|
||||
o.Namespace, o.EnforceNamespace, err = f.ToRawKubeConfigLoader().Namespace()
|
||||
if err != nil {
|
||||
return err
|
||||
@ -206,10 +192,6 @@ func (o *CreateSecretTLSOptions) Run() error {
|
||||
}
|
||||
createOptions.FieldValidation = o.ValidationDirective
|
||||
if o.DryRunStrategy == cmdutil.DryRunServer {
|
||||
err := o.DryRunVerifier.HasSupport(secretTLS.GroupVersionKind())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
createOptions.DryRun = []string{metav1.DryRunAll}
|
||||
}
|
||||
secretTLS, err = o.Client.Secrets(o.Namespace).Create(context.TODO(), secretTLS, createOptions)
|
||||
|
@ -30,7 +30,6 @@ import (
|
||||
"k8s.io/apimachinery/pkg/util/intstr"
|
||||
"k8s.io/apimachinery/pkg/util/validation"
|
||||
"k8s.io/cli-runtime/pkg/genericclioptions"
|
||||
"k8s.io/cli-runtime/pkg/resource"
|
||||
corev1client "k8s.io/client-go/kubernetes/typed/core/v1"
|
||||
cmdutil "k8s.io/kubectl/pkg/cmd/util"
|
||||
"k8s.io/kubectl/pkg/scheme"
|
||||
@ -76,7 +75,6 @@ type ServiceOptions struct {
|
||||
|
||||
Client corev1client.CoreV1Interface
|
||||
DryRunStrategy cmdutil.DryRunStrategy
|
||||
DryRunVerifier *resource.QueryParamVerifier
|
||||
ValidationDirective string
|
||||
genericclioptions.IOStreams
|
||||
}
|
||||
@ -116,11 +114,6 @@ func (o *ServiceOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
dynamicClient, err := f.DynamicClient()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
o.DryRunVerifier = resource.NewQueryParamVerifier(dynamicClient, f.OpenAPIGetter(), resource.QueryParamDryRun)
|
||||
cmdutil.PrintFlagsWithDryRunStrategy(o.PrintFlags, o.DryRunStrategy)
|
||||
|
||||
printer, err := o.PrintFlags.ToPrinter()
|
||||
|
@ -27,7 +27,6 @@ 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"
|
||||
coreclient "k8s.io/client-go/kubernetes/typed/core/v1"
|
||||
cmdutil "k8s.io/kubectl/pkg/cmd/util"
|
||||
"k8s.io/kubectl/pkg/scheme"
|
||||
@ -53,7 +52,6 @@ type ServiceAccountOpts struct {
|
||||
// Name of resource being created
|
||||
Name string
|
||||
DryRunStrategy cmdutil.DryRunStrategy
|
||||
DryRunVerifier *resource.QueryParamVerifier
|
||||
ValidationDirective string
|
||||
CreateAnnotation bool
|
||||
FieldManager string
|
||||
@ -125,11 +123,6 @@ func (o *ServiceAccountOpts) Complete(f cmdutil.Factory, cmd *cobra.Command, arg
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
dynamicClient, err := f.DynamicClient()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
o.DryRunVerifier = resource.NewQueryParamVerifier(dynamicClient, f.OpenAPIGetter(), resource.QueryParamDryRun)
|
||||
|
||||
o.Namespace, o.EnforceNamespace, err = f.ToRawKubeConfigLoader().Namespace()
|
||||
if err != nil {
|
||||
@ -181,9 +174,6 @@ func (o *ServiceAccountOpts) Run() error {
|
||||
}
|
||||
createOptions.FieldValidation = o.ValidationDirective
|
||||
if o.DryRunStrategy == cmdutil.DryRunServer {
|
||||
if err := o.DryRunVerifier.HasSupport(serviceAccount.GroupVersionKind()); err != nil {
|
||||
return err
|
||||
}
|
||||
createOptions.DryRun = []string{metav1.DryRunAll}
|
||||
}
|
||||
serviceAccount, err = o.Client.ServiceAccounts(o.Namespace).Create(context.TODO(), serviceAccount, createOptions)
|
||||
|
@ -125,7 +125,6 @@ type DeleteOptions struct {
|
||||
Timeout time.Duration
|
||||
|
||||
DryRunStrategy cmdutil.DryRunStrategy
|
||||
DryRunVerifier *resource.QueryParamVerifier
|
||||
|
||||
Output string
|
||||
|
||||
@ -196,11 +195,6 @@ func (o *DeleteOptions) Complete(f cmdutil.Factory, args []string, cmd *cobra.Co
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
dynamicClient, err := f.DynamicClient()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
o.DryRunVerifier = resource.NewQueryParamVerifier(dynamicClient, f.OpenAPIGetter(), resource.QueryParamDryRun)
|
||||
|
||||
if len(o.Raw) == 0 {
|
||||
r := f.NewBuilder().
|
||||
@ -328,11 +322,6 @@ func (o *DeleteOptions) DeleteResult(r *resource.Result) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
if o.DryRunStrategy == cmdutil.DryRunServer {
|
||||
if err := o.DryRunVerifier.HasSupport(info.Mapping.GroupVersionKind); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
response, err := o.deleteResource(info, options)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -110,7 +110,6 @@ type DiffOptions struct {
|
||||
Selector string
|
||||
OpenAPISchema openapi.Resources
|
||||
DynamicClient dynamic.Interface
|
||||
DryRunVerifier *resource.QueryParamVerifier
|
||||
CmdNamespace string
|
||||
EnforceNamespace bool
|
||||
Builder *resource.Builder
|
||||
@ -645,8 +644,6 @@ func (o *DiffOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []str
|
||||
return err
|
||||
}
|
||||
|
||||
o.DryRunVerifier = resource.NewQueryParamVerifier(o.DynamicClient, f.OpenAPIGetter(), resource.QueryParamDryRun)
|
||||
|
||||
o.CmdNamespace, o.EnforceNamespace, err = f.ToRawKubeConfigLoader().Namespace()
|
||||
if err != nil {
|
||||
return err
|
||||
@ -697,10 +694,6 @@ func (o *DiffOptions) Run() error {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := o.DryRunVerifier.HasSupport(info.Mapping.GroupVersionKind); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
local := info.Object.DeepCopyObject()
|
||||
for i := 1; i <= maxRetries; i++ {
|
||||
if err = info.Get(); err != nil {
|
||||
|
@ -224,11 +224,6 @@ func (o *DrainCmdOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args [
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
dynamicClient, err := f.DynamicClient()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
o.drainer.DryRunVerifier = resource.NewQueryParamVerifier(dynamicClient, f.OpenAPIGetter(), resource.QueryParamDryRun)
|
||||
|
||||
if o.drainer.Client, err = f.KubernetesClientSet(); err != nil {
|
||||
return err
|
||||
@ -400,12 +395,6 @@ func (o *DrainCmdOptions) RunCordonOrUncordon(desired bool) error {
|
||||
printObj(nodeInfo.Object, o.Out)
|
||||
} else {
|
||||
if o.drainer.DryRunStrategy != cmdutil.DryRunClient {
|
||||
if o.drainer.DryRunStrategy == cmdutil.DryRunServer {
|
||||
if err := o.drainer.DryRunVerifier.HasSupport(gvk); err != nil {
|
||||
printError(err)
|
||||
continue
|
||||
}
|
||||
}
|
||||
err, patchErr := c.PatchOrReplace(o.drainer.Client, o.drainer.DryRunStrategy == cmdutil.DryRunServer)
|
||||
if patchErr != nil {
|
||||
printError(patchErr)
|
||||
|
@ -115,7 +115,6 @@ type ExposeServiceOptions struct {
|
||||
ClusterIP string
|
||||
|
||||
DryRunStrategy cmdutil.DryRunStrategy
|
||||
DryRunVerifier *resource.QueryParamVerifier
|
||||
EnforceNamespace bool
|
||||
|
||||
fieldManager string
|
||||
@ -201,11 +200,6 @@ func (o *ExposeServiceOptions) Complete(f cmdutil.Factory, cmd *cobra.Command) e
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
dynamicClient, err := f.DynamicClient()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
o.DryRunVerifier = resource.NewQueryParamVerifier(dynamicClient, f.OpenAPIGetter(), resource.QueryParamDryRun)
|
||||
|
||||
cmdutil.PrintFlagsWithDryRunStrategy(o.PrintFlags, o.DryRunStrategy)
|
||||
printer, err := o.PrintFlags.ToPrinter()
|
||||
@ -360,11 +354,6 @@ func (o *ExposeServiceOptions) RunExpose(cmd *cobra.Command, args []string) erro
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if o.DryRunStrategy == cmdutil.DryRunServer {
|
||||
if err := o.DryRunVerifier.HasSupport(objMapping.GroupVersionKind); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
// Serialize the object with the annotation applied.
|
||||
client, err := o.ClientForMapping(objMapping)
|
||||
if err != nil {
|
||||
|
@ -83,7 +83,6 @@ type LabelOptions struct {
|
||||
enforceNamespace bool
|
||||
builder *resource.Builder
|
||||
unstructuredClientForMapping func(mapping *meta.RESTMapping) (resource.RESTClient, error)
|
||||
dryRunVerifier *resource.QueryParamVerifier
|
||||
|
||||
// Common shared fields
|
||||
genericclioptions.IOStreams
|
||||
@ -181,11 +180,6 @@ func (o *LabelOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []st
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
dynamicClient, err := f.DynamicClient()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
o.dryRunVerifier = resource.NewQueryParamVerifier(dynamicClient, f.OpenAPIGetter(), resource.QueryParamDryRun)
|
||||
|
||||
o.ToPrinter = func(operation string) (printers.ResourcePrinter, error) {
|
||||
o.PrintFlags.NamePrintFlags.Operation = operation
|
||||
@ -343,11 +337,6 @@ func (o *LabelOptions) RunLabel() error {
|
||||
}
|
||||
|
||||
mapping := info.ResourceMapping()
|
||||
if o.dryRunStrategy == cmdutil.DryRunServer {
|
||||
if err := o.dryRunVerifier.HasSupport(mapping.GroupVersionKind); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
client, err := o.unstructuredClientForMapping(mapping)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -68,7 +68,6 @@ type PatchOptions struct {
|
||||
namespace string
|
||||
enforceNamespace bool
|
||||
dryRunStrategy cmdutil.DryRunStrategy
|
||||
dryRunVerifier *resource.QueryParamVerifier
|
||||
outputFormat string
|
||||
args []string
|
||||
builder *resource.Builder
|
||||
@ -177,11 +176,6 @@ func (o *PatchOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []st
|
||||
o.args = args
|
||||
o.builder = f.NewBuilder()
|
||||
o.unstructuredClientForMapping = f.UnstructuredClientForMapping
|
||||
dynamicClient, err := f.DynamicClient()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
o.dryRunVerifier = resource.NewQueryParamVerifier(dynamicClient, f.OpenAPIGetter(), resource.QueryParamDryRun)
|
||||
|
||||
return nil
|
||||
}
|
||||
@ -257,11 +251,6 @@ func (o *PatchOptions) RunPatch() error {
|
||||
|
||||
if !o.Local && o.dryRunStrategy != cmdutil.DryRunClient {
|
||||
mapping := info.ResourceMapping()
|
||||
if o.dryRunStrategy == cmdutil.DryRunServer {
|
||||
if err := o.dryRunVerifier.HasSupport(mapping.GroupVersionKind); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
client, err := o.unstructuredClientForMapping(mapping)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -77,7 +77,6 @@ type ReplaceOptions struct {
|
||||
DeleteOptions *delete.DeleteOptions
|
||||
|
||||
DryRunStrategy cmdutil.DryRunStrategy
|
||||
DryRunVerifier *resource.QueryParamVerifier
|
||||
FieldValidationVerifier *resource.QueryParamVerifier
|
||||
validationDirective string
|
||||
|
||||
@ -165,7 +164,6 @@ func (o *ReplaceOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
o.DryRunVerifier = resource.NewQueryParamVerifier(dynamicClient, f.OpenAPIGetter(), resource.QueryParamDryRun)
|
||||
o.FieldValidationVerifier = resource.NewQueryParamVerifier(dynamicClient, f.OpenAPIGetter(), resource.QueryParamFieldValidation)
|
||||
cmdutil.PrintFlagsWithDryRunStrategy(o.PrintFlags, o.DryRunStrategy)
|
||||
|
||||
@ -303,11 +301,6 @@ func (o *ReplaceOptions) Run(f cmdutil.Factory) error {
|
||||
if o.DryRunStrategy == cmdutil.DryRunClient {
|
||||
return o.PrintObj(info.Object)
|
||||
}
|
||||
if o.DryRunStrategy == cmdutil.DryRunServer {
|
||||
if err := o.DryRunVerifier.HasSupport(info.Mapping.GroupVersionKind); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// Serialize the object with the annotation applied.
|
||||
obj, err := resource.
|
||||
|
@ -41,7 +41,6 @@ type UndoOptions struct {
|
||||
Builder func() *resource.Builder
|
||||
ToRevision int64
|
||||
DryRunStrategy cmdutil.DryRunStrategy
|
||||
DryRunVerifier *resource.QueryParamVerifier
|
||||
Resources []string
|
||||
Namespace string
|
||||
LabelSelector string
|
||||
@ -113,11 +112,6 @@ func (o *UndoOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []str
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
dynamicClient, err := f.DynamicClient()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
o.DryRunVerifier = resource.NewQueryParamVerifier(dynamicClient, f.OpenAPIGetter(), resource.QueryParamDryRun)
|
||||
|
||||
if o.Namespace, o.EnforceNamespace, err = f.ToRawKubeConfigLoader().Namespace(); err != nil {
|
||||
return err
|
||||
@ -167,11 +161,6 @@ func (o *UndoOptions) RunUndo() error {
|
||||
return err
|
||||
}
|
||||
|
||||
if o.DryRunStrategy == cmdutil.DryRunServer {
|
||||
if err := o.DryRunVerifier.HasSupport(info.Mapping.GroupVersionKind); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
result, err := rollbacker.Rollback(info.Object, nil, o.ToRevision, o.DryRunStrategy)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -109,7 +109,6 @@ type RunOptions struct {
|
||||
DeleteOptions *cmddelete.DeleteOptions
|
||||
|
||||
DryRunStrategy cmdutil.DryRunStrategy
|
||||
DryRunVerifier *resource.QueryParamVerifier
|
||||
|
||||
PrintObj func(runtime.Object) error
|
||||
Recorder genericclioptions.Recorder
|
||||
@ -227,7 +226,6 @@ func (o *RunOptions) Complete(f cmdutil.Factory, cmd *cobra.Command) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
o.DryRunVerifier = resource.NewQueryParamVerifier(dynamicClient, f.OpenAPIGetter(), resource.QueryParamDryRun)
|
||||
|
||||
attachFlag := cmd.Flags().Lookup("attach")
|
||||
if !attachFlag.Changed && o.Interactive {
|
||||
@ -651,11 +649,6 @@ func (o *RunOptions) createGeneratedObject(f cmdutil.Factory, cmd *cobra.Command
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if o.DryRunStrategy == cmdutil.DryRunServer {
|
||||
if err := o.DryRunVerifier.HasSupport(mapping.GroupVersionKind); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
actualObj, err = resource.
|
||||
NewHelper(client, mapping).
|
||||
DryRun(o.DryRunStrategy == cmdutil.DryRunServer).
|
||||
|
@ -87,7 +87,6 @@ type ScaleOptions struct {
|
||||
unstructuredClientForMapping func(mapping *meta.RESTMapping) (resource.RESTClient, error)
|
||||
parent string
|
||||
dryRunStrategy cmdutil.DryRunStrategy
|
||||
dryRunVerifier *resource.QueryParamVerifier
|
||||
|
||||
genericclioptions.IOStreams
|
||||
}
|
||||
@ -156,12 +155,6 @@ func (o *ScaleOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []st
|
||||
}
|
||||
o.PrintObj = printer.PrintObj
|
||||
|
||||
dynamicClient, err := f.DynamicClient()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
o.dryRunVerifier = resource.NewQueryParamVerifier(dynamicClient, f.OpenAPIGetter(), resource.QueryParamDryRun)
|
||||
|
||||
o.namespace, o.enforceNamespace, err = f.ToRawKubeConfigLoader().Namespace()
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -123,7 +123,6 @@ type EnvOptions struct {
|
||||
resources []string
|
||||
output string
|
||||
dryRunStrategy cmdutil.DryRunStrategy
|
||||
dryRunVerifier *resource.QueryParamVerifier
|
||||
builder func() *resource.Builder
|
||||
updatePodSpecForObject polymorphichelpers.UpdatePodSpecForObjectFunc
|
||||
namespace string
|
||||
@ -231,11 +230,6 @@ func (o *EnvOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []stri
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
dynamicClient, err := f.DynamicClient()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
o.dryRunVerifier = resource.NewQueryParamVerifier(dynamicClient, f.OpenAPIGetter(), resource.QueryParamDryRun)
|
||||
|
||||
cmdutil.PrintFlagsWithDryRunStrategy(o.PrintFlags, o.dryRunStrategy)
|
||||
printer, err := o.PrintFlags.ToPrinter()
|
||||
@ -521,13 +515,6 @@ func (o *EnvOptions) RunEnv() error {
|
||||
continue
|
||||
}
|
||||
|
||||
if o.dryRunStrategy == cmdutil.DryRunServer {
|
||||
if err := o.dryRunVerifier.HasSupport(info.Mapping.GroupVersionKind); err != nil {
|
||||
allErrs = append(allErrs, err)
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
actual, err := resource.
|
||||
NewHelper(info.Client, info.Mapping).
|
||||
DryRun(o.dryRunStrategy == cmdutil.DryRunServer).
|
||||
|
@ -47,7 +47,6 @@ type SetImageOptions struct {
|
||||
Infos []*resource.Info
|
||||
Selector string
|
||||
DryRunStrategy cmdutil.DryRunStrategy
|
||||
DryRunVerifier *resource.QueryParamVerifier
|
||||
All bool
|
||||
Output string
|
||||
Local bool
|
||||
@ -154,11 +153,7 @@ func (o *SetImageOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args [
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
dynamicClient, err := f.DynamicClient()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
o.DryRunVerifier = resource.NewQueryParamVerifier(dynamicClient, f.OpenAPIGetter(), resource.QueryParamDryRun)
|
||||
|
||||
o.Output = cmdutil.GetFlagString(cmd, "output")
|
||||
o.ResolveImage = ImageResolver
|
||||
|
||||
@ -284,11 +279,6 @@ func (o *SetImageOptions) Run() error {
|
||||
continue
|
||||
}
|
||||
|
||||
if o.DryRunStrategy == cmdutil.DryRunServer {
|
||||
if err := o.DryRunVerifier.HasSupport(info.Mapping.GroupVersionKind); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
// patch the change
|
||||
actual, err := resource.
|
||||
NewHelper(info.Client, info.Mapping).
|
||||
|
@ -86,7 +86,6 @@ type SetResourcesOptions struct {
|
||||
|
||||
UpdatePodSpecForObject polymorphichelpers.UpdatePodSpecForObjectFunc
|
||||
Resources []string
|
||||
DryRunVerifier *resource.QueryParamVerifier
|
||||
|
||||
genericclioptions.IOStreams
|
||||
}
|
||||
@ -157,11 +156,6 @@ func (o *SetResourcesOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, ar
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
dynamicClient, err := f.DynamicClient()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
o.DryRunVerifier = resource.NewQueryParamVerifier(dynamicClient, f.OpenAPIGetter(), resource.QueryParamDryRun)
|
||||
|
||||
cmdutil.PrintFlagsWithDryRunStrategy(o.PrintFlags, o.DryRunStrategy)
|
||||
printer, err := o.PrintFlags.ToPrinter()
|
||||
@ -288,13 +282,6 @@ func (o *SetResourcesOptions) Run() error {
|
||||
continue
|
||||
}
|
||||
|
||||
if o.DryRunStrategy == cmdutil.DryRunServer {
|
||||
if err := o.DryRunVerifier.HasSupport(info.Mapping.GroupVersionKind); err != nil {
|
||||
allErrs = append(allErrs, fmt.Errorf("failed to patch resources update to pod template %v", err))
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
actual, err := resource.
|
||||
NewHelper(info.Client, info.Mapping).
|
||||
DryRun(o.DryRunStrategy == cmdutil.DryRunServer).
|
||||
|
@ -45,7 +45,6 @@ type SetSelectorOptions struct {
|
||||
PrintFlags *genericclioptions.PrintFlags
|
||||
RecordFlags *genericclioptions.RecordFlags
|
||||
dryRunStrategy cmdutil.DryRunStrategy
|
||||
dryRunVerifier *resource.QueryParamVerifier
|
||||
fieldManager string
|
||||
|
||||
// set by args
|
||||
@ -136,11 +135,6 @@ func (o *SetSelectorOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, arg
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
dynamicClient, err := f.DynamicClient()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
o.dryRunVerifier = resource.NewQueryParamVerifier(dynamicClient, f.OpenAPIGetter(), resource.QueryParamDryRun)
|
||||
|
||||
o.resources, o.selector, err = getResourcesAndSelector(args)
|
||||
if err != nil {
|
||||
@ -216,11 +210,6 @@ func (o *SetSelectorOptions) RunSelector() error {
|
||||
if !o.WriteToServer {
|
||||
return o.PrintObj(info.Object, o.Out)
|
||||
}
|
||||
if o.dryRunStrategy == cmdutil.DryRunServer {
|
||||
if err := o.dryRunVerifier.HasSupport(info.Mapping.GroupVersionKind); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
actual, err := resource.
|
||||
NewHelper(info.Client, info.Mapping).
|
||||
|
@ -63,7 +63,6 @@ type SetServiceAccountOptions struct {
|
||||
|
||||
fileNameOptions resource.FilenameOptions
|
||||
dryRunStrategy cmdutil.DryRunStrategy
|
||||
dryRunVerifier *resource.QueryParamVerifier
|
||||
shortOutput bool
|
||||
all bool
|
||||
output string
|
||||
@ -138,11 +137,6 @@ func (o *SetServiceAccountOptions) Complete(f cmdutil.Factory, cmd *cobra.Comman
|
||||
if o.local && o.dryRunStrategy == cmdutil.DryRunServer {
|
||||
return fmt.Errorf("cannot specify --local and --dry-run=server - did you mean --dry-run=client?")
|
||||
}
|
||||
dynamicClient, err := f.DynamicClient()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
o.dryRunVerifier = resource.NewQueryParamVerifier(dynamicClient, f.OpenAPIGetter(), resource.QueryParamDryRun)
|
||||
o.output = cmdutil.GetFlagString(cmd, "output")
|
||||
o.updatePodSpecForObject = polymorphichelpers.UpdatePodSpecForObjectFn
|
||||
|
||||
@ -210,12 +204,6 @@ func (o *SetServiceAccountOptions) Run() error {
|
||||
}
|
||||
continue
|
||||
}
|
||||
if o.dryRunStrategy == cmdutil.DryRunServer {
|
||||
if err := o.dryRunVerifier.HasSupport(info.Mapping.GroupVersionKind); err != nil {
|
||||
patchErrs = append(patchErrs, err)
|
||||
continue
|
||||
}
|
||||
}
|
||||
actual, err := resource.
|
||||
NewHelper(info.Client, info.Mapping).
|
||||
DryRun(o.dryRunStrategy == cmdutil.DryRunServer).
|
||||
|
@ -66,7 +66,6 @@ type SubjectOptions struct {
|
||||
Output string
|
||||
All bool
|
||||
DryRunStrategy cmdutil.DryRunStrategy
|
||||
DryRunVerifier *resource.QueryParamVerifier
|
||||
Local bool
|
||||
fieldManager string
|
||||
|
||||
@ -128,11 +127,6 @@ func (o *SubjectOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
dynamicClient, err := f.DynamicClient()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
o.DryRunVerifier = resource.NewQueryParamVerifier(dynamicClient, f.OpenAPIGetter(), resource.QueryParamDryRun)
|
||||
|
||||
cmdutil.PrintFlagsWithDryRunStrategy(o.PrintFlags, o.DryRunStrategy)
|
||||
printer, err := o.PrintFlags.ToPrinter()
|
||||
@ -270,12 +264,6 @@ func (o *SubjectOptions) Run(fn updateSubjects) error {
|
||||
continue
|
||||
}
|
||||
|
||||
if o.DryRunStrategy == cmdutil.DryRunServer {
|
||||
if err := o.DryRunVerifier.HasSupport(info.Mapping.GroupVersionKind); err != nil {
|
||||
allErrs = append(allErrs, err)
|
||||
continue
|
||||
}
|
||||
}
|
||||
actual, err := resource.
|
||||
NewHelper(info.Client, info.Mapping).
|
||||
DryRun(o.DryRunStrategy == cmdutil.DryRunServer).
|
||||
|
@ -48,7 +48,6 @@ type TaintOptions struct {
|
||||
ToPrinter func(string) (printers.ResourcePrinter, error)
|
||||
|
||||
DryRunStrategy cmdutil.DryRunStrategy
|
||||
DryRunVerifier *resource.QueryParamVerifier
|
||||
ValidationDirective string
|
||||
|
||||
resources []string
|
||||
@ -144,11 +143,6 @@ func (o *TaintOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []st
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
dynamicClient, err := f.DynamicClient()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
o.DryRunVerifier = resource.NewQueryParamVerifier(dynamicClient, f.OpenAPIGetter(), resource.QueryParamDryRun)
|
||||
cmdutil.PrintFlagsWithDryRunStrategy(o.PrintFlags, o.DryRunStrategy)
|
||||
|
||||
o.ValidationDirective, err = cmdutil.GetValidationDirective(cmd)
|
||||
@ -332,11 +326,6 @@ func (o TaintOptions) RunTaint() error {
|
||||
}
|
||||
|
||||
mapping := info.ResourceMapping()
|
||||
if o.DryRunStrategy == cmdutil.DryRunServer {
|
||||
if err := o.DryRunVerifier.HasSupport(mapping.GroupVersionKind); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
client, err := o.ClientForMapping(mapping)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -83,7 +83,6 @@ type Helper struct {
|
||||
ErrOut io.Writer
|
||||
|
||||
DryRunStrategy cmdutil.DryRunStrategy
|
||||
DryRunVerifier *resource.QueryParamVerifier
|
||||
|
||||
// OnPodDeletedOrEvicted is called when a pod is evicted/deleted; for printing progress output
|
||||
OnPodDeletedOrEvicted func(pod *corev1.Pod, usingEviction bool)
|
||||
@ -135,22 +134,11 @@ func (d *Helper) makeDeleteOptions() metav1.DeleteOptions {
|
||||
|
||||
// DeletePod will delete the given pod, or return an error if it couldn't
|
||||
func (d *Helper) DeletePod(pod corev1.Pod) error {
|
||||
if d.DryRunStrategy == cmdutil.DryRunServer {
|
||||
if err := d.DryRunVerifier.HasSupport(pod.GroupVersionKind()); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return d.Client.CoreV1().Pods(pod.Namespace).Delete(d.getContext(), pod.Name, d.makeDeleteOptions())
|
||||
}
|
||||
|
||||
// EvictPod will evict the given pod, or return an error if it couldn't
|
||||
func (d *Helper) EvictPod(pod corev1.Pod, evictionGroupVersion schema.GroupVersion) error {
|
||||
if d.DryRunStrategy == cmdutil.DryRunServer {
|
||||
if err := d.DryRunVerifier.HasSupport(pod.GroupVersionKind()); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
delOpts := d.makeDeleteOptions()
|
||||
|
||||
switch evictionGroupVersion {
|
||||
|
Loading…
Reference in New Issue
Block a user