Rename fields on proxyConfig (#15541)

* Change api Fields for expose and paths

* Add changelog entry

* changelog: add deprecation notes about connect fields

* api: minor style tweaks

---------

Co-authored-by: Seth Hoenig <shoenig@duck.com>
This commit is contained in:
Jorge Marey
2023-01-30 16:31:16 +01:00
committed by GitHub
parent 631fd4778e
commit 340ad2db58
8 changed files with 51 additions and 23 deletions

View File

@@ -1646,11 +1646,18 @@ func apiConnectSidecarServiceProxyToStructs(in *api.ConsulProxy) *structs.Consul
if in == nil {
return nil
}
// TODO: to maintain backwards compatibility
expose := in.Expose
if in.ExposeConfig != nil {
expose = in.ExposeConfig
}
return &structs.ConsulProxy{
LocalServiceAddress: in.LocalServiceAddress,
LocalServicePort: in.LocalServicePort,
Upstreams: apiUpstreamsToStructs(in.Upstreams),
Expose: apiConsulExposeConfigToStructs(in.ExposeConfig),
Expose: apiConsulExposeConfigToStructs(expose),
Config: maps.Clone(in.Config),
}
}
@@ -1686,8 +1693,15 @@ func apiConsulExposeConfigToStructs(in *api.ConsulExposeConfig) *structs.ConsulE
if in == nil {
return nil
}
// TODO: to maintain backwards compatibility
paths := in.Paths
if in.Path != nil {
paths = in.Path
}
return &structs.ConsulExposeConfig{
Paths: apiConsulExposePathsToStructs(in.Path),
Paths: apiConsulExposePathsToStructs(paths),
}
}

View File

@@ -3694,7 +3694,7 @@ func TestConversion_apiConsulExposeConfigToStructs(t *testing.T) {
require.Equal(t, &structs.ConsulExposeConfig{
Paths: []structs.ConsulExposePath{{Path: "/health"}},
}, apiConsulExposeConfigToStructs(&api.ConsulExposeConfig{
Path: []*api.ConsulExposePath{{Path: "/health"}},
Paths: []*api.ConsulExposePath{{Path: "/health"}},
}))
}
@@ -3747,8 +3747,8 @@ func TestConversion_apiConnectSidecarServiceProxyToStructs(t *testing.T) {
Upstreams: []*api.ConsulUpstream{{
DestinationName: "upstream",
}},
ExposeConfig: &api.ConsulExposeConfig{
Path: []*api.ConsulExposePath{{
Expose: &api.ConsulExposeConfig{
Paths: []*api.ConsulExposePath{{
Path: "/health",
}},
},