-
-
Notifications
You must be signed in to change notification settings - Fork 398
Fix core upgrade #291
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
Fix core upgrade #291
Conversation
res[i] = n | ||
i++ | ||
} | ||
sortutil.CiAsc(res) | ||
return res | ||
} | ||
|
||
// GetDepsOfPlatformRelease returns the deps of a specified release of a core. | ||
func (packages Packages) GetDepsOfPlatformRelease(release *PlatformRelease) ([]*ToolRelease, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was just moved up in the source module
type Packages struct { | ||
Packages map[string]*Package // Maps packager name to Package | ||
} | ||
type Packages map[string]*Package // Maps packager name to Package |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no reason for this indirection level that also makes the use of the map awkward by having to repeat packages.Packages
, this way "packages is a map" and can be used directly
@@ -44,13 +40,13 @@ type Package struct { | |||
Email string // Email of maintainer. | |||
Platforms map[string]*Platform // The platforms in the system. | |||
Tools map[string]*Tool // The tools in the system. | |||
Packages *Packages `json:"-"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
now that Packages
is aliased to a map, no need to send around a pointer, map is already a reference
@@ -132,27 +152,3 @@ func (tdep ToolDependency) extractRelease(sc Packages) (*ToolRelease, error) { | |||
} | |||
return release, nil | |||
} | |||
|
|||
// GetDepsOfPlatformRelease returns the deps of a specified release of a core. | |||
func (packages *Packages) GetDepsOfPlatformRelease(release *PlatformRelease) ([]*ToolRelease, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see previous comment, this was just moved
@@ -71,7 +77,7 @@ func upgradePlatform(pm *packagemanager.PackageManager, platformRef *packagemana | |||
} | |||
latest := platform.GetLatestRelease() | |||
if !latest.Version.GreaterThan(installed.Version) { | |||
return fmt.Errorf("platform %s is already at the latest version", platformRef) | |||
return ErrAlreadyLatest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this way we avoid returning an error if users ask to upgrade a core that's already latest
rpcPlatform := core.PlatformReleaseToRPC(p) | ||
rpcPlatform.Installed = p.Version.String() | ||
installed = append(installed, rpcPlatform) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this code was moved here from the core
package since here it's legit to depend on rpc
IndexDir: indexDir, | ||
PackagesDir: packagesDir, | ||
DownloadDir: downloadDir, | ||
TempDir: tempDir, | ||
} | ||
} | ||
|
||
// Clear FIXMEDOC | ||
func (pm *PackageManager) Clear() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this wasn't used anywhere
Affected by the same issue as libs
does not solve #285 either. Everything else LGTM |
@mastrolinux my bad, I copypasted the wrong issue number, this is actually for #273 I've fixed PR description |
I can confirm that is fixed and I am going to prepare an integration test for it. |
This PR fixes the case where no args are passed to the upgrade command, like:
Now an upgrade will be performed to any core that is up to date. If all the cores are at the latest version, command is a no op and will exit without errors, providing and info message.
Fixes
#285#273Additional notes
I took the opportunity to review the design of the code that lists all the available cores that was depending on the
rpc
package for no reason. Also the api of the oldPlatformList
required acontext
that was never used.Other minor improvements are commented inline.