Skip to content

Commit 5f39bce

Browse files
committed
add err message if <rsrc>/<name> pairs specified w/ --local flag
1 parent 44d77ae commit 5f39bce

File tree

8 files changed

+56
-0
lines changed

8 files changed

+56
-0
lines changed

pkg/oc/cli/cmd/set/buildhook.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,13 @@ func (o *BuildHookOptions) Complete(f *clientcmd.Factory, cmd *cobra.Command, ar
152152
if o.All {
153153
o.Builder.ResourceTypes("buildconfigs").SelectAllParam(o.All)
154154
}
155+
} else {
156+
// if a --local flag was provided, and a resource was specified in the form
157+
// <resource>/<name>, fail immediately as --local cannot query the api server
158+
// for the specified resource.
159+
if len(resources) > 0 {
160+
return resource.LocalResourceError
161+
}
155162
}
156163

157164
o.Output = kcmdutil.GetFlagString(cmd, "output")

pkg/oc/cli/cmd/set/buildsecret.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,13 @@ func (o *BuildSecretOptions) Complete(f *clientcmd.Factory, cmd *cobra.Command,
188188
if o.All {
189189
o.Builder.ResourceTypes(supportedBuildTypes...).SelectAllParam(o.All)
190190
}
191+
} else {
192+
// if a --local flag was provided, and a resource was specified in the form
193+
// <resource>/<name>, fail immediately as --local cannot query the api server
194+
// for the specified resource.
195+
if len(resources) > 0 {
196+
return resource.LocalResourceError
197+
}
191198
}
192199

193200
o.Output = kcmdutil.GetFlagString(cmd, "output")

pkg/oc/cli/cmd/set/deploymenthook.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,13 @@ func (o *DeploymentHookOptions) Complete(f *clientcmd.Factory, cmd *cobra.Comman
170170
o.Builder.ResourceTypes("deploymentconfigs").SelectAllParam(o.All)
171171
}
172172

173+
} else {
174+
// if a --local flag was provided, and a resource was specified in the form
175+
// <resource>/<name>, fail immediately as --local cannot query the api server
176+
// for the specified resource.
177+
if len(resources) > 0 {
178+
return resource.LocalResourceError
179+
}
173180
}
174181

175182
o.Output = kcmdutil.GetFlagString(cmd, "output")

pkg/oc/cli/cmd/set/env.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,13 @@ func (o *EnvOptions) RunEnv(f *clientcmd.Factory) error {
297297
b = b.
298298
SelectorParam(o.Selector).
299299
ResourceTypeOrNameArgs(o.All, o.Resources...)
300+
} else {
301+
// if a --local flag was provided, and a resource was specified in the form
302+
// <resource>/<name>, fail immediately as --local cannot query the api server
303+
// for the specified resource.
304+
if len(o.Resources) > 0 {
305+
return resource.LocalResourceError
306+
}
300307
}
301308

302309
one := false

pkg/oc/cli/cmd/set/probe.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,13 @@ func (o *ProbeOptions) Complete(f *clientcmd.Factory, cmd *cobra.Command, args [
191191
o.Builder = o.Builder.
192192
SelectorParam(o.Selector).
193193
ResourceTypeOrNameArgs(o.All, resources...)
194+
} else {
195+
// if a --local flag was provided, and a resource was specified in the form
196+
// <resource>/<name>, fail immediately as --local cannot query the api server
197+
// for the specified resource.
198+
if len(resources) > 0 {
199+
return resource.LocalResourceError
200+
}
194201
}
195202

196203
o.Output = kcmdutil.GetFlagString(cmd, "output")

pkg/oc/cli/cmd/set/routebackends.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,13 @@ func (o *BackendsOptions) Complete(f *clientcmd.Factory, cmd *cobra.Command, arg
175175
if len(resources) == 0 {
176176
o.Builder.ResourceTypes("routes")
177177
}
178+
} else {
179+
// if a --local flag was provided, and a resource was specified in the form
180+
// <resource>/<name>, fail immediately as --local cannot query the api server
181+
// for the specified resource.
182+
if len(resources) > 0 {
183+
return resource.LocalResourceError
184+
}
178185
}
179186

180187
o.Output = kcmdutil.GetFlagString(cmd, "output")

pkg/oc/cli/cmd/set/triggers.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,13 @@ func (o *TriggersOptions) Complete(f *clientcmd.Factory, cmd *cobra.Command, arg
230230
o.Builder = o.Builder.
231231
SelectorParam(o.Selector).
232232
ResourceTypeOrNameArgs(o.All, args...)
233+
} else {
234+
// if a --local flag was provided, and a resource was specified in the form
235+
// <resource>/<name>, fail immediately as --local cannot query the api server
236+
// for the specified resource.
237+
if len(args) > 0 {
238+
return resource.LocalResourceError
239+
}
233240
}
234241

235242
o.Output = kcmdutil.GetFlagString(cmd, "output")

pkg/oc/cli/cmd/set/volume.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,13 @@ func (v *VolumeOptions) RunVolume(args []string, f *clientcmd.Factory) error {
437437
b = b.
438438
SelectorParam(v.Selector).
439439
ResourceTypeOrNameArgs(v.All, args...)
440+
} else {
441+
// if a --local flag was provided, and a resource was specified in the form
442+
// <resource>/<name>, fail immediately as --local cannot query the api server
443+
// for the specified resource.
444+
if len(args) > 0 {
445+
return resource.LocalResourceError
446+
}
440447
}
441448

442449
singleItemImplied := false

0 commit comments

Comments
 (0)