Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: reset password namespace & start chart name #2132

Merged
merged 2 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions cmd/vclusterctl/cmd/platform/reset.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,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 @@ -117,7 +118,7 @@ func (cmd *PasswordCmd) Run() error {
},
PasswordRef: &storagev1.SecretRef{
SecretName: "loft-password-" + random.String(5),
SecretNamespace: "loft",
SecretNamespace: cmd.Namespace,
Key: "password",
},
},
Expand All @@ -138,7 +139,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" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this hard-coded?

Upgraded platforms will still have loft, but only fresh installs will have vcluster-platform.

Also, users could choose any namespace name that they want.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not about the namespace its the chart that doesn't exist prior to v4.0.0-alpha.0

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
Loading