Skip to content

Commit

Permalink
implemented --local flag to replace --dry-run
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobTanenbaum committed Oct 19, 2016
1 parent 49d547e commit fd4a40e
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 22 deletions.
4 changes: 2 additions & 2 deletions contrib/completions/bash/oc
Original file line number Diff line number Diff line change
Expand Up @@ -13246,13 +13246,13 @@ _oc_set_resources()
flags+=("--containers=")
two_word_flags+=("-c")
local_nonpersistent_flags+=("--containers=")
flags+=("--dry-run")
local_nonpersistent_flags+=("--dry-run")
flags+=("--filename=")
two_word_flags+=("-f")
local_nonpersistent_flags+=("--filename=")
flags+=("--limits=")
local_nonpersistent_flags+=("--limits=")
flags+=("--local")
local_nonpersistent_flags+=("--local")
flags+=("--no-headers")
local_nonpersistent_flags+=("--no-headers")
flags+=("--output=")
Expand Down
4 changes: 2 additions & 2 deletions contrib/completions/bash/openshift
Original file line number Diff line number Diff line change
Expand Up @@ -17834,13 +17834,13 @@ _openshift_cli_set_resources()
flags+=("--containers=")
two_word_flags+=("-c")
local_nonpersistent_flags+=("--containers=")
flags+=("--dry-run")
local_nonpersistent_flags+=("--dry-run")
flags+=("--filename=")
two_word_flags+=("-f")
local_nonpersistent_flags+=("--filename=")
flags+=("--limits=")
local_nonpersistent_flags+=("--limits=")
flags+=("--local")
local_nonpersistent_flags+=("--local")
flags+=("--no-headers")
local_nonpersistent_flags+=("--no-headers")
flags+=("--output=")
Expand Down
4 changes: 2 additions & 2 deletions contrib/completions/zsh/oc
Original file line number Diff line number Diff line change
Expand Up @@ -13407,13 +13407,13 @@ _oc_set_resources()
flags+=("--containers=")
two_word_flags+=("-c")
local_nonpersistent_flags+=("--containers=")
flags+=("--dry-run")
local_nonpersistent_flags+=("--dry-run")
flags+=("--filename=")
two_word_flags+=("-f")
local_nonpersistent_flags+=("--filename=")
flags+=("--limits=")
local_nonpersistent_flags+=("--limits=")
flags+=("--local")
local_nonpersistent_flags+=("--local")
flags+=("--no-headers")
local_nonpersistent_flags+=("--no-headers")
flags+=("--output=")
Expand Down
4 changes: 2 additions & 2 deletions contrib/completions/zsh/openshift
Original file line number Diff line number Diff line change
Expand Up @@ -17995,13 +17995,13 @@ _openshift_cli_set_resources()
flags+=("--containers=")
two_word_flags+=("-c")
local_nonpersistent_flags+=("--containers=")
flags+=("--dry-run")
local_nonpersistent_flags+=("--dry-run")
flags+=("--filename=")
two_word_flags+=("-f")
local_nonpersistent_flags+=("--filename=")
flags+=("--limits=")
local_nonpersistent_flags+=("--limits=")
flags+=("--local")
local_nonpersistent_flags+=("--local")
flags+=("--no-headers")
local_nonpersistent_flags+=("--no-headers")
flags+=("--output=")
Expand Down
2 changes: 1 addition & 1 deletion docs/generated/oc_by_example_content.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2715,7 +2715,7 @@ oc set resources deployment nginx --limits=cpu=0,memory=0 --requests=cpu=0,memor
# Print the result (in yaml format) of updating nginx container limits from a local, without hitting the server
oc set resources -f path/to/file.yaml --limits=cpu=200m,memory=512Mi --dry-run -o yaml
oc set resources -f path/to/file.yaml --limits=cpu=200m,memory=512Mi --local -o yaml
----
====
Expand Down
10 changes: 5 additions & 5 deletions docs/man/man1/oc-set-resources.1
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ Possible resources include (case insensitive):
\fB\-c\fP, \fB\-\-containers\fP="*"
The names of containers in the selected pod templates to change, all containers are selected by default \- may use wildcards

.PP
\fB\-\-dry\-run\fP=false
If true, only print the object that would be sent, without sending it.

.PP
\fB\-f\fP, \fB\-\-filename\fP=[]
Filename, directory or URL to file to use to edit the resource
Expand All @@ -44,6 +40,10 @@ Possible resources include (case insensitive):
\fB\-\-limits\fP=""
The resource requirement requests for this container. For example, 'cpu=100m,memory=256Mi'. Note that server side components may assign requests depending on the server configuration, such as limit ranges.

.PP
\fB\-\-local\fP=false
If true set resources will NOT contact api\-server but run locally.

.PP
\fB\-\-no\-headers\fP=false
When using the default or custom\-column output format, don't print headers.
Expand Down Expand Up @@ -176,7 +176,7 @@ oc set resources deployment nginx \-\-limits=cpu=0,memory=0 \-\-requests=cpu=0,m

# Print the result (in yaml format) of updating nginx container limits from a local, without hitting the server

oc set resources \-f path/to/file.yaml \-\-limits=cpu=200m,memory=512Mi \-\-dry\-run \-o yaml
oc set resources \-f path/to/file.yaml \-\-limits=cpu=200m,memory=512Mi \-\-local \-o yaml


.fi
Expand Down
10 changes: 5 additions & 5 deletions docs/man/man1/openshift-cli-set-resources.1
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ Possible resources include (case insensitive):
\fB\-c\fP, \fB\-\-containers\fP="*"
The names of containers in the selected pod templates to change, all containers are selected by default \- may use wildcards

.PP
\fB\-\-dry\-run\fP=false
If true, only print the object that would be sent, without sending it.

.PP
\fB\-f\fP, \fB\-\-filename\fP=[]
Filename, directory or URL to file to use to edit the resource
Expand All @@ -44,6 +40,10 @@ Possible resources include (case insensitive):
\fB\-\-limits\fP=""
The resource requirement requests for this container. For example, 'cpu=100m,memory=256Mi'. Note that server side components may assign requests depending on the server configuration, such as limit ranges.

.PP
\fB\-\-local\fP=false
If true set resources will NOT contact api\-server but run locally.

.PP
\fB\-\-no\-headers\fP=false
When using the default or custom\-column output format, don't print headers.
Expand Down Expand Up @@ -176,7 +176,7 @@ oc set resources deployment nginx \-\-limits=cpu=0,memory=0 \-\-requests=cpu=0,m

# Print the result (in yaml format) of updating nginx container limits from a local, without hitting the server

oc set resources \-f path/to/file.yaml \-\-limits=cpu=200m,memory=512Mi \-\-dry\-run \-o yaml
oc set resources \-f path/to/file.yaml \-\-limits=cpu=200m,memory=512Mi \-\-local \-o yaml


.fi
Expand Down
7 changes: 4 additions & 3 deletions pkg/cmd/cli/cmd/set/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type ResourceOptions struct {
All bool
Record bool
ChangeCause string
Local bool
Cmd *cobra.Command

Limits string
Expand Down Expand Up @@ -67,7 +68,7 @@ oc set resources deployment nginx --limits=cpu=0,memory=0 --requests=cpu=0,memor
# Print the result (in yaml format) of updating nginx container limits from a local, without hitting the server
oc set resources -f path/to/file.yaml --limits=cpu=200m,memory=512Mi --dry-run -o yaml
oc set resources -f path/to/file.yaml --limits=cpu=200m,memory=512Mi --local -o yaml
`
)

Expand All @@ -93,7 +94,7 @@ func NewCmdResources(f *clientcmd.Factory, out io.Writer, errOut io.Writer) *cob
cmd.Flags().BoolVar(&options.All, "all", options.All, "Select all resources in the namespace of the specified resource types")
cmd.Flags().StringVarP(&options.Selector, "selector", "l", "", "Selector (label query) to filter on")
cmd.Flags().StringVarP(&options.ContainerSelector, "containers", "c", "*", "The names of containers in the selected pod templates to change, all containers are selected by default - may use wildcards")
kcmdutil.AddDryRunFlag(cmd)
cmd.Flags().BoolVar(&options.Local, "local", false, "If true set resources will NOT contact api-server but run locally.")
kcmdutil.AddRecordFlag(cmd)
cmd.Flags().StringVar(&options.Limits, "limits", options.Limits, "The resource requirement requests for this container. For example, 'cpu=100m,memory=256Mi'. Note that server side components may assign requests depending on the server configuration, such as limit ranges.")
cmd.Flags().StringVar(&options.Requests, "requests", options.Requests, "The resource requirement requests for this container. For example, 'cpu=100m,memory=256Mi'. Note that server side components may assign requests depending on the server configuration, such as limit ranges.")
Expand Down Expand Up @@ -193,7 +194,7 @@ func (o *ResourceOptions) Run() error {
continue
}

if kcmdutil.GetDryRunFlag(o.Cmd) {
if o.Local {
fmt.Fprintln(o.Err, "info: running in local mode...")
return o.PrintObject(o.Cmd, o.Mapper, info.Object, o.Out)
}
Expand Down

0 comments on commit fd4a40e

Please sign in to comment.