mirror of
https://github.com/rancher/k3k.git
synced 2026-08-19 04:16:16 +00:00
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:
co-authored by
Enrico Candino
parent
80f0938148
commit
bd8ed8a036
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user