mirror of https://github.com/status-im/consul.git
Add -host flag to expose command
This commit is contained in:
parent
5958328552
commit
edab5588d8
|
@ -30,6 +30,7 @@ type cmd struct {
|
|||
service string
|
||||
port int
|
||||
protocol string
|
||||
hosts flags.AppendSliceValue
|
||||
}
|
||||
|
||||
func (c *cmd) init() {
|
||||
|
@ -48,6 +49,9 @@ func (c *cmd) init() {
|
|||
c.flags.StringVar(&c.protocol, "protocol", "tcp",
|
||||
"The protocol for the service. Defaults to 'tcp'.")
|
||||
|
||||
c.flags.Var(&c.hosts, "host", "Additional DNS hostname to use for routing to this service."+
|
||||
"Can be specified multiple times.")
|
||||
|
||||
c.http = &flags.HTTPFlags{}
|
||||
flags.Merge(c.flags, c.http.ClientFlags())
|
||||
flags.Merge(c.flags, c.http.ServerFlags())
|
||||
|
@ -144,6 +148,7 @@ func (c *cmd) Run(args []string) int {
|
|||
ingressConf.Listeners[listenerIdx].Services = append(ingressConf.Listeners[listenerIdx].Services, api.IngressService{
|
||||
Name: svc,
|
||||
Namespace: svcNamespace,
|
||||
Hosts: c.hosts,
|
||||
})
|
||||
} else {
|
||||
ingressConf.Listeners = append(ingressConf.Listeners, api.IngressListener{
|
||||
|
@ -153,6 +158,7 @@ func (c *cmd) Run(args []string) int {
|
|||
{
|
||||
Name: svc,
|
||||
Namespace: svcNamespace,
|
||||
Hosts: c.hosts,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
|
|
@ -279,6 +279,8 @@ func TestConnectExpose_existingConfig(t *testing.T) {
|
|||
"-ingress-gateway=ingress",
|
||||
"-port=9999",
|
||||
"-protocol=http",
|
||||
"-host=foo.com",
|
||||
"-host=foo.net",
|
||||
}
|
||||
|
||||
code := c.Run(args)
|
||||
|
@ -291,7 +293,8 @@ func TestConnectExpose_existingConfig(t *testing.T) {
|
|||
require.NoError(err)
|
||||
|
||||
ingressConf.Listeners[1].Services = append(ingressConf.Listeners[1].Services, api.IngressService{
|
||||
Name: "zoo",
|
||||
Name: "zoo",
|
||||
Hosts: []string{"foo.com", "foo.net"},
|
||||
})
|
||||
ingressConf.CreateIndex = entry.GetCreateIndex()
|
||||
ingressConf.ModifyIndex = entry.GetModifyIndex()
|
||||
|
|
|
@ -40,12 +40,15 @@ Usage: consul connect expose [options]
|
|||
- `-port` - (Required) The listener port to use for the service on the Ingress
|
||||
gateway.
|
||||
|
||||
- `-protocol` - The protocol for the service. Defaults to 'tcp'.
|
||||
|
||||
- `-service` - (Required) The name of destination service to expose. A namespace
|
||||
can optionally be specified as a prefix via the 'namespace/service'
|
||||
format.
|
||||
|
||||
- `-protocol` - The protocol for the service. Defaults to 'tcp'.
|
||||
|
||||
- `-host` - Additional DNS hostname to use for routing to this service. Can be
|
||||
specified multiple times.
|
||||
|
||||
## Examples
|
||||
|
||||
The example below shows using the `expose` command to make the `foo` service available
|
||||
|
|
Loading…
Reference in New Issue