fix: handle empty port in HCP LoadBalancer URL causing strconv.Atoi failure (#1134)

* fix: handle empty port in HCP mode LoadBalancer URL parsing

Assisted-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>

* fix lint

---------

Co-authored-by: Enrico Candino <enrico.candino@suse.com>
This commit is contained in:
Copilot
2026-08-13 10:27:45 +02:00
committed by GitHub
co-authored by Enrico Candino
parent 80f0938148
commit bd8ed8a036
+7 -2
View File
@@ -1,6 +1,7 @@
package cluster
import (
"cmp"
"context"
"fmt"
"net"
@@ -55,7 +56,9 @@ func (c *ClusterReconciler) ensureHCPKubernetesEndpointSlice(ctx context.Context
return err
}
port, err := strconv.Atoi(url.Port())
portStr := cmp.Or(url.Port(), "443")
port, err := strconv.Atoi(portStr)
if err != nil {
return err
}
@@ -148,7 +151,9 @@ func (c *ClusterReconciler) ensureHCPKubernetesEndpoints(ctx context.Context, cl
},
}
port, err := strconv.Atoi(url.Port())
portStr := cmp.Or(url.Port(), "443")
port, err := strconv.Atoi(portStr)
if err != nil {
return err
}