Skip to content

Commit 9442f33

Browse files
authored
Reformat instance id to the format {protocol}://{ip}:{port} (#86)
1 parent 6375d4b commit 9442f33

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

pkg/model/types.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"github.com/aws/aws-sdk-go-v2/service/servicediscovery/types"
77
"reflect"
88
"strconv"
9+
"strings"
910
)
1011

1112
// Resource encapsulates a ID/name pair.
@@ -188,7 +189,7 @@ func (e *Endpoint) String() string {
188189

189190
// EndpointIdFromIPAddressAndPort converts an IP address to human-readable identifier.
190191
func EndpointIdFromIPAddressAndPort(address string, port Port) string {
191-
return fmt.Sprintf("%s:%s:%d", port.Protocol, address, port.Port)
192+
return fmt.Sprintf("%s://%s:%d", strings.ToLower(port.Protocol), address, port.Port)
192193
}
193194

194195
func ConvertNamespaceType(nsType types.NamespaceType) (namespaceType NamespaceType) {

pkg/model/types_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ func TestEndpointIdFromIPAddressAndPort(t *testing.T) {
182182
Port: 80,
183183
Protocol: "TCP",
184184
},
185-
want: "TCP:192.168.0.1:80",
185+
want: "tcp://192.168.0.1:80",
186186
},
187187
}
188188
for _, tt := range tests {

test/test-constants.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ const (
99
NsId = "ns-id"
1010
SvcName = "svc-name"
1111
SvcId = "svc-id"
12-
EndptId1 = "TCP:192.168.0.1:1"
13-
EndptId2 = "TCP:192.168.0.2:2"
12+
EndptId1 = "tcp://192.168.0.1:1"
13+
EndptId2 = "tcp://192.168.0.2:2"
1414
EndptIp1 = "192.168.0.1"
1515
EndptIp2 = "192.168.0.2"
1616
Port1 = 1

0 commit comments

Comments
 (0)