diff --git a/cli/internal/cmd/init.go b/cli/internal/cmd/init.go index 376f46b51..1dcb03382 100644 --- a/cli/internal/cmd/init.go +++ b/cli/internal/cmd/init.go @@ -18,6 +18,8 @@ import ( "text/tabwriter" "time" + "github.com/edgelesssys/constellation/v2/internal/compatibility" + "github.com/edgelesssys/constellation/v2/bootstrapper/initproto" "github.com/edgelesssys/constellation/v2/cli/internal/cloudcmd" "github.com/edgelesssys/constellation/v2/cli/internal/clusterid" @@ -112,7 +114,7 @@ func (i *initCmd) initialize(cmd *cobra.Command, newDialer func(validator *cloud return fmt.Errorf("reading cluster ID file: %w", err) } - k8sVersion, err := versions.NewValidK8sVersion(conf.KubernetesVersion) + k8sVersion, err := versions.NewValidK8sVersion(compatibility.EnsurePrefixV(conf.KubernetesVersion)) if err != nil { return fmt.Errorf("validating kubernetes version: %w", err) } diff --git a/cli/internal/cmd/init_test.go b/cli/internal/cmd/init_test.go index ccf903956..c909fb0b4 100644 --- a/cli/internal/cmd/init_test.go +++ b/cli/internal/cmd/init_test.go @@ -19,6 +19,7 @@ import ( "time" kmssetup "github.com/edgelesssys/constellation/v2/internal/kms/setup" + "github.com/edgelesssys/constellation/v2/internal/versions" "github.com/edgelesssys/constellation/v2/bootstrapper/initproto" "github.com/edgelesssys/constellation/v2/cli/internal/cloudcmd" @@ -116,6 +117,12 @@ func TestInitialize(t *testing.T) { retriable: true, wantErr: true, }, + "k8s version without v works": { + provider: cloudprovider.Azure, + idFile: &clusterid.File{IP: "192.0.2.1"}, + initServerAPI: &stubInitServer{initResp: testInitResp}, + configMutator: func(c *config.Config) { c.KubernetesVersion = strings.TrimPrefix(string(versions.Default), "v") }, + }, } for name, tc := range testCases {