@@ -59,22 +59,32 @@ func List(inst *rpc.Instance, all bool, updatableOnly bool) {
59
59
}
60
60
61
61
// GetList returns a list of installed platforms.
62
- func GetList (inst * rpc.Instance , all bool , updatableOnly bool ) []* rpc.Platform {
63
- platforms , err := core .PlatformList (& rpc.PlatformListRequest {
64
- Instance : inst ,
65
- UpdatableOnly : updatableOnly ,
66
- All : all ,
62
+ func GetList (inst * rpc.Instance , all bool , updatableOnly bool ) []* rpc.PlatformSummary {
63
+ platforms , err := core .PlatformSearch (& rpc.PlatformSearchRequest {
64
+ Instance : inst ,
65
+ AllVersions : true ,
67
66
})
68
67
if err != nil {
69
68
feedback .Fatal (tr ("Error listing platforms: %v" , err ), feedback .ErrGeneric )
70
69
}
71
- return platforms .InstalledPlatforms
70
+
71
+ result := []* rpc.PlatformSummary {}
72
+ for _ , platform := range platforms .GetSearchOutput () {
73
+ if ! all && platform .InstalledVersion == "" {
74
+ continue
75
+ }
76
+ if updatableOnly && platform .InstalledVersion == platform .LatestVersion {
77
+ continue
78
+ }
79
+ result = append (result , platform )
80
+ }
81
+ return result
72
82
}
73
83
74
84
// output from this command requires special formatting, let's create a dedicated
75
85
// feedback.Result implementation
76
86
type installedResult struct {
77
- platforms []* rpc.Platform
87
+ platforms []* rpc.PlatformSummary
78
88
}
79
89
80
90
func (ir installedResult ) Data () interface {} {
@@ -87,12 +97,18 @@ func (ir installedResult) String() string {
87
97
}
88
98
t := table .New ()
89
99
t .SetHeader (tr ("ID" ), tr ("Installed" ), tr ("Latest" ), tr ("Name" ))
90
- for _ , p := range ir .platforms {
91
- name := p .Name
92
- if p .Deprecated {
100
+ for _ , platform := range ir .platforms {
101
+ installedRelease := platform .GetInstalledRelease ()
102
+ latestRelease := platform .GetLatestRelease ()
103
+
104
+ name := installedRelease .GetName ()
105
+ if name == "" {
106
+ name = latestRelease .GetName ()
107
+ }
108
+ if platform .Metadata .Deprecated {
93
109
name = fmt .Sprintf ("[%s] %s" , tr ("DEPRECATED" ), name )
94
110
}
95
- t .AddRow (p . Id , p . Installed , p . Latest , name )
111
+ t .AddRow (platform . Metadata . Id , platform . InstalledVersion , platform . LatestVersion , name )
96
112
}
97
113
98
114
return t .Render ()
0 commit comments