cli: fix init with k8s version without v prefix (#1174)

This commit is contained in:
Otto Bittner 2023-02-13 11:54:38 +01:00 committed by GitHub
parent aa422bb648
commit 8a72df89ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View File

@ -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)
}

View File

@ -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 {