Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Automatically download indexes, if missing, in gRPC Init call #2119

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

Merged
merged 6 commits into from
Jun 16, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Created core.PlatformList implementaion follow gRPC naming
Previously it was named GetPlatforms with a different return type than
the one defined in gRPC API .proto files.
  • Loading branch information
cmaglie committed Jun 16, 2023
commit e5da0d6fb5a50021ac6f70ef0dff30daabe4b5dc
6 changes: 3 additions & 3 deletions 6 commands/core/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ import (
rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
)

// GetPlatforms returns a list of installed platforms, optionally filtered by
// PlatformList returns a list of installed platforms, optionally filtered by
// those requiring an update.
func GetPlatforms(req *rpc.PlatformListRequest) ([]*rpc.Platform, error) {
func PlatformList(req *rpc.PlatformListRequest) (*rpc.PlatformListResponse, error) {
pme, release := commands.GetPackageManagerExplorer(req)
if pme == nil {
return nil, &arduino.InvalidInstanceError{}
Expand Down Expand Up @@ -85,5 +85,5 @@ func GetPlatforms(req *rpc.PlatformListRequest) ([]*rpc.Platform, error) {
}
return false
})
return res, nil
return &rpc.PlatformListResponse{InstalledPlatforms: res}, nil
}
7 changes: 2 additions & 5 deletions 7 commands/daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,11 +284,8 @@ func (s *ArduinoCoreServerImpl) PlatformSearch(ctx context.Context, req *rpc.Pla

// PlatformList FIXMEDOC
func (s *ArduinoCoreServerImpl) PlatformList(ctx context.Context, req *rpc.PlatformListRequest) (*rpc.PlatformListResponse, error) {
platforms, err := core.GetPlatforms(req)
if err != nil {
return nil, convertErrorToRPCStatus(err)
}
return &rpc.PlatformListResponse{InstalledPlatforms: platforms}, nil
platforms, err := core.PlatformList(req)
return platforms, convertErrorToRPCStatus(err)
}

// Upload FIXMEDOC
Expand Down
34 changes: 34 additions & 0 deletions 34 docs/UPGRADING.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,40 @@ has been removed as well.

That method was outdated and must not be used.

### golang API: method `github.com/arduino/arduino-cli/commands/core/GetPlatforms` renamed

The following method in `github.com/arduino/arduino-cli/commands/core`:

```go
func GetPlatforms(req *rpc.PlatformListRequest) ([]*rpc.Platform, error) { ... }
```

has been changed to:

```go
func PlatformList(req *rpc.PlatformListRequest) (*rpc.PlatformListResponse, error) { ... }
```

now it better follows the gRPC API interface. Old code like the following:

```go
platforms, _ := core.GetPlatforms(&rpc.PlatformListRequest{Instance: inst})
for _, i := range platforms {
...
}
```

must be changed as follows:

```go
// Use PlatformList function instead of GetPlatforms
platforms, _ := core.PlatformList(&rpc.PlatformListRequest{Instance: inst})
// Access installed platforms through the .InstalledPlatforms field
for _, i := range platforms.InstalledPlatforms {
...
}
```

## 0.31.0

### Added `post_install` script support for tools
Expand Down
4 changes: 2 additions & 2 deletions 4 internal/cli/arguments/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,14 @@ func GetInstalledProgrammers() []string {
func GetUninstallableCores() []string {
inst := instance.CreateAndInit()

platforms, _ := core.GetPlatforms(&rpc.PlatformListRequest{
platforms, _ := core.PlatformList(&rpc.PlatformListRequest{
Instance: inst,
UpdatableOnly: false,
All: false,
})
var res []string
// transform the data structure for the completion
for _, i := range platforms {
for _, i := range platforms.InstalledPlatforms {
res = append(res, i.Id+"\t"+i.Name)
}
return res
Expand Down
6 changes: 3 additions & 3 deletions 6 internal/cli/arguments/reference.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,15 @@ func ParseReference(arg string) (*Reference, error) {
ret.Architecture = toks[1]

// Now that we have the required informations in `ret` we can
// try to use core.GetPlatforms to optimize what the user typed
// try to use core.PlatformList to optimize what the user typed
// (by replacing the PackageName and Architecture in ret with the content of core.GetPlatform())
platforms, _ := core.GetPlatforms(&rpc.PlatformListRequest{
platforms, _ := core.PlatformList(&rpc.PlatformListRequest{
Instance: instance.CreateAndInit(),
UpdatableOnly: false,
All: true, // this is true because we want also the installable platforms
})
foundPlatforms := []string{}
for _, platform := range platforms {
for _, platform := range platforms.InstalledPlatforms {
platformID := platform.GetId()
platformUser := ret.PackageName + ":" + ret.Architecture
// At first we check if the platform the user is searching for matches an available one,
Expand Down
4 changes: 2 additions & 2 deletions 4 internal/cli/core/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ func List(inst *rpc.Instance, all bool, updatableOnly bool) {

// GetList returns a list of installed platforms.
func GetList(inst *rpc.Instance, all bool, updatableOnly bool) []*rpc.Platform {
platforms, err := core.GetPlatforms(&rpc.PlatformListRequest{
platforms, err := core.PlatformList(&rpc.PlatformListRequest{
Instance: inst,
UpdatableOnly: updatableOnly,
All: all,
})
if err != nil {
feedback.Fatal(tr("Error listing platforms: %v", err), feedback.ErrGeneric)
}
return platforms
return platforms.InstalledPlatforms
}

// output from this command requires special formatting, let's create a dedicated
Expand Down
6 changes: 3 additions & 3 deletions 6 internal/cli/core/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,20 @@ func runUpgradeCommand(args []string, skipPostInstall bool) {
func Upgrade(inst *rpc.Instance, args []string, skipPostInstall bool) {
// if no platform was passed, upgrade allthethings
if len(args) == 0 {
targets, err := core.GetPlatforms(&rpc.PlatformListRequest{
targets, err := core.PlatformList(&rpc.PlatformListRequest{
Instance: inst,
UpdatableOnly: true,
})
if err != nil {
feedback.Fatal(tr("Error retrieving core list: %v", err), feedback.ErrGeneric)
}

if len(targets) == 0 {
if len(targets.InstalledPlatforms) == 0 {
feedback.Print(tr("All the cores are already at the latest version"))
return
}

for _, t := range targets {
for _, t := range targets.InstalledPlatforms {
args = append(args, t.Id)
}
}
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.