Error if --local and --dry-run=server are passed

Kubernetes-commit: 5fcd9c7c7ec432dd27e770e49e0e6872335c765d
This commit is contained in:
Julian V. Modesto 2020-02-13 16:44:14 -05:00 committed by Kubernetes Publisher
parent 715cba8fd6
commit 9c04919f3b
8 changed files with 24 additions and 0 deletions

View File

@ -223,6 +223,9 @@ func (o AnnotateOptions) Validate() error {
return fmt.Errorf("one or more resources must be specified as <resource> <name> or <resource>/<name>")
}
} else {
if o.dryRunStrategy == cmdutil.DryRunServer {
return fmt.Errorf("cannot specify --local and --dry-run=server - did you mean --dry-run=client?")
}
if len(o.resources) > 0 {
return fmt.Errorf("can only use local files by -f rsrc.yaml or --filename=rsrc.json when --local=true is set")
}

View File

@ -211,6 +211,9 @@ func (o *LabelOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []st
// Validate checks to the LabelOptions to see if there is sufficient information run the command.
func (o *LabelOptions) Validate() error {
if o.local && o.dryRunStrategy == cmdutil.DryRunServer {
return fmt.Errorf("cannot specify --local and --dry-run=server - did you mean --dry-run=client?")
}
if o.all && len(o.selector) > 0 {
return fmt.Errorf("cannot set --all and --selector at the same time")
}

View File

@ -176,6 +176,9 @@ func (o *PatchOptions) Validate() error {
if o.Local && len(o.args) != 0 {
return fmt.Errorf("cannot specify --local and server resources")
}
if o.Local && o.dryRunStrategy == cmdutil.DryRunServer {
return fmt.Errorf("cannot specify --local and --dry-run=server - did you mean --dry-run=client?")
}
if len(o.Patch) == 0 {
return fmt.Errorf("must specify -p to patch")
}

View File

@ -254,6 +254,9 @@ func (o *EnvOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []stri
// Validate makes sure provided values for EnvOptions are valid
func (o *EnvOptions) Validate() error {
if o.Local && o.dryRunStrategy == cmdutil.DryRunServer {
return fmt.Errorf("cannot specify --local and --dry-run=server - did you mean --dry-run=client?")
}
if len(o.Filenames) == 0 && len(o.resources) < 1 {
return fmt.Errorf("one or more resources must be specified as <resource> <name> or <resource>/<name>")
}

View File

@ -216,6 +216,9 @@ func (o *SetImageOptions) Validate() error {
} else if len(o.ContainerImages) > 1 && hasWildcardKey(o.ContainerImages) {
errors = append(errors, fmt.Errorf("all containers are already specified by *, but saw more than one container_name=container_image pairs"))
}
if o.Local && o.DryRunStrategy == cmdutil.DryRunServer {
errors = append(errors, fmt.Errorf("cannot specify --local and --dry-run=server - did you mean --dry-run=client?"))
}
return utilerrors.NewAggregate(errors)
}

View File

@ -210,6 +210,9 @@ func (o *SetResourcesOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, ar
// Validate makes sure that provided values in ResourcesOptions are valid
func (o *SetResourcesOptions) Validate() error {
var err error
if o.Local && o.DryRunStrategy == cmdutil.DryRunServer {
return fmt.Errorf("cannot specify --local and --dry-run=server - did you mean --dry-run=client?")
}
if o.All && len(o.Selector) > 0 {
return fmt.Errorf("cannot set --all and --selector at the same time")
}

View File

@ -133,6 +133,9 @@ func (o *SetServiceAccountOptions) Complete(f cmdutil.Factory, cmd *cobra.Comman
if err != nil {
return err
}
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

View File

@ -181,6 +181,9 @@ func (o *SubjectOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []
// Validate makes sure provided values in SubjectOptions are valid
func (o *SubjectOptions) Validate() error {
if o.Local && o.DryRunStrategy == cmdutil.DryRunServer {
return fmt.Errorf("cannot specify --local and --dry-run=server - did you mean --dry-run=client?")
}
if o.All && len(o.Selector) > 0 {
return fmt.Errorf("cannot set --all and --selector at the same time")
}