Skip to content

Commit

Permalink
Merge pull request #1544 from rohantmp/fixUpgrade
Browse files Browse the repository at this point in the history
fix: ensure vcluster upgrade downloads correct binary
  • Loading branch information
FabianKramm authored Feb 14, 2024
2 parents bad32bb + 0aecfea commit 467824b
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 467824b

Please sign in to comment.