Skip to content

Commit

Permalink
Merge pull request #2134 from loft-sh/backport/v0.20/pr-2132
Browse files Browse the repository at this point in the history
[v0.20] Merge pull request #2132 from FabianKramm/main
  • Loading branch information
FabianKramm authored Sep 11, 2024
2 parents cf8bcac + 8d384c5 commit 1363a2b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
5 changes: 3 additions & 2 deletions cmd/vclusterctl/cmd/platform/reset.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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",
},
},
Expand All @@ -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{})
Expand Down
11 changes: 11 additions & 0 deletions cmd/vclusterctl/cmd/platform/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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{
Expand Down

0 comments on commit 1363a2b

Please sign in to comment.