mirror of https://github.com/status-im/consul.git
Merge pull request #10006 from hashicorp/api-ptrs
This commit is contained in:
commit
3ec4556114
|
@ -3519,6 +3519,10 @@ func testAgent_RegisterService_UnmanagedConnectProxy(t *testing.T, extraHCL stri
|
||||||
LocalBindPort: 1235,
|
LocalBindPort: 1235,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Mode: api.ProxyModeTransparent,
|
||||||
|
TransparentProxy: &api.TransparentProxyConfig{
|
||||||
|
OutboundListenerPort: 808,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -110,8 +110,8 @@ type TransparentProxyConfig struct {
|
||||||
OutboundListenerPort int `json:",omitempty" alias:"outbound_listener_port"`
|
OutboundListenerPort int `json:",omitempty" alias:"outbound_listener_port"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c TransparentProxyConfig) ToAPI() api.TransparentProxyConfig {
|
func (c TransparentProxyConfig) ToAPI() *api.TransparentProxyConfig {
|
||||||
return api.TransparentProxyConfig{OutboundListenerPort: c.OutboundListenerPort}
|
return &api.TransparentProxyConfig{OutboundListenerPort: c.OutboundListenerPort}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ConnectProxyConfig describes the configuration needed for any proxy managed
|
// ConnectProxyConfig describes the configuration needed for any proxy managed
|
||||||
|
|
|
@ -46,6 +46,10 @@ func TestConnectProxyConfig_ToAPI(t *testing.T) {
|
||||||
LocalBindAddress: "127.10.10.10",
|
LocalBindAddress: "127.10.10.10",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Mode: ProxyModeTransparent,
|
||||||
|
TransparentProxy: TransparentProxyConfig{
|
||||||
|
OutboundListenerPort: 808,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
want: &api.AgentServiceConnectProxyConfig{
|
want: &api.AgentServiceConnectProxyConfig{
|
||||||
DestinationServiceName: "web",
|
DestinationServiceName: "web",
|
||||||
|
@ -76,6 +80,10 @@ func TestConnectProxyConfig_ToAPI(t *testing.T) {
|
||||||
LocalBindAddress: "127.10.10.10",
|
LocalBindAddress: "127.10.10.10",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Mode: api.ProxyModeTransparent,
|
||||||
|
TransparentProxy: &api.TransparentProxyConfig{
|
||||||
|
OutboundListenerPort: 808,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
20
api/agent.go
20
api/agent.go
|
@ -114,16 +114,16 @@ type AgentServiceConnect struct {
|
||||||
// AgentServiceConnectProxyConfig is the proxy configuration in a connect-proxy
|
// AgentServiceConnectProxyConfig is the proxy configuration in a connect-proxy
|
||||||
// ServiceDefinition or response.
|
// ServiceDefinition or response.
|
||||||
type AgentServiceConnectProxyConfig struct {
|
type AgentServiceConnectProxyConfig struct {
|
||||||
DestinationServiceName string `json:",omitempty"`
|
DestinationServiceName string `json:",omitempty"`
|
||||||
DestinationServiceID string `json:",omitempty"`
|
DestinationServiceID string `json:",omitempty"`
|
||||||
LocalServiceAddress string `json:",omitempty"`
|
LocalServiceAddress string `json:",omitempty"`
|
||||||
LocalServicePort int `json:",omitempty"`
|
LocalServicePort int `json:",omitempty"`
|
||||||
Mode ProxyMode `json:",omitempty"`
|
Mode ProxyMode `json:",omitempty"`
|
||||||
TransparentProxy TransparentProxyConfig `json:",omitempty"`
|
TransparentProxy *TransparentProxyConfig `json:",omitempty"`
|
||||||
Config map[string]interface{} `json:",omitempty" bexpr:"-"`
|
Config map[string]interface{} `json:",omitempty" bexpr:"-"`
|
||||||
Upstreams []Upstream `json:",omitempty"`
|
Upstreams []Upstream `json:",omitempty"`
|
||||||
MeshGateway MeshGatewayConfig `json:",omitempty"`
|
MeshGateway MeshGatewayConfig `json:",omitempty"`
|
||||||
Expose ExposeConfig `json:",omitempty"`
|
Expose ExposeConfig `json:",omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
|
@ -505,6 +505,10 @@ func testUnmanagedProxy(t *testing.T) *AgentService {
|
||||||
LocalServiceAddress: "127.0.0.2",
|
LocalServiceAddress: "127.0.0.2",
|
||||||
LocalServicePort: 8080,
|
LocalServicePort: 8080,
|
||||||
Upstreams: testUpstreams(t),
|
Upstreams: testUpstreams(t),
|
||||||
|
Mode: ProxyModeTransparent,
|
||||||
|
TransparentProxy: &TransparentProxyConfig{
|
||||||
|
OutboundListenerPort: 808,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
ID: "web-proxy1",
|
ID: "web-proxy1",
|
||||||
Service: "web-proxy",
|
Service: "web-proxy",
|
||||||
|
|
|
@ -193,15 +193,15 @@ type UpstreamLimits struct {
|
||||||
type ServiceConfigEntry struct {
|
type ServiceConfigEntry struct {
|
||||||
Kind string
|
Kind string
|
||||||
Name string
|
Name string
|
||||||
Namespace string `json:",omitempty"`
|
Namespace string `json:",omitempty"`
|
||||||
Protocol string `json:",omitempty"`
|
Protocol string `json:",omitempty"`
|
||||||
Mode ProxyMode `json:",omitempty"`
|
Mode ProxyMode `json:",omitempty"`
|
||||||
TransparentProxy TransparentProxyConfig `json:",omitempty" alias:"transparent_proxy"`
|
TransparentProxy *TransparentProxyConfig `json:",omitempty" alias:"transparent_proxy"`
|
||||||
MeshGateway MeshGatewayConfig `json:",omitempty" alias:"mesh_gateway"`
|
MeshGateway MeshGatewayConfig `json:",omitempty" alias:"mesh_gateway"`
|
||||||
Connect ConnectConfiguration `json:",omitempty"`
|
Connect *ConnectConfiguration `json:",omitempty"`
|
||||||
Expose ExposeConfig `json:",omitempty"`
|
Expose ExposeConfig `json:",omitempty"`
|
||||||
ExternalSNI string `json:",omitempty" alias:"external_sni"`
|
ExternalSNI string `json:",omitempty" alias:"external_sni"`
|
||||||
Meta map[string]string `json:",omitempty"`
|
Meta map[string]string `json:",omitempty"`
|
||||||
CreateIndex uint64
|
CreateIndex uint64
|
||||||
ModifyIndex uint64
|
ModifyIndex uint64
|
||||||
}
|
}
|
||||||
|
@ -233,13 +233,13 @@ func (s *ServiceConfigEntry) GetModifyIndex() uint64 {
|
||||||
type ProxyConfigEntry struct {
|
type ProxyConfigEntry struct {
|
||||||
Kind string
|
Kind string
|
||||||
Name string
|
Name string
|
||||||
Namespace string `json:",omitempty"`
|
Namespace string `json:",omitempty"`
|
||||||
Mode ProxyMode `json:",omitempty"`
|
Mode ProxyMode `json:",omitempty"`
|
||||||
TransparentProxy TransparentProxyConfig `json:",omitempty" alias:"transparent_proxy"`
|
TransparentProxy *TransparentProxyConfig `json:",omitempty" alias:"transparent_proxy"`
|
||||||
Config map[string]interface{} `json:",omitempty"`
|
Config map[string]interface{} `json:",omitempty"`
|
||||||
MeshGateway MeshGatewayConfig `json:",omitempty" alias:"mesh_gateway"`
|
MeshGateway MeshGatewayConfig `json:",omitempty" alias:"mesh_gateway"`
|
||||||
Expose ExposeConfig `json:",omitempty"`
|
Expose ExposeConfig `json:",omitempty"`
|
||||||
Meta map[string]string `json:",omitempty"`
|
Meta map[string]string `json:",omitempty"`
|
||||||
CreateIndex uint64
|
CreateIndex uint64
|
||||||
ModifyIndex uint64
|
ModifyIndex uint64
|
||||||
}
|
}
|
||||||
|
|
|
@ -321,7 +321,7 @@ func TestDecodeConfigEntry(t *testing.T) {
|
||||||
Mode: MeshGatewayModeRemote,
|
Mode: MeshGatewayModeRemote,
|
||||||
},
|
},
|
||||||
Mode: ProxyModeTransparent,
|
Mode: ProxyModeTransparent,
|
||||||
TransparentProxy: TransparentProxyConfig{OutboundListenerPort: 808},
|
TransparentProxy: &TransparentProxyConfig{OutboundListenerPort: 808},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -388,8 +388,8 @@ func TestDecodeConfigEntry(t *testing.T) {
|
||||||
Mode: MeshGatewayModeRemote,
|
Mode: MeshGatewayModeRemote,
|
||||||
},
|
},
|
||||||
Mode: ProxyModeTransparent,
|
Mode: ProxyModeTransparent,
|
||||||
TransparentProxy: TransparentProxyConfig{OutboundListenerPort: 808},
|
TransparentProxy: &TransparentProxyConfig{OutboundListenerPort: 808},
|
||||||
Connect: ConnectConfiguration{
|
Connect: &ConnectConfiguration{
|
||||||
UpstreamConfigs: map[string]UpstreamConfig{
|
UpstreamConfigs: map[string]UpstreamConfig{
|
||||||
"redis": {
|
"redis": {
|
||||||
PassiveHealthCheck: &PassiveHealthCheck{
|
PassiveHealthCheck: &PassiveHealthCheck{
|
||||||
|
|
|
@ -275,7 +275,7 @@ func TestParseConfigEntry(t *testing.T) {
|
||||||
Mode: api.MeshGatewayModeRemote,
|
Mode: api.MeshGatewayModeRemote,
|
||||||
},
|
},
|
||||||
Mode: api.ProxyModeDirect,
|
Mode: api.ProxyModeDirect,
|
||||||
TransparentProxy: api.TransparentProxyConfig{
|
TransparentProxy: &api.TransparentProxyConfig{
|
||||||
OutboundListenerPort: 10101,
|
OutboundListenerPort: 10101,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -297,7 +297,7 @@ func TestParseConfigEntry(t *testing.T) {
|
||||||
Mode: api.MeshGatewayModeRemote,
|
Mode: api.MeshGatewayModeRemote,
|
||||||
},
|
},
|
||||||
Mode: api.ProxyModeDirect,
|
Mode: api.ProxyModeDirect,
|
||||||
TransparentProxy: api.TransparentProxyConfig{
|
TransparentProxy: &api.TransparentProxyConfig{
|
||||||
OutboundListenerPort: 10101,
|
OutboundListenerPort: 10101,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -654,10 +654,10 @@ func TestParseConfigEntry(t *testing.T) {
|
||||||
Mode: api.MeshGatewayModeRemote,
|
Mode: api.MeshGatewayModeRemote,
|
||||||
},
|
},
|
||||||
Mode: api.ProxyModeDirect,
|
Mode: api.ProxyModeDirect,
|
||||||
TransparentProxy: api.TransparentProxyConfig{
|
TransparentProxy: &api.TransparentProxyConfig{
|
||||||
OutboundListenerPort: 10101,
|
OutboundListenerPort: 10101,
|
||||||
},
|
},
|
||||||
Connect: api.ConnectConfiguration{
|
Connect: &api.ConnectConfiguration{
|
||||||
UpstreamConfigs: map[string]api.UpstreamConfig{
|
UpstreamConfigs: map[string]api.UpstreamConfig{
|
||||||
"redis": {
|
"redis": {
|
||||||
PassiveHealthCheck: &api.PassiveHealthCheck{
|
PassiveHealthCheck: &api.PassiveHealthCheck{
|
||||||
|
|
|
@ -122,6 +122,10 @@ func TestStructsToAgentService(t *testing.T) {
|
||||||
LocalServiceAddress: "127.0.0.1",
|
LocalServiceAddress: "127.0.0.1",
|
||||||
LocalServicePort: 8181,
|
LocalServicePort: 8181,
|
||||||
Upstreams: structs.TestUpstreams(t),
|
Upstreams: structs.TestUpstreams(t),
|
||||||
|
Mode: structs.ProxyModeTransparent,
|
||||||
|
TransparentProxy: structs.TransparentProxyConfig{
|
||||||
|
OutboundListenerPort: 808,
|
||||||
|
},
|
||||||
Config: map[string]interface{}{
|
Config: map[string]interface{}{
|
||||||
"foo": "bar",
|
"foo": "bar",
|
||||||
},
|
},
|
||||||
|
@ -138,6 +142,10 @@ func TestStructsToAgentService(t *testing.T) {
|
||||||
LocalServiceAddress: "127.0.0.1",
|
LocalServiceAddress: "127.0.0.1",
|
||||||
LocalServicePort: 8181,
|
LocalServicePort: 8181,
|
||||||
Upstreams: structs.TestUpstreams(t).ToAPI(),
|
Upstreams: structs.TestUpstreams(t).ToAPI(),
|
||||||
|
Mode: api.ProxyModeTransparent,
|
||||||
|
TransparentProxy: &api.TransparentProxyConfig{
|
||||||
|
OutboundListenerPort: 808,
|
||||||
|
},
|
||||||
Config: map[string]interface{}{
|
Config: map[string]interface{}{
|
||||||
"foo": "bar",
|
"foo": "bar",
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue