Skip to content

Commit

Permalink
Bypass email prompt for upgrades if installed
Browse files Browse the repository at this point in the history
  • Loading branch information
zerbitx committed Dec 13, 2024
1 parent fa41bde commit 79b57e3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
27 changes: 22 additions & 5 deletions cmd/vclusterctl/cmd/platform/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package platform
import (
"context"
"fmt"
"k8s.io/client-go/kubernetes"
"strings"
"time"

Expand Down Expand Up @@ -84,10 +85,6 @@ before running this command:
}

func (cmd *StartCmd) Run(ctx context.Context) error {
if err := cmd.ensureEmailWithDisclaimer(); err != nil {
return err
}

// get version to deploy
if cmd.Version == "latest" || cmd.Version == "" {
cmd.Version = platform.MinimumVersionTag
Expand Down Expand Up @@ -150,10 +147,30 @@ func (cmd *StartCmd) Run(ctx context.Context) error {
}
}

if err := cmd.StartOptions.Prepare(false); err != nil {
return err
}

if err := cmd.ensureEmailWithDisclaimer(ctx, cmd.KubeClient, cmd.Namespace); err != nil {
return err
}

return start.NewLoftStarter(cmd.StartOptions).Start(ctx)
}

func (cmd *StartCmd) ensureEmailWithDisclaimer() error {
func (cmd *StartCmd) ensureEmailWithDisclaimer(ctx context.Context, kc kubernetes.Interface, namespace string) error {
if cmd.Upgrade {
isInstalled, err := clihelper.IsLoftAlreadyInstalled(ctx, kc, namespace)

if err != nil {
return err
}

if isInstalled {
return nil
}
}

fmt.Printf(`By providing your email, you accept our Terms of Service and Privacy Statement:
Terms of Service: https://www.loft.sh/legal/terms
Privacy Statement: https://www.loft.sh/legal/privacy
Expand Down
6 changes: 1 addition & 5 deletions pkg/cli/start/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,11 @@ func (l *LoftStarter) Start(ctx context.Context) error {
l.LocalPort = "9898"
}

err := l.Prepare(false)
if err != nil {
return err
}
l.Log.WriteString(logrus.InfoLevel, "\n")

// Uninstall already existing Loft instance
if l.Reset {
err = clihelper.UninstallLoft(ctx, l.KubeClient, l.RestConfig, l.Context, l.Namespace, l.Log)
err := clihelper.UninstallLoft(ctx, l.KubeClient, l.RestConfig, l.Context, l.Namespace, l.Log)
if err != nil {
return err
}
Expand Down

0 comments on commit 79b57e3

Please sign in to comment.