Skip to content
This repository has been archived by the owner on Mar 16, 2024. It is now read-only.

Commit

Permalink
Remove duplicate endpoint, apply protocol
Browse files Browse the repository at this point in the history
Signed-off-by: Daishan Peng <[email protected]>
  • Loading branch information
StrongMonkey committed Nov 6, 2023
1 parent 1849371 commit 176e5e5
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions pkg/controller/appstatus/endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,15 @@ func serviceEndpoints(ctx context.Context, c kclient.Client, app *v1.AppInstance
portNum := port.Port
if len(ingress.Ports) > 0 {
for _, ingressPort := range ingress.Ports {
portProtocol := port.Protocol
if ingressPort.Protocol != "" {
portProtocol = ingressPort.Protocol
}
endpoints = append(endpoints, v1.Endpoint{
Target: containerName,
TargetPort: port.TargetPort.IntVal,
Address: fmt.Sprintf("%s:%d", ingress.Hostname, ingressPort.Port),
Protocol: protocol,
Protocol: v1.Protocol(portProtocol),
})
}
} else {
Expand Down Expand Up @@ -90,7 +94,17 @@ func serviceEndpoints(ctx context.Context, c kclient.Client, app *v1.AppInstance
}
}

return
set := map[string]v1.Endpoint{}
for _, ep := range endpoints {
set[fmt.Sprintf("%v://%v", ep.Protocol, ep.Address)] = ep
}

var result []v1.Endpoint
for _, ep := range set {
result = append(result, ep)
}

return result, nil
}

func ingressEndpoints(ctx context.Context, c kclient.Client, app *v1.AppInstance) (endpoints []v1.Endpoint, _ error) {
Expand Down

0 comments on commit 176e5e5

Please sign in to comment.