Make routegroup client IPv6 compatible

Signed-off-by: Mikkel Oscar Lyderik Larsen <mikkel.larsen@zalando.de>
This commit is contained in:
Mikkel Oscar Lyderik Larsen 2023-11-27 11:53:42 +01:00
parent a60480f414
commit b48bb26c5f

View File

@ -210,7 +210,8 @@ func NewRouteGroupSource(timeout time.Duration, token, tokenPath, apiServerURL,
apiServer := u.String()
// strip port if well known port, because of TLS certificate match
if u.Scheme == "https" && u.Port() == "443" {
apiServer = "https://" + u.Hostname()
// correctly handle IPv6 addresses by keeping surrounding `[]`.
apiServer = "https://" + strings.TrimSuffix(u.Host, ":443")
}
sc := &routeGroupSource{