Browse code

oc: generate path-based routes in expose

Michail Kargakis authored on 2016/01/26 02:22:34
Showing 5 changed files
... ...
@@ -2154,6 +2154,7 @@ _oc_expose()
2154 2154
     two_word_flags+=("-o")
2155 2155
     flags+=("--output-version=")
2156 2156
     flags+=("--overrides=")
2157
+    flags+=("--path=")
2157 2158
     flags+=("--port=")
2158 2159
     flags+=("--protocol=")
2159 2160
     flags+=("--save-config")
... ...
@@ -7219,6 +7219,7 @@ _openshift_cli_expose()
7219 7219
     two_word_flags+=("-o")
7220 7220
     flags+=("--output-version=")
7221 7221
     flags+=("--overrides=")
7222
+    flags+=("--path=")
7222 7223
     flags+=("--port=")
7223 7224
     flags+=("--protocol=")
7224 7225
     flags+=("--save-config")
... ...
@@ -385,6 +385,9 @@ Expose a replicated application as a service or route
385 385
 
386 386
   # Expose a deployment configuration as a service and use the specified port
387 387
   $ oc expose dc ruby-hello-world --port=8080
388
+
389
+  # Expose a service as a route in the specified path
390
+  $ oc expose service nginx --path=/nginx
388 391
 ----
389 392
 ====
390 393
 
... ...
@@ -32,7 +32,10 @@ labels from the object it exposes.`
32 32
   $ %[1]s expose service nginx --hostname=www.example.com
33 33
 
34 34
   # Expose a deployment configuration as a service and use the specified port
35
-  $ %[1]s expose dc ruby-hello-world --port=8080`
35
+  $ %[1]s expose dc ruby-hello-world --port=8080
36
+
37
+  # Expose a service as a route in the specified path
38
+  $ %[1]s expose service nginx --path=/nginx`
36 39
 )
37 40
 
38 41
 // NewCmdExpose is a wrapper for the Kubernetes cli expose command
... ...
@@ -57,6 +60,7 @@ func NewCmdExpose(fullName string, f *clientcmd.Factory, out io.Writer) *cobra.C
57 57
 		defRun(cmd, args)
58 58
 	}
59 59
 	cmd.Flags().String("hostname", "", "Set a hostname for the new route")
60
+	cmd.Flags().String("path", "", "Set a path for the new route")
60 61
 	return cmd
61 62
 }
62 63
 
... ...
@@ -163,6 +167,9 @@ func validateFlags(cmd *cobra.Command, generator string) error {
163 163
 		if len(cmdutil.GetFlagString(cmd, "hostname")) != 0 {
164 164
 			invalidFlags = append(invalidFlags, "--hostname")
165 165
 		}
166
+		if len(cmdutil.GetFlagString(cmd, "path")) != 0 {
167
+			invalidFlags = append(invalidFlags, "--path")
168
+		}
166 169
 	case "route/v1":
167 170
 		if len(cmdutil.GetFlagString(cmd, "protocol")) != 0 {
168 171
 			invalidFlags = append(invalidFlags, "--protocol")
... ...
@@ -67,6 +67,7 @@ func (RouteGenerator) Generate(genericParams map[string]interface{}) (runtime.Ob
67 67
 		},
68 68
 		Spec: api.RouteSpec{
69 69
 			Host: params["hostname"],
70
+			Path: params["path"],
70 71
 			To: kapi.ObjectReference{
71 72
 				Name: params["default-name"],
72 73
 			},