Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions staging/src/k8s.io/kubectl/pkg/cmd/annotate/annotate.go
Expand Up @@ -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")
}
Expand Down
3 changes: 3 additions & 0 deletions staging/src/k8s.io/kubectl/pkg/cmd/label/label.go
Expand Up @@ -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")
}
Expand Down
3 changes: 3 additions & 0 deletions staging/src/k8s.io/kubectl/pkg/cmd/patch/patch.go
Expand Up @@ -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")
}
Expand Down
3 changes: 3 additions & 0 deletions staging/src/k8s.io/kubectl/pkg/cmd/set/set_env.go
Expand Up @@ -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>")
}
Expand Down
3 changes: 3 additions & 0 deletions staging/src/k8s.io/kubectl/pkg/cmd/set/set_image.go
Expand Up @@ -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)
}

Expand Down
3 changes: 3 additions & 0 deletions staging/src/k8s.io/kubectl/pkg/cmd/set/set_resources.go
Expand Up @@ -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")
}
Expand Down
3 changes: 3 additions & 0 deletions staging/src/k8s.io/kubectl/pkg/cmd/set/set_serviceaccount.go
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions staging/src/k8s.io/kubectl/pkg/cmd/set/set_subject.go
Expand Up @@ -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")
}
Expand Down