Skip to content

Commit

Permalink
fix: ensure vcluster upgrade uses correct binary
Browse files Browse the repository at this point in the history
Signed-off-by: Rohan CJ <rohantmp@gmail.com>
  • Loading branch information
rohantmp committed Feb 14, 2024
1 parent bad32bb commit 0aecfea
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions pkg/upgrade/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,14 @@ func NewerVersionAvailable() string {

// Upgrade downloads the latest release from github and replaces vcluster if a new version is found
func Upgrade(flagVersion string, log log.Logger) error {
updater, err := selfupdate.NewUpdater(selfupdate.Config{
Filters: []string{"vcluster"},
})
if err != nil {
return fmt.Errorf("failed to initialize updater: %w", err)
}
if flagVersion != "" {
release, found, err := selfupdate.DetectVersion(githubSlug, flagVersion)
release, found, err := updater.DetectVersion(githubSlug, flagVersion)
if err != nil {
return errors.Wrap(err, "find version")
} else if !found {
Expand All @@ -127,7 +133,7 @@ func Upgrade(flagVersion string, log log.Logger) error {
}

log.Infof("Downloading version %s...", flagVersion)
err = selfupdate.DefaultUpdater().UpdateTo(release, cmdPath)
err = updater.UpdateTo(release, cmdPath)
if err != nil {
return err
}
Expand All @@ -148,7 +154,7 @@ func Upgrade(flagVersion string, log log.Logger) error {
v := semver.MustParse(version)

log.Info("Downloading newest version...")
latest, err := selfupdate.UpdateSelf(v, githubSlug)
latest, err := updater.UpdateSelf(v, githubSlug)
if err != nil {
return err
}
Expand Down

0 comments on commit 0aecfea

Please sign in to comment.