From 77ec3d1fabc95c7815a935a45afdfc8bbb76f96a Mon Sep 17 00:00:00 2001 From: AndrewChubatiuk Date: Sat, 13 Feb 2021 02:32:33 +0200 Subject: [PATCH] pr comments --- command/agent/consul/connect.go | 7 ++++--- command/agent/consul/connect_test.go | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/command/agent/consul/connect.go b/command/agent/consul/connect.go index 16ad8ce36e5..3825c0da932 100644 --- a/command/agent/consul/connect.go +++ b/command/agent/consul/connect.go @@ -2,9 +2,10 @@ package consul import ( "fmt" + "net" + "strconv" "github.com/hashicorp/consul/api" - "github.com/hashicorp/consul/ipaddr" "github.com/hashicorp/nomad/helper" "github.com/hashicorp/nomad/nomad/structs" ) @@ -112,7 +113,7 @@ func connectSidecarRegistration(serviceId string, css *structs.ConsulSidecarServ Checks: api.AgentServiceChecks{ { Name: "Connect Sidecar Listening", - TCP: ipaddr.FormatAddressPort(cMapping.HostIP, cMapping.Value), + TCP: net.JoinHostPort(cMapping.HostIP, strconv.Itoa(cMapping.Value)), Interval: "10s", }, { @@ -225,7 +226,7 @@ func connectPort(portLabel string, networks structs.Networks, ports structs.Allo if mapping.Value > 0 { return mapping, nil } - return structs.AllocatedPortMapping{}, fmt.Errorf("invalid port %q: port label not found", portLabel) + return structs.AllocatedPortMapping{}, fmt.Errorf("No port of label %q defined", portLabel) } return mapping, nil } diff --git a/command/agent/consul/connect_test.go b/command/agent/consul/connect_test.go index edefa3f88a9..7d89c55eca4 100644 --- a/command/agent/consul/connect_test.go +++ b/command/agent/consul/connect_test.go @@ -94,7 +94,7 @@ func TestConnect_connectSidecarRegistration(t *testing.T) { _, err := connectSidecarRegistration("unknown-id", &structs.ConsulSidecarService{ Port: "unknown-label", }, testConnectNetwork, testConnectPorts) - require.EqualError(t, err, `invalid port "unknown-label": port label not found`) + require.EqualError(t, err, `No port of label "unknown-label" defined`) }) t.Run("bad proxy", func(t *testing.T) { @@ -383,7 +383,7 @@ func TestConnect_getConnectPort(t *testing.T) { t.Run("no such service", func(t *testing.T) { _, err := connectPort("other", networks, ports) - require.EqualError(t, err, `invalid port "other": port label not found`) + require.EqualError(t, err, `No port of label "other" defined`) }) t.Run("no network", func(t *testing.T) {