From 2fdae82d0bbdee1366eb2daacb16594de9362249 Mon Sep 17 00:00:00 2001 From: "R.B. Boyer" Date: Tue, 2 Jul 2019 17:15:30 -0500 Subject: [PATCH] ensure consul config write has snake case conversions for MeshGateway (#6062) --- command/config/write/config_write.go | 6 ++++++ command/config/write/config_write_test.go | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/command/config/write/config_write.go b/command/config/write/config_write.go index 4150780c8..593b76eed 100644 --- a/command/config/write/config_write.go +++ b/command/config/write/config_write.go @@ -138,7 +138,13 @@ func newDecodeConfigEntry(raw map[string]interface{}) (api.ConfigEntry, error) { switch entry.GetKind() { case api.ProxyDefaults: + translateKeysDict = map[string]string{ + "mesh_gateway": "meshgateway", + } case api.ServiceDefaults: + translateKeysDict = map[string]string{ + "mesh_gateway": "meshgateway", + } case api.ServiceRouter: skipWhenPatching = []string{ "routes", diff --git a/command/config/write/config_write_test.go b/command/config/write/config_write_test.go index 809c44cfa..3211b8dcf 100644 --- a/command/config/write/config_write_test.go +++ b/command/config/write/config_write_test.go @@ -145,6 +145,9 @@ func TestParseConfigEntry(t *testing.T) { "moar" = "config" } } + mesh_gateway { + mode = "remote" + } `, camel: ` Kind = "proxy-defaults" @@ -156,6 +159,9 @@ func TestParseConfigEntry(t *testing.T) { "moar" = "config" } } + MeshGateway { + Mode = "remote" + } `, expect: &api.ProxyConfigEntry{ Kind: "proxy-defaults", @@ -167,6 +173,9 @@ func TestParseConfigEntry(t *testing.T) { "moar": "config", }, }, + MeshGateway: api.MeshGatewayConfig{ + Mode: api.MeshGatewayModeRemote, + }, }, }, { @@ -175,16 +184,25 @@ func TestParseConfigEntry(t *testing.T) { kind = "service-defaults" name = "main" protocol = "http" + mesh_gateway { + mode = "remote" + } `, camel: ` Kind = "service-defaults" Name = "main" Protocol = "http" + MeshGateway { + Mode = "remote" + } `, expect: &api.ServiceConfigEntry{ Kind: "service-defaults", Name: "main", Protocol: "http", + MeshGateway: api.MeshGatewayConfig{ + Mode: api.MeshGatewayModeRemote, + }, }, }, {