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

Auto update ridectl to latest version #139

Merged
merged 3 commits into from
Jul 25, 2023
Merged
Changes from 2 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
14 changes: 6 additions & 8 deletions pkg/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import (

"github.com/Ridecell/ridectl/pkg/utils"
"github.com/inconshreveable/go-update"
"github.com/manifoldco/promptui"
"github.com/mitchellh/go-homedir"
"github.com/pterm/pterm"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -82,17 +81,16 @@ func init() {

// check version and update if not latest
if !isLatestVersion() {
updatePrompt := promptui.Prompt{
Label: "Do you want to update to latest version",
IsConfirm: true,
}
shouldUpdate, _ := updatePrompt.Run()
if shouldUpdate == "y" {
skipUpgrade := os.Getenv("RIDECTL_SKIP_UPGRADE")
if skipUpgrade != "true" {
selfUpdate()
pterm.Info.Println("Ridectl update is completed. Please re-run the command.")
os.Exit(0)
} else {
pterm.Warning.Println("RIDECTL_SKIP_UPGRADE is set to true, hence skipping ridectl upgrade.")
}
}

// Register all types from summon-operator and ridecell-controllers secrets
_ = summonv1beta2.AddToScheme(scheme.Scheme)
_ = secretsv1beta2.AddToScheme(scheme.Scheme)
Expand Down Expand Up @@ -136,7 +134,7 @@ func isLatestVersion() bool {
}

if version != data.TagName {
pterm.Warning.Printf("You are running an older version of ridectl: %s. Latest: %s\n.", version, data.TagName)
pterm.Warning.Printf("You are running an older version of ridectl: %s. Latest: %s.\n", version, data.TagName)
return false
}

Expand Down