mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 18:35:44 +03:00
consul/connect: support for proxy upstreams opaque config (#15761)
This PR adds support for configuring `proxy.upstreams[].config` for Consul Connect upstreams. This is an opaque config value to Nomad - the data is passed directly to Consul and is unknown to Nomad.
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
|
||||
"github.com/hashicorp/consul/api"
|
||||
"github.com/hashicorp/nomad/nomad/structs"
|
||||
"golang.org/x/exp/maps"
|
||||
"golang.org/x/exp/slices"
|
||||
)
|
||||
|
||||
@@ -202,6 +203,7 @@ func connectUpstreams(in []structs.ConsulUpstream) []api.Upstream {
|
||||
Datacenter: upstream.Datacenter,
|
||||
LocalBindAddress: upstream.LocalBindAddress,
|
||||
MeshGateway: connectMeshGateway(upstream.MeshGateway),
|
||||
Config: maps.Clone(upstream.Config),
|
||||
}
|
||||
}
|
||||
return upstreams
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"github.com/hashicorp/nomad/helper/pointer"
|
||||
"github.com/hashicorp/nomad/helper/uuid"
|
||||
"github.com/hashicorp/nomad/nomad/structs"
|
||||
"github.com/shoenig/test/must"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
@@ -360,11 +361,11 @@ func TestConnect_connectUpstreams(t *testing.T) {
|
||||
ci.Parallel(t)
|
||||
|
||||
t.Run("nil", func(t *testing.T) {
|
||||
require.Nil(t, connectUpstreams(nil))
|
||||
must.Nil(t, connectUpstreams(nil))
|
||||
})
|
||||
|
||||
t.Run("not empty", func(t *testing.T) {
|
||||
require.Equal(t,
|
||||
must.Eq(t,
|
||||
[]api.Upstream{{
|
||||
DestinationName: "foo",
|
||||
LocalBindPort: 8000,
|
||||
@@ -374,6 +375,7 @@ func TestConnect_connectUpstreams(t *testing.T) {
|
||||
LocalBindPort: 9000,
|
||||
Datacenter: "dc2",
|
||||
LocalBindAddress: "127.0.0.2",
|
||||
Config: map[string]any{"connect_timeout_ms": 5000},
|
||||
}},
|
||||
connectUpstreams([]structs.ConsulUpstream{{
|
||||
DestinationName: "foo",
|
||||
@@ -384,6 +386,7 @@ func TestConnect_connectUpstreams(t *testing.T) {
|
||||
LocalBindPort: 9000,
|
||||
Datacenter: "dc2",
|
||||
LocalBindAddress: "127.0.0.2",
|
||||
Config: map[string]any{"connect_timeout_ms": 5000},
|
||||
}}),
|
||||
)
|
||||
})
|
||||
|
||||
@@ -1668,6 +1668,7 @@ func apiUpstreamsToStructs(in []*api.ConsulUpstream) []structs.ConsulUpstream {
|
||||
Datacenter: upstream.Datacenter,
|
||||
LocalBindAddress: upstream.LocalBindAddress,
|
||||
MeshGateway: apiMeshGatewayToStructs(upstream.MeshGateway),
|
||||
Config: maps.Clone(upstream.Config),
|
||||
}
|
||||
}
|
||||
return upstreams
|
||||
|
||||
Reference in New Issue
Block a user