Skip to content
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
8 changes: 8 additions & 0 deletions hack/test-end-to-end.sh
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,14 @@ wait_for_command '[[ "$(osc get endpoints router -t "{{ if .endpoints }}{{ len .
echo "[INFO] Validating routed app response..."
validate_response "-s -k --resolve www.example.com:443:${CONTAINER_ACCESSIBLE_API_HOST} https://www.example.com" "Hello from OpenShift" 0.2 50

# Remote command execution
registry_pod=$(osc get pod | grep docker-registry | awk '{print $1}')
osc exec -p ${registry_pod} whoami | grep root

# Port forwarding
osc port-forward -p ${registry_pod} 5001:5000 &
wait_for_url_timed "http://localhost:5001/" "[INFO] Docker registry says: " $((10*TIME_SEC))

# UI e2e tests can be found in assets/test/e2e
if [[ "$TEST_ASSETS" == "true" ]]; then
echo "[INFO] Running UI e2e tests..."
Expand Down
2 changes: 2 additions & 0 deletions pkg/cmd/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ func NewCommandCLI(name, fullName string) *cobra.Command {
cmds.AddCommand(cmd.NewCmdUpdate(fullName, f, out))
cmds.AddCommand(cmd.NewCmdDelete(fullName, f, out))
cmds.AddCommand(cmd.NewCmdLog(fullName, f, out))
cmds.AddCommand(cmd.NewCmdExec(fullName, f, os.Stdin, out, os.Stderr))
cmds.AddCommand(cmd.NewCmdPortForward(fullName, f))
cmds.AddCommand(f.NewCmdProxy(out))
cmds.AddCommand(kubecmd.NewCmdNamespace(out))
cmds.AddCommand(cmd.NewCmdProject(f, out))
Expand Down
40 changes: 39 additions & 1 deletion pkg/cmd/cli/cmd/wrappers.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ Examples:
func NewCmdCreate(fullName string, f *clientcmd.Factory, out io.Writer) *cobra.Command {
cmd := f.NewCmdCreate(out)
longDesc := `Create a resource by filename or stdin.

JSON and YAML formats are accepted.

Examples:
Expand All @@ -121,3 +121,41 @@ Examples:
cmd.Long = fmt.Sprintf(longDesc, fullName)
return cmd
}

func NewCmdExec(fullName string, f *clientcmd.Factory, cmdIn io.Reader, cmdOut, cmdErr io.Writer) *cobra.Command {
cmd := f.NewCmdExec(cmdIn, cmdOut, cmdErr)
longDesc := `Execute a command in a container.

Examples:

# get output from running 'date' in ruby-container from pod 123456-7890
$ %[1]s exec -p 123456-7890 -c ruby-container date

# switch to raw terminal mode, sends stdin to 'bash' in ruby-container from pod 123456-780 and sends stdout/stderr from 'bash' back to the client
$ %[1]s exec -p 123456-7890 -c ruby-container -i -t -- bash -il
`
cmd.Long = fmt.Sprintf(longDesc, fullName)
return cmd
}

func NewCmdPortForward(fullName string, f *clientcmd.Factory) *cobra.Command {
cmd := f.NewCmdPortForward()
longDesc := `Forward 1 or more local ports to a pod.

Examples:

# listens on ports 5000 and 6000 locally, forwarding data to/from ports 5000 and 6000 in the pod
$ %[1]s port-forward -p mypod 5000 6000

# listens on port 8888 locally, forwarding to 5000 in the pod
$ %[1]s port-forward -p mypod 8888:5000

# listens on a random port locally, forwarding to 5000 in the pod
$ %[1]s port-forward -p mypod :5000

# listens on a random port locally, forwarding to 5000 in the pod
$ %[1]s port-forward -p mypod 0:5000
`
cmd.Long = fmt.Sprintf(longDesc, fullName)
return cmd
}