Skip to content

Commit

Permalink
Updated gRPC Pltform API, regenerated API
Browse files Browse the repository at this point in the history
  • Loading branch information
cmaglie committed Oct 6, 2023
1 parent f561da0 commit 3e1f5f9
Show file tree
Hide file tree
Showing 5 changed files with 496 additions and 213 deletions.
39 changes: 22 additions & 17 deletions commands/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,25 @@ import (
rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
)

// PlatformToRPCPlatformMetadata converts our internal structure to the RPC structure.
func PlatformToRPCPlatformMetadata(platform *cores.Platform) *rpc.PlatformMetadata {
return &rpc.PlatformMetadata{
Id: platform.String(),
Name: platform.Name,
Maintainer: platform.Package.Maintainer,
Website: platform.Package.WebsiteURL,
Email: platform.Package.Email,
ManuallyInstalled: platform.ManuallyInstalled,
Deprecated: platform.Deprecated,
Type: []string{platform.Category},
Indexed: platform.Indexed,
}
}

// PlatformReleaseToRPC converts our internal structure to the RPC structure.
// Note: this function does not touch the "Installed" field of rpc.Platform as it's not always clear that the
// platformRelease we're currently converting is actually installed.
func PlatformReleaseToRPC(platformRelease *cores.PlatformRelease) *rpc.Platform {
func PlatformReleaseToRPC(platformRelease *cores.PlatformRelease) *rpc.PlatformRelease {
// If the boards are not installed yet, the `platformRelease.Boards` will be a zero length slice.
// In such case, we have to use the `platformRelease.BoardsManifest` instead.
// So that we can retrieve the name of the boards at least.
Expand All @@ -50,21 +65,11 @@ func PlatformReleaseToRPC(platformRelease *cores.PlatformRelease) *rpc.Platform
}
}

result := &rpc.Platform{
Id: platformRelease.Platform.String(),
Name: platformRelease.Platform.Name,
Maintainer: platformRelease.Platform.Package.Maintainer,
Website: platformRelease.Platform.Package.WebsiteURL,
Email: platformRelease.Platform.Package.Email,
Help: &rpc.HelpResources{Online: platformRelease.Platform.Package.Help.Online},
Boards: boards,
Latest: platformRelease.Version.String(),
ManuallyInstalled: platformRelease.Platform.ManuallyInstalled,
Deprecated: platformRelease.Platform.Deprecated,
Type: []string{platformRelease.Platform.Category},
Indexed: platformRelease.Platform.Indexed,
MissingMetadata: !platformRelease.HasMetadata(),
return &rpc.PlatformRelease{
Help: &rpc.HelpResources{Online: platformRelease.Platform.Package.Help.Online},
Boards: boards,
Version: platformRelease.Version.String(),
Installed: platformRelease.IsInstalled(),
MissingMetadata: !platformRelease.HasMetadata(),
}

return result
}
Loading

0 comments on commit 3e1f5f9

Please sign in to comment.