From 0aecfea79e8cab9f1bed1ea7e3f416718596f8ba Mon Sep 17 00:00:00 2001 From: Rohan CJ Date: Wed, 14 Feb 2024 14:48:09 +0530 Subject: [PATCH] fix: ensure vcluster upgrade uses correct binary Signed-off-by: Rohan CJ --- pkg/upgrade/upgrade.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pkg/upgrade/upgrade.go b/pkg/upgrade/upgrade.go index 5de9fcb2a..d2416749e 100644 --- a/pkg/upgrade/upgrade.go +++ b/pkg/upgrade/upgrade.go @@ -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 { @@ -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 } @@ -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 }