Skip to content

Commit 5fcd9c7

Browse files
Error if --local and --dry-run=server are passed
1 parent 89bd2bd commit 5fcd9c7

File tree

8 files changed

+24
-0
lines changed

8 files changed

+24
-0
lines changed

staging/src/k8s.io/kubectl/pkg/cmd/annotate/annotate.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,9 @@ func (o AnnotateOptions) Validate() error {
223223
return fmt.Errorf("one or more resources must be specified as <resource> <name> or <resource>/<name>")
224224
}
225225
} else {
226+
if o.dryRunStrategy == cmdutil.DryRunServer {
227+
return fmt.Errorf("cannot specify --local and --dry-run=server - did you mean --dry-run=client?")
228+
}
226229
if len(o.resources) > 0 {
227230
return fmt.Errorf("can only use local files by -f rsrc.yaml or --filename=rsrc.json when --local=true is set")
228231
}

staging/src/k8s.io/kubectl/pkg/cmd/label/label.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,9 @@ func (o *LabelOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []st
211211

212212
// Validate checks to the LabelOptions to see if there is sufficient information run the command.
213213
func (o *LabelOptions) Validate() error {
214+
if o.local && o.dryRunStrategy == cmdutil.DryRunServer {
215+
return fmt.Errorf("cannot specify --local and --dry-run=server - did you mean --dry-run=client?")
216+
}
214217
if o.all && len(o.selector) > 0 {
215218
return fmt.Errorf("cannot set --all and --selector at the same time")
216219
}

staging/src/k8s.io/kubectl/pkg/cmd/patch/patch.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,9 @@ func (o *PatchOptions) Validate() error {
176176
if o.Local && len(o.args) != 0 {
177177
return fmt.Errorf("cannot specify --local and server resources")
178178
}
179+
if o.Local && o.dryRunStrategy == cmdutil.DryRunServer {
180+
return fmt.Errorf("cannot specify --local and --dry-run=server - did you mean --dry-run=client?")
181+
}
179182
if len(o.Patch) == 0 {
180183
return fmt.Errorf("must specify -p to patch")
181184
}

staging/src/k8s.io/kubectl/pkg/cmd/set/set_env.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,9 @@ func (o *EnvOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []stri
254254

255255
// Validate makes sure provided values for EnvOptions are valid
256256
func (o *EnvOptions) Validate() error {
257+
if o.Local && o.dryRunStrategy == cmdutil.DryRunServer {
258+
return fmt.Errorf("cannot specify --local and --dry-run=server - did you mean --dry-run=client?")
259+
}
257260
if len(o.Filenames) == 0 && len(o.resources) < 1 {
258261
return fmt.Errorf("one or more resources must be specified as <resource> <name> or <resource>/<name>")
259262
}

staging/src/k8s.io/kubectl/pkg/cmd/set/set_image.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,9 @@ func (o *SetImageOptions) Validate() error {
216216
} else if len(o.ContainerImages) > 1 && hasWildcardKey(o.ContainerImages) {
217217
errors = append(errors, fmt.Errorf("all containers are already specified by *, but saw more than one container_name=container_image pairs"))
218218
}
219+
if o.Local && o.DryRunStrategy == cmdutil.DryRunServer {
220+
errors = append(errors, fmt.Errorf("cannot specify --local and --dry-run=server - did you mean --dry-run=client?"))
221+
}
219222
return utilerrors.NewAggregate(errors)
220223
}
221224

staging/src/k8s.io/kubectl/pkg/cmd/set/set_resources.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,9 @@ func (o *SetResourcesOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, ar
210210
// Validate makes sure that provided values in ResourcesOptions are valid
211211
func (o *SetResourcesOptions) Validate() error {
212212
var err error
213+
if o.Local && o.DryRunStrategy == cmdutil.DryRunServer {
214+
return fmt.Errorf("cannot specify --local and --dry-run=server - did you mean --dry-run=client?")
215+
}
213216
if o.All && len(o.Selector) > 0 {
214217
return fmt.Errorf("cannot set --all and --selector at the same time")
215218
}

staging/src/k8s.io/kubectl/pkg/cmd/set/set_serviceaccount.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,9 @@ func (o *SetServiceAccountOptions) Complete(f cmdutil.Factory, cmd *cobra.Comman
133133
if err != nil {
134134
return err
135135
}
136+
if o.local && o.dryRunStrategy == cmdutil.DryRunServer {
137+
return fmt.Errorf("cannot specify --local and --dry-run=server - did you mean --dry-run=client?")
138+
}
136139
dynamicClient, err := f.DynamicClient()
137140
if err != nil {
138141
return err

staging/src/k8s.io/kubectl/pkg/cmd/set/set_subject.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,9 @@ func (o *SubjectOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args []
181181

182182
// Validate makes sure provided values in SubjectOptions are valid
183183
func (o *SubjectOptions) Validate() error {
184+
if o.Local && o.DryRunStrategy == cmdutil.DryRunServer {
185+
return fmt.Errorf("cannot specify --local and --dry-run=server - did you mean --dry-run=client?")
186+
}
184187
if o.All && len(o.Selector) > 0 {
185188
return fmt.Errorf("cannot set --all and --selector at the same time")
186189
}

0 commit comments

Comments
 (0)