Skip to content

Commit 240ceeb

Browse files
committed
Updated gRPC Pltform API, regenerated API
1 parent 748fcf6 commit 240ceeb

File tree

9 files changed

+738
-651
lines changed

9 files changed

+738
-651
lines changed

commands/core.go

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,23 @@ import (
2020
rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
2121
)
2222

23+
// PlatformToRPCPlatformMetadata converts our internal structure to the RPC structure.
24+
func PlatformToRPCPlatformMetadata(platform *cores.Platform) *rpc.PlatformMetadata {
25+
return &rpc.PlatformMetadata{
26+
Id: platform.String(),
27+
Maintainer: platform.Package.Maintainer,
28+
Website: platform.Package.WebsiteURL,
29+
Email: platform.Package.Email,
30+
ManuallyInstalled: platform.ManuallyInstalled,
31+
Deprecated: platform.Deprecated_,
32+
Indexed: platform.Indexed,
33+
}
34+
}
35+
2336
// PlatformReleaseToRPC converts our internal structure to the RPC structure.
2437
// Note: this function does not touch the "Installed" field of rpc.Platform as it's not always clear that the
2538
// platformRelease we're currently converting is actually installed.
26-
func PlatformReleaseToRPC(platformRelease *cores.PlatformRelease) *rpc.Platform {
39+
func PlatformReleaseToRPC(platformRelease *cores.PlatformRelease) *rpc.PlatformRelease {
2740
// If the boards are not installed yet, the `platformRelease.Boards` will be a zero length slice.
2841
// In such case, we have to use the `platformRelease.BoardsManifest` instead.
2942
// So that we can retrieve the name of the boards at least.
@@ -50,21 +63,14 @@ func PlatformReleaseToRPC(platformRelease *cores.PlatformRelease) *rpc.Platform
5063
}
5164
}
5265

53-
result := &rpc.Platform{
54-
Id: platformRelease.Platform.String(),
55-
Name: platformRelease.Platform.Name,
56-
Maintainer: platformRelease.Platform.Package.Maintainer,
57-
Website: platformRelease.Platform.Package.WebsiteURL,
58-
Email: platformRelease.Platform.Package.Email,
59-
Help: &rpc.HelpResources{Online: platformRelease.Platform.Package.Help.Online},
60-
Boards: boards,
61-
Latest: platformRelease.Version.String(),
62-
ManuallyInstalled: platformRelease.Platform.ManuallyInstalled,
63-
Deprecated: platformRelease.Platform.Deprecated,
64-
Type: []string{platformRelease.Platform.Category},
65-
Indexed: platformRelease.Platform.Indexed,
66-
MissingMetadata: !platformRelease.HasMetadata(),
66+
return &rpc.PlatformRelease{
67+
Name: platformRelease.Name,
68+
Help: &rpc.HelpResources{Online: platformRelease.Platform.Package.Help.Online},
69+
Boards: boards,
70+
Version: platformRelease.Version.String(),
71+
Installed: platformRelease.IsInstalled(),
72+
MissingMetadata: !platformRelease.HasMetadata(),
73+
Type: []string{platformRelease.Category},
74+
Deprecated: platformRelease.Deprecated,
6775
}
68-
69-
return result
7076
}

rpc/cc/arduino/cli/commands/v1/commands.pb.go

Lines changed: 204 additions & 215 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rpc/cc/arduino/cli/commands/v1/commands.proto

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,6 @@ service ArduinoCoreService {
131131
// Search for a platform in the platforms indexes.
132132
rpc PlatformSearch(PlatformSearchRequest) returns (PlatformSearchResponse);
133133

134-
// List all installed platforms.
135-
rpc PlatformList(PlatformListRequest) returns (PlatformListResponse);
136-
137134
// Download the archive file of an Arduino library in the libraries index to
138135
// the staging directory.
139136
rpc LibraryDownload(LibraryDownloadRequest)

rpc/cc/arduino/cli/commands/v1/commands_grpc.pb.go

Lines changed: 0 additions & 39 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rpc/cc/arduino/cli/commands/v1/common.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,21 @@ type TaskProgressCB func(msg *TaskProgress)
6262
type InstanceCommand interface {
6363
GetInstance() *Instance
6464
}
65+
66+
// GetLatestRelease returns the latest release in this PlatformSummary,
67+
// or nil if not available.
68+
func (s *PlatformSummary) GetLatestRelease() *PlatformRelease {
69+
if s.LatestVersion == "" {
70+
return nil
71+
}
72+
return s.Releases[s.LatestVersion]
73+
}
74+
75+
// GetInstalledRelease returns the latest release in this PlatformSummary,
76+
// or nil if not available.
77+
func (s *PlatformSummary) GetInstalledRelease() *PlatformRelease {
78+
if s.InstalledVersion == "" {
79+
return nil
80+
}
81+
return s.Releases[s.InstalledVersion]
82+
}

0 commit comments

Comments
 (0)