Skip to content

Commit 2cfc860

Browse files
author
OpenShift Bot
authored
Merge pull request #12238 from JacobTanenbaum/BZ1391786-wildcardpolicy
Merged by openshift-bot
2 parents 8394f91 + d065f73 commit 2cfc860

File tree

9 files changed

+43
-2
lines changed

9 files changed

+43
-2
lines changed

contrib/completions/bash/oc

+2
Original file line numberDiff line numberDiff line change
@@ -9541,6 +9541,8 @@ _oc_expose()
95419541
local_nonpersistent_flags+=("--template=")
95429542
flags+=("--type=")
95439543
local_nonpersistent_flags+=("--type=")
9544+
flags+=("--wildcardpolicy=")
9545+
local_nonpersistent_flags+=("--wildcardpolicy=")
95449546
flags+=("--as=")
95459547
flags+=("--certificate-authority=")
95469548
flags_with_completion+=("--certificate-authority")

contrib/completions/bash/openshift

+2
Original file line numberDiff line numberDiff line change
@@ -14216,6 +14216,8 @@ _openshift_cli_expose()
1421614216
local_nonpersistent_flags+=("--template=")
1421714217
flags+=("--type=")
1421814218
local_nonpersistent_flags+=("--type=")
14219+
flags+=("--wildcardpolicy=")
14220+
local_nonpersistent_flags+=("--wildcardpolicy=")
1421914221
flags+=("--as=")
1422014222
flags+=("--certificate-authority=")
1422114223
flags_with_completion+=("--certificate-authority")

contrib/completions/zsh/oc

+2
Original file line numberDiff line numberDiff line change
@@ -9689,6 +9689,8 @@ _oc_expose()
96899689
local_nonpersistent_flags+=("--template=")
96909690
flags+=("--type=")
96919691
local_nonpersistent_flags+=("--type=")
9692+
flags+=("--wildcardpolicy=")
9693+
local_nonpersistent_flags+=("--wildcardpolicy=")
96929694
flags+=("--as=")
96939695
flags+=("--certificate-authority=")
96949696
flags_with_completion+=("--certificate-authority")

contrib/completions/zsh/openshift

+2
Original file line numberDiff line numberDiff line change
@@ -14364,6 +14364,8 @@ _openshift_cli_expose()
1436414364
local_nonpersistent_flags+=("--template=")
1436514365
flags+=("--type=")
1436614366
local_nonpersistent_flags+=("--type=")
14367+
flags+=("--wildcardpolicy=")
14368+
local_nonpersistent_flags+=("--wildcardpolicy=")
1436714369
flags+=("--as=")
1436814370
flags+=("--certificate-authority=")
1436914371
flags_with_completion+=("--certificate-authority")

docs/generated/oc_by_example_content.adoc

+4
Original file line numberDiff line numberDiff line change
@@ -1724,6 +1724,10 @@ Expose a replicated application as a service or route
17241724
# Create a route and specify a hostname
17251725
oc expose service nginx --hostname=www.example.com
17261726
1727+
# Create a route with wildcard
1728+
oc expose service nginx --hostname=x.example.com --wildcard=Subdomain
1729+
This would be equivalent to *.example.com. NOTE: only hosts are matched by the wildcard, subdomains would not be included.
1730+
17271731
# Expose a deployment configuration as a service and use the specified port
17281732
oc expose dc ruby-hello-world --port=8080
17291733

docs/man/man1/oc-expose.1

+8
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,10 @@ There is also the ability to expose a deployment configuration, replication cont
144144
\fB\-\-type\fP=""
145145
Type for this service: ClusterIP, NodePort, or LoadBalancer. Default is 'ClusterIP'.
146146

147+
.PP
148+
\fB\-\-wildcardpolicy\fP=""
149+
Sets the WildcardPolicy for the hostname, the default is "None". Valid values are "None" and "Subdomain"
150+
147151

148152
.SH OPTIONS INHERITED FROM PARENT COMMANDS
149153
.PP
@@ -229,6 +233,10 @@ There is also the ability to expose a deployment configuration, replication cont
229233
# Create a route and specify a hostname
230234
oc expose service nginx \-\-hostname=www.example.com
231235

236+
# Create a route with wildcard
237+
oc expose service nginx \-\-hostname=x.example.com \-\-wildcard=Subdomain
238+
This would be equivalent to *.example.com. NOTE: only hosts are matched by the wildcard, subdomains would not be included.
239+
232240
# Expose a deployment configuration as a service and use the specified port
233241
oc expose dc ruby\-hello\-world \-\-port=8080
234242

docs/man/man1/openshift-cli-expose.1

+8
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,10 @@ There is also the ability to expose a deployment configuration, replication cont
144144
\fB\-\-type\fP=""
145145
Type for this service: ClusterIP, NodePort, or LoadBalancer. Default is 'ClusterIP'.
146146

147+
.PP
148+
\fB\-\-wildcardpolicy\fP=""
149+
Sets the WildcardPolicy for the hostname, the default is "None". Valid values are "None" and "Subdomain"
150+
147151

148152
.SH OPTIONS INHERITED FROM PARENT COMMANDS
149153
.PP
@@ -229,6 +233,10 @@ There is also the ability to expose a deployment configuration, replication cont
229233
# Create a route and specify a hostname
230234
openshift cli expose service nginx \-\-hostname=www.example.com
231235

236+
# Create a route with wildcard
237+
openshift cli expose service nginx \-\-hostname=x.example.com \-\-wildcard=Subdomain
238+
This would be equivalent to *.example.com. NOTE: only hosts are matched by the wildcard, subdomains would not be included.
239+
232240
# Expose a deployment configuration as a service and use the specified port
233241
openshift cli expose dc ruby\-hello\-world \-\-port=8080
234242

pkg/cmd/cli/cmd/expose.go

+11
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ var (
3333
# Create a route and specify a hostname
3434
%[1]s expose service nginx --hostname=www.example.com
3535
36+
# Create a route with wildcard
37+
%[1]s expose service nginx --hostname=x.example.com --wildcard=Subdomain
38+
This would be equivalent to *.example.com. NOTE: only hosts are matched by the wildcard, subdomains would not be included.
39+
3640
# Expose a deployment configuration as a service and use the specified port
3741
%[1]s expose dc ruby-hello-world --port=8080
3842
@@ -65,6 +69,7 @@ func NewCmdExpose(fullName string, f *clientcmd.Factory, out io.Writer) *cobra.C
6569
}
6670
cmd.Flags().String("hostname", "", "Set a hostname for the new route")
6771
cmd.Flags().String("path", "", "Set a path for the new route")
72+
cmd.Flags().String("wildcardpolicy", "", "Sets the WildcardPolicy for the hostname, the default is \"None\". Valid values are \"None\" and \"Subdomain\"")
6873
return cmd
6974
}
7075

@@ -93,6 +98,12 @@ func validate(cmd *cobra.Command, f *clientcmd.Factory, args []string) error {
9398
if err != nil {
9499
return kcmdutil.UsageError(cmd, err.Error())
95100
}
101+
102+
wildcardpolicy := kcmdutil.GetFlagString(cmd, "wildcardpolicy")
103+
if len(wildcardpolicy) > 0 && (wildcardpolicy != "Subdomain" && wildcardpolicy != "None") {
104+
return fmt.Errorf("only \"Subdomain\" or \"None\" are supported for wildcardpolicy")
105+
}
106+
96107
if len(infos) > 1 {
97108
return fmt.Errorf("multiple resources provided: %v", args)
98109
}

pkg/route/generator/generate.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ func (RouteGenerator) ParamNames() []kubectl.GeneratorParam {
2727
{Name: "name", Required: false},
2828
{Name: "hostname", Required: false},
2929
{Name: "path", Required: false},
30+
{Name: "wildcardpolicy", Required: false},
3031
}
3132
}
3233

@@ -68,8 +69,9 @@ func (RouteGenerator) Generate(genericParams map[string]interface{}) (runtime.Ob
6869
Labels: labels,
6970
},
7071
Spec: api.RouteSpec{
71-
Host: params["hostname"],
72-
Path: params["path"],
72+
Host: params["hostname"],
73+
WildcardPolicy: api.WildcardPolicyType(params["wildcardpolicy"]),
74+
Path: params["path"],
7375
To: api.RouteTargetReference{
7476
Name: params["default-name"],
7577
},

0 commit comments

Comments
 (0)