Skip to content

Commit

Permalink
pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewChubatiuk committed Feb 13, 2021
1 parent 66e3e95 commit 77ec3d1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions command/agent/consul/connect.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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",
},
{
Expand Down Expand Up @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions command/agent/consul/connect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 77ec3d1

Please sign in to comment.