| ... | ... |
@@ -290,6 +290,14 @@ wait_for_command '[[ "$(osc get endpoints router -t "{{ if .endpoints }}{{ len .
|
| 290 | 290 |
echo "[INFO] Validating routed app response..." |
| 291 | 291 |
validate_response "-s -k --resolve www.example.com:443:${CONTAINER_ACCESSIBLE_API_HOST} https://www.example.com" "Hello from OpenShift" 0.2 50
|
| 292 | 292 |
|
| 293 |
+# Remote command execution |
|
| 294 |
+registry_pod=$(osc get pod | grep docker-registry | awk '{print $1}')
|
|
| 295 |
+osc exec -p ${registry_pod} whoami | grep root
|
|
| 296 |
+ |
|
| 297 |
+# Port forwarding |
|
| 298 |
+osc port-forward -p ${registry_pod} 5001:5000 &
|
|
| 299 |
+wait_for_url_timed "http://localhost:5001/" "[INFO] Docker registry says: " $((10*TIME_SEC)) |
|
| 300 |
+ |
|
| 293 | 301 |
# UI e2e tests can be found in assets/test/e2e |
| 294 | 302 |
if [[ "$TEST_ASSETS" == "true" ]]; then |
| 295 | 303 |
echo "[INFO] Running UI e2e tests..." |
| ... | ... |
@@ -76,6 +76,8 @@ func NewCommandCLI(name, fullName string) *cobra.Command {
|
| 76 | 76 |
cmds.AddCommand(cmd.NewCmdUpdate(fullName, f, out)) |
| 77 | 77 |
cmds.AddCommand(cmd.NewCmdDelete(fullName, f, out)) |
| 78 | 78 |
cmds.AddCommand(cmd.NewCmdLog(fullName, f, out)) |
| 79 |
+ cmds.AddCommand(cmd.NewCmdExec(fullName, f, os.Stdin, out, os.Stderr)) |
|
| 80 |
+ cmds.AddCommand(cmd.NewCmdPortForward(fullName, f)) |
|
| 79 | 81 |
cmds.AddCommand(f.NewCmdProxy(out)) |
| 80 | 82 |
cmds.AddCommand(kubecmd.NewCmdNamespace(out)) |
| 81 | 83 |
cmds.AddCommand(cmd.NewCmdProject(f, out)) |
| ... | ... |
@@ -107,7 +107,7 @@ Examples: |
| 107 | 107 |
func NewCmdCreate(fullName string, f *clientcmd.Factory, out io.Writer) *cobra.Command {
|
| 108 | 108 |
cmd := f.NewCmdCreate(out) |
| 109 | 109 |
longDesc := `Create a resource by filename or stdin. |
| 110 |
- |
|
| 110 |
+ |
|
| 111 | 111 |
JSON and YAML formats are accepted. |
| 112 | 112 |
|
| 113 | 113 |
Examples: |
| ... | ... |
@@ -121,3 +121,41 @@ Examples: |
| 121 | 121 |
cmd.Long = fmt.Sprintf(longDesc, fullName) |
| 122 | 122 |
return cmd |
| 123 | 123 |
} |
| 124 |
+ |
|
| 125 |
+func NewCmdExec(fullName string, f *clientcmd.Factory, cmdIn io.Reader, cmdOut, cmdErr io.Writer) *cobra.Command {
|
|
| 126 |
+ cmd := f.NewCmdExec(cmdIn, cmdOut, cmdErr) |
|
| 127 |
+ longDesc := `Execute a command in a container. |
|
| 128 |
+ |
|
| 129 |
+Examples: |
|
| 130 |
+ |
|
| 131 |
+ # get output from running 'date' in ruby-container from pod 123456-7890 |
|
| 132 |
+ $ %[1]s exec -p 123456-7890 -c ruby-container date |
|
| 133 |
+ |
|
| 134 |
+ # 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 |
|
| 135 |
+ $ %[1]s exec -p 123456-7890 -c ruby-container -i -t -- bash -il |
|
| 136 |
+` |
|
| 137 |
+ cmd.Long = fmt.Sprintf(longDesc, fullName) |
|
| 138 |
+ return cmd |
|
| 139 |
+} |
|
| 140 |
+ |
|
| 141 |
+func NewCmdPortForward(fullName string, f *clientcmd.Factory) *cobra.Command {
|
|
| 142 |
+ cmd := f.NewCmdPortForward() |
|
| 143 |
+ longDesc := `Forward 1 or more local ports to a pod. |
|
| 144 |
+ |
|
| 145 |
+Examples: |
|
| 146 |
+ |
|
| 147 |
+ # listens on ports 5000 and 6000 locally, forwarding data to/from ports 5000 and 6000 in the pod |
|
| 148 |
+ $ %[1]s port-forward -p mypod 5000 6000 |
|
| 149 |
+ |
|
| 150 |
+ # listens on port 8888 locally, forwarding to 5000 in the pod |
|
| 151 |
+ $ %[1]s port-forward -p mypod 8888:5000 |
|
| 152 |
+ |
|
| 153 |
+ # listens on a random port locally, forwarding to 5000 in the pod |
|
| 154 |
+ $ %[1]s port-forward -p mypod :5000 |
|
| 155 |
+ |
|
| 156 |
+ # listens on a random port locally, forwarding to 5000 in the pod |
|
| 157 |
+ $ %[1]s port-forward -p mypod 0:5000 |
|
| 158 |
+` |
|
| 159 |
+ cmd.Long = fmt.Sprintf(longDesc, fullName) |
|
| 160 |
+ return cmd |
|
| 161 |
+} |