@@ -238,10 +238,6 @@ func (k *kubectlResourceOperations) ReplaceResource(ctx context.Context, obj *un
238238 return err
239239 }
240240
241- if err := replaceOptions .Validate (); err != nil {
242- return fmt .Errorf ("error validating replace options: %w" , err )
243- }
244-
245241 return replaceOptions .Run (k .fact )
246242 })
247243}
@@ -433,6 +429,10 @@ func (k *kubectlServerSideDiffDryRunApplier) newApplyOptions(ioStreams genericcl
433429 }
434430
435431 o .ForceConflicts = true
432+
433+ if err := o .Validate (); err != nil {
434+ return nil , fmt .Errorf ("error validating options: %w" , err )
435+ }
436436 return o , nil
437437}
438438
@@ -462,6 +462,10 @@ func (k *kubectlResourceOperations) newApplyOptions(ioStreams genericclioptions.
462462 if serverSideApply {
463463 o .ForceConflicts = true
464464 }
465+
466+ if err := o .Validate (); err != nil {
467+ return nil , fmt .Errorf ("error validating options: %w" , err )
468+ }
465469 return o , nil
466470}
467471
@@ -496,6 +500,10 @@ func (k *kubectlResourceOperations) newCreateOptions(ioStreams genericclioptions
496500 return printer .PrintObj (obj , o .Out )
497501 }
498502 o .FilenameOptions .Filenames = []string {fileName }
503+
504+ if err := o .Validate (); err != nil {
505+ return nil , fmt .Errorf ("error validating options: %w" , err )
506+ }
499507 return o , nil
500508}
501509
@@ -551,6 +559,9 @@ func (k *kubectlResourceOperations) newReplaceOptions(config *rest.Config, f cmd
551559 o .DeleteOptions .ForceDeletion = force
552560 }
553561
562+ if err := o .Validate (); err != nil {
563+ return nil , fmt .Errorf ("error validating options: %w" , err )
564+ }
554565 return o , nil
555566}
556567
@@ -580,6 +591,10 @@ func newReconcileOptions(f cmdutil.Factory, kubeClient *kubernetes.Clientset, fi
580591 return nil , fmt .Errorf ("error configuring printer: %w" , err )
581592 }
582593 o .PrintObject = printer .PrintObj
594+
595+ if err := o .Validate (); err != nil {
596+ return nil , fmt .Errorf ("error validating options: %w" , err )
597+ }
583598 return o , nil
584599}
585600
0 commit comments