Skip to content

Commit

Permalink
Auto update ridectl to latest version (#139)
Browse files Browse the repository at this point in the history
* Auto update ridectl to latest version

* fix typo

* some more changes

---------

Co-authored-by: Vivek Jain <vivek@ridecell.com>
  • Loading branch information
kunalp-gohire and Vivek Jain committed Jul 25, 2023
1 parent a057bc5 commit d38f0f9
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 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,17 @@ 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" {
pterm.Info.Println("Upgrading ridectl.")
selfUpdate()
pterm.Info.Println("Ridectl update is completed. Please re-run the command.")
os.Exit(0)
} else {
pterm.Info.Println("RIDECTL_SKIP_UPGRADE is set to true, 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 +135,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

0 comments on commit d38f0f9

Please sign in to comment.