From d4d774b339291db2ce229b14c52392b7c56fa6dc Mon Sep 17 00:00:00 2001 From: Fabian Kramm Date: Wed, 11 Sep 2024 09:11:05 +0200 Subject: [PATCH 1/2] fix: change namespace in reset password (cherry picked from commit a84333a3aeb9ddc0f596371176505a4c276d3e62) --- cmd/vclusterctl/cmd/platform/reset.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cmd/vclusterctl/cmd/platform/reset.go b/cmd/vclusterctl/cmd/platform/reset.go index 370fbeb087..7a7ce72fe3 100644 --- a/cmd/vclusterctl/cmd/platform/reset.go +++ b/cmd/vclusterctl/cmd/platform/reset.go @@ -79,6 +79,7 @@ vcluster platform reset password --user admin c.Flags().StringVar(&cmd.Password, "password", "", "The new password to use") c.Flags().BoolVar(&cmd.Create, "create", false, "Creates the user if it does not exist") c.Flags().BoolVar(&cmd.Force, "force", false, "If user had no password will create one") + c.Flags().StringVar(&cmd.Namespace, "namespace", "vcluster-platform", "The namespace to use") return c } @@ -118,7 +119,7 @@ func (cmd *PasswordCmd) Run() error { }, PasswordRef: &storagev1.SecretRef{ SecretName: "loft-password-" + random.String(5), - SecretNamespace: "loft", + SecretNamespace: cmd.Namespace, Key: "password", }, }, @@ -136,7 +137,7 @@ func (cmd *PasswordCmd) Run() error { user.Spec.PasswordRef = &storagev1.SecretRef{ SecretName: "loft-password-" + random.String(5), - SecretNamespace: "loft", + SecretNamespace: cmd.Namespace, Key: "password", } user, err = managementClient.Loft().StorageV1().Users().Update(context.Background(), user, metav1.UpdateOptions{}) From 8d384c5eb92588aa0819cf171b3fa21e159f6655 Mon Sep 17 00:00:00 2001 From: Fabian Kramm Date: Wed, 11 Sep 2024 09:15:59 +0200 Subject: [PATCH 2/2] fix: use correct chart name for vcluster platform start (cherry picked from commit 5e71d62d84e0b4bc9dcee502d556e4b77598ac3d) --- cmd/vclusterctl/cmd/platform/start.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/cmd/vclusterctl/cmd/platform/start.go b/cmd/vclusterctl/cmd/platform/start.go index 40a9faa3d5..6c29119452 100644 --- a/cmd/vclusterctl/cmd/platform/start.go +++ b/cmd/vclusterctl/cmd/platform/start.go @@ -3,7 +3,9 @@ package platform import ( "context" "fmt" + "strings" + "github.com/blang/semver" "github.com/loft-sh/log" "github.com/loft-sh/log/survey" "github.com/loft-sh/log/terminal" @@ -83,6 +85,15 @@ func (cmd *StartCmd) Run(ctx context.Context) error { cmd.Version = latestVersion } } + + // if < v4.0.0 then use ChartName loft + parsedVersion, err := semver.Parse(strings.TrimPrefix(cmd.Version, "v")) + if err != nil { + return fmt.Errorf("parse provided version %s: %w", cmd.Version, err) + } else if parsedVersion.LT(semver.MustParse("4.0.0-alpha.0")) && cmd.ChartName == "vcluster-platform" { + cmd.ChartName = "loft" + } + // make sure we are in the correct context // first load the kube config kubeClientConfig := clientcmd.NewNonInteractiveDeferredLoadingClientConfig(clientcmd.NewDefaultClientConfigLoadingRules(), &clientcmd.ConfigOverrides{