From 93c3c1780d308fe65aafe01c9f25b072a707238d Mon Sep 17 00:00:00 2001 From: freddygv Date: Mon, 15 Mar 2021 14:12:15 -0600 Subject: [PATCH] Only lowercase the protocol when normalizing --- agent/structs/config_entry.go | 6 +----- agent/structs/config_entry_test.go | 12 ------------ 2 files changed, 1 insertion(+), 17 deletions(-) diff --git a/agent/structs/config_entry.go b/agent/structs/config_entry.go index 048ab84257..97e3e9ff83 100644 --- a/agent/structs/config_entry.go +++ b/agent/structs/config_entry.go @@ -706,11 +706,7 @@ func (cfg UpstreamConfig) MergeInto(dst map[string]interface{}, legacy bool) { } func (cfg *UpstreamConfig) Normalize() { - if cfg.Protocol == "" { - cfg.Protocol = "tcp" - } else { - cfg.Protocol = strings.ToLower(cfg.Protocol) - } + cfg.Protocol = strings.ToLower(cfg.Protocol) if cfg.ConnectTimeoutMs < 1 { cfg.ConnectTimeoutMs = 5000 diff --git a/agent/structs/config_entry_test.go b/agent/structs/config_entry_test.go index 9e79d8f142..7e5d58f167 100644 --- a/agent/structs/config_entry_test.go +++ b/agent/structs/config_entry_test.go @@ -1575,12 +1575,10 @@ func TestServiceConfigEntry_Normalize(t *testing.T) { ConnectTimeoutMs: 5000, }, "memcached": { - Protocol: "tcp", ConnectTimeoutMs: 5000, }, }, UpstreamDefaults: &UpstreamConfig{ - Protocol: "tcp", ConnectTimeoutMs: 5000, }, }, @@ -1771,7 +1769,6 @@ func TestParseUpstreamConfig(t *testing.T) { input: nil, want: UpstreamConfig{ ConnectTimeoutMs: 5000, - Protocol: "tcp", }, }, { @@ -1779,7 +1776,6 @@ func TestParseUpstreamConfig(t *testing.T) { input: map[string]interface{}{}, want: UpstreamConfig{ ConnectTimeoutMs: 5000, - Protocol: "tcp", }, }, { @@ -1790,7 +1786,6 @@ func TestParseUpstreamConfig(t *testing.T) { }, want: UpstreamConfig{ ConnectTimeoutMs: 5000, - Protocol: "tcp", }, }, { @@ -1810,7 +1805,6 @@ func TestParseUpstreamConfig(t *testing.T) { }, want: UpstreamConfig{ ConnectTimeoutMs: 1000, - Protocol: "tcp", }, }, { @@ -1820,7 +1814,6 @@ func TestParseUpstreamConfig(t *testing.T) { }, want: UpstreamConfig{ ConnectTimeoutMs: 1000, - Protocol: "tcp", }, }, { @@ -1830,7 +1823,6 @@ func TestParseUpstreamConfig(t *testing.T) { }, want: UpstreamConfig{ ConnectTimeoutMs: 1000, - Protocol: "tcp", }, }, { @@ -1844,7 +1836,6 @@ func TestParseUpstreamConfig(t *testing.T) { }, want: UpstreamConfig{ ConnectTimeoutMs: 5000, - Protocol: "tcp", Limits: &UpstreamLimits{ MaxConnections: intPointer(50), MaxPendingRequests: intPointer(60), @@ -1863,7 +1854,6 @@ func TestParseUpstreamConfig(t *testing.T) { }, want: UpstreamConfig{ ConnectTimeoutMs: 5000, - Protocol: "tcp", Limits: &UpstreamLimits{ MaxConnections: intPointer(0), MaxPendingRequests: intPointer(0), @@ -1881,7 +1871,6 @@ func TestParseUpstreamConfig(t *testing.T) { }, want: UpstreamConfig{ ConnectTimeoutMs: 5000, - Protocol: "tcp", PassiveHealthCheck: &PassiveHealthCheck{ Interval: 22 * time.Second, MaxFailures: 7, @@ -1897,7 +1886,6 @@ func TestParseUpstreamConfig(t *testing.T) { }, want: UpstreamConfig{ ConnectTimeoutMs: 5000, - Protocol: "tcp", MeshGateway: MeshGatewayConfig{ Mode: MeshGatewayModeRemote, },