Skip to content

Commit 72e0f66

Browse files
authored
Change exported endpoint ID delimiters, add -ldflags to go run (#94)
1 parent 100c133 commit 72e0f66

File tree

4 files changed

+8
-6
lines changed

4 files changed

+8
-6
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ build: manifests generate generate-mocks fmt vet ## Build manager binary.
8484
go build -ldflags="-s -w -X ${PKG}.GitVersion=${GIT_TAG} -X ${PKG}.GitCommit=${GIT_COMMIT}" -o bin/manager main.go
8585

8686
run: manifests generate generate-mocks fmt vet ## Run a controller from your host.
87-
go run ./main.go
87+
go run -ldflags="-s -w -X ${PKG}.GitVersion=${GIT_TAG} -X ${PKG}.GitCommit=${GIT_COMMIT}" ./main.go
8888

8989
docker-build: test ## Build docker image with the manager.
9090
docker build $(ARGS) -t ${IMG} .

pkg/model/types.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,9 @@ func (e *Endpoint) String() string {
189189

190190
// EndpointIdFromIPAddressAndPort converts an IP address to human-readable identifier.
191191
func EndpointIdFromIPAddressAndPort(address string, port Port) string {
192-
return fmt.Sprintf("%s://%s:%d", strings.ToLower(port.Protocol), address, port.Port)
192+
address = strings.Replace(address, ".", "_", -1)
193+
address = strings.Replace(address, ":", "_", -1)
194+
return fmt.Sprintf("%s-%s-%d", strings.ToLower(port.Protocol), address, port.Port)
193195
}
194196

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

pkg/model/types_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,13 +176,13 @@ func TestEndpointIdFromIPAddressAndPort(t *testing.T) {
176176
}{
177177
{
178178
name: "happy case",
179-
address: "192.168.0.1",
179+
address: ip,
180180
port: Port{
181181
Name: "http",
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)