Skip to content

Commit 6e9cace

Browse files
committed
fix: change k8s version if it has leading "v"
This PR adds a simple fix to strip the leading v before generating talos machine configs if necessary. Signed-off-by: Spencer Smith <[email protected]>
1 parent e1bc290 commit 6e9cace

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

controllers/talosconfig_controller.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"errors"
2222
"fmt"
2323
"strconv"
24+
"strings"
2425

2526
"github.com/go-logr/logr"
2627
bootstrapv1alpha3 "github.com/talos-systems/cluster-api-bootstrap-provider-talos/api/v1alpha3"
@@ -273,10 +274,14 @@ func (r *TalosConfigReconciler) genConfigs(ctx context.Context, scope *TalosConf
273274
machineType = configmachine.TypeControlPlane
274275
}
275276

277+
// Handle k8s version being formatted like "vX.Y.Z" instead of without leading 'v'
278+
// TrimPrefix returns the string unchanged if the prefix isn't present.
279+
k8sVersion := strings.TrimPrefix(*scope.Machine.Spec.Version, "v")
280+
276281
APIEndpointPort := strconv.Itoa(int(scope.Cluster.Spec.ControlPlaneEndpoint.Port))
277282
input, err := generate.NewInput(scope.Cluster.Name,
278283
"https://"+scope.Cluster.Spec.ControlPlaneEndpoint.Host+":"+APIEndpointPort,
279-
*scope.Machine.Spec.Version,
284+
k8sVersion,
280285
)
281286
if err != nil {
282287
return retBundle, err

0 commit comments

Comments
 (0)