Skip to content

Commit 175a6d2

Browse files
cmagliealessio-perugini
authored andcommitted
Adapt 'core upgrade' command to use PlatformSearch instead of PlatformList
1 parent c80d0ff commit 175a6d2

File tree

1 file changed

+23
-8
lines changed

1 file changed

+23
-8
lines changed

internal/cli/core/upgrade.go

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,30 +60,45 @@ func runUpgradeCommand(args []string, skipPostInstall bool, skipPreUninstall boo
6060
func Upgrade(inst *rpc.Instance, args []string, skipPostInstall bool, skipPreUninstall bool) {
6161
// if no platform was passed, upgrade allthethings
6262
if len(args) == 0 {
63-
targets, err := core.PlatformList(&rpc.PlatformListRequest{
64-
Instance: inst,
65-
UpdatableOnly: true,
63+
platforms, err := core.PlatformSearch(&rpc.PlatformSearchRequest{
64+
Instance: inst,
65+
AllVersions: false,
6666
})
6767
if err != nil {
6868
feedback.Fatal(tr("Error retrieving core list: %v", err), feedback.ErrGeneric)
6969
}
7070

71-
if len(targets.InstalledPlatforms) == 0 {
71+
targets := []*rpc.Platform{}
72+
for _, platform := range platforms.GetSearchOutput() {
73+
if platform.InstalledVersion == "" {
74+
continue
75+
}
76+
if platform.InstalledVersion == platform.LatestVersion {
77+
// if it's not updatable, skip it
78+
continue
79+
}
80+
targets = append(targets, &rpc.Platform{
81+
Metadata: platform.GetMetadata(),
82+
Release: platform.GetLatestRelease(),
83+
})
84+
}
85+
86+
if len(targets) == 0 {
7287
feedback.Print(tr("All the cores are already at the latest version"))
7388
return
7489
}
7590

76-
for _, t := range targets.InstalledPlatforms {
77-
args = append(args, t.Id)
91+
for _, t := range targets {
92+
args = append(args, t.GetMetadata().Id)
7893
}
7994
}
8095

8196
warningMissingIndex := func(response *rpc.PlatformUpgradeResponse) {
8297
if response == nil || response.Platform == nil {
8398
return
8499
}
85-
if !response.Platform.Indexed {
86-
feedback.Warning(tr("missing package index for %s, future updates cannot be guaranteed", response.Platform.Id))
100+
if !response.Platform.GetMetadata().Indexed {
101+
feedback.Warning(tr("missing package index for %s, future updates cannot be guaranteed", response.Platform.GetMetadata().Id))
87102
}
88103
}
89104

0 commit comments

Comments
 (0)