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

add --timeout flag to oc rsh #10745

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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions contrib/completions/bash/oc
Original file line number Diff line number Diff line change
Expand Up @@ -11720,6 +11720,8 @@ _oc_rsh()
local_nonpersistent_flags+=("--no-tty")
flags+=("--shell=")
local_nonpersistent_flags+=("--shell=")
flags+=("--timeout=")
local_nonpersistent_flags+=("--timeout=")
flags+=("--tty")
flags+=("-t")
local_nonpersistent_flags+=("--tty")
Expand Down
2 changes: 2 additions & 0 deletions contrib/completions/bash/openshift
Original file line number Diff line number Diff line change
Expand Up @@ -16285,6 +16285,8 @@ _openshift_cli_rsh()
local_nonpersistent_flags+=("--no-tty")
flags+=("--shell=")
local_nonpersistent_flags+=("--shell=")
flags+=("--timeout=")
local_nonpersistent_flags+=("--timeout=")
flags+=("--tty")
flags+=("-t")
local_nonpersistent_flags+=("--tty")
Expand Down
2 changes: 2 additions & 0 deletions contrib/completions/zsh/oc
Original file line number Diff line number Diff line change
Expand Up @@ -11882,6 +11882,8 @@ _oc_rsh()
local_nonpersistent_flags+=("--no-tty")
flags+=("--shell=")
local_nonpersistent_flags+=("--shell=")
flags+=("--timeout=")
local_nonpersistent_flags+=("--timeout=")
flags+=("--tty")
flags+=("-t")
local_nonpersistent_flags+=("--tty")
Expand Down
2 changes: 2 additions & 0 deletions contrib/completions/zsh/openshift
Original file line number Diff line number Diff line change
Expand Up @@ -16447,6 +16447,8 @@ _openshift_cli_rsh()
local_nonpersistent_flags+=("--no-tty")
flags+=("--shell=")
local_nonpersistent_flags+=("--shell=")
flags+=("--timeout=")
local_nonpersistent_flags+=("--timeout=")
flags+=("--tty")
flags+=("-t")
local_nonpersistent_flags+=("--tty")
Expand Down
4 changes: 4 additions & 0 deletions docs/man/man1/oc-rsh.1
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ directly.
\fB\-\-shell\fP="/bin/sh"
Path to the shell command

.PP
\fB\-\-timeout\fP=10
Request timeout for obtaining a pod from the server; defaults to 10 seconds

.PP
\fB\-t\fP, \fB\-\-tty\fP=false
Force a pseudo\-terminal to be allocated
Expand Down
4 changes: 4 additions & 0 deletions docs/man/man1/openshift-cli-rsh.1
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ directly.
\fB\-\-shell\fP="/bin/sh"
Path to the shell command

.PP
\fB\-\-timeout\fP=10
Request timeout for obtaining a pod from the server; defaults to 10 seconds

.PP
\fB\-t\fP, \fB\-\-tty\fP=false
Force a pseudo\-terminal to be allocated
Expand Down
6 changes: 4 additions & 2 deletions pkg/cmd/cli/cmd/rsh.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ type RshOptions struct {
ForceTTY bool
DisableTTY bool
Executable string
Timeout int
*kubecmd.ExecOptions
}

Expand All @@ -61,6 +62,7 @@ func NewCmdRsh(name string, parent string, f *clientcmd.Factory, in io.Reader, o
options := &RshOptions{
ForceTTY: false,
DisableTTY: false,
Timeout: 10,
ExecOptions: &kubecmd.ExecOptions{
StreamOptions: kubecmd.StreamOptions{
In: in,
Expand Down Expand Up @@ -89,6 +91,7 @@ func NewCmdRsh(name string, parent string, f *clientcmd.Factory, in io.Reader, o
cmd.Flags().BoolVarP(&options.ForceTTY, "tty", "t", false, "Force a pseudo-terminal to be allocated")
cmd.Flags().BoolVarP(&options.DisableTTY, "no-tty", "T", false, "Disable pseudo-terminal allocation")
cmd.Flags().StringVar(&options.Executable, "shell", "/bin/sh", "Path to the shell command")
cmd.Flags().IntVar(&options.Timeout, "timeout", 10, "Request timeout for obtaining a pod from the server; defaults to 10 seconds")
cmd.Flags().StringVarP(&options.ContainerName, "container", "c", "", "Container name; defaults to first container")
cmd.Flags().SetInterspersed(false)
return cmd
Expand Down Expand Up @@ -136,8 +139,7 @@ func (o *RshOptions) Complete(f *clientcmd.Factory, cmd *cobra.Command, args []s
}
o.Client = client

// TODO: Consider making the timeout configurable
o.PodName, err = f.PodForResource(resource, 10*time.Second)
o.PodName, err = f.PodForResource(resource, time.Duration(o.Timeout)*time.Second)
return err
}

Expand Down