8000 [BREAKING] gRPC / golang Configuration API refactoring by cmaglie · Pull Request #2565 · arduino/arduino-cli · GitHub
[go: up one dir, main page]

Skip to content
8000

[BREAKING] gRPC / golang Configuration API refactoring #2565

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 56 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
8c07823
Moved a batch of function from commands/* subpackage to commands
cmaglie Mar 13, 2024
3d8f50a
Moved a batch of function from commands/* subpackage to commands (par…
cmaglie Mar 13, 2024
3ff8e09
Moved a batch of function from commands/* subpackage to commands (par…
cmaglie Mar 13, 2024
8615985
Moved a batch of function from commands/* subpackage to commands (par…
cmaglie Mar 13, 2024
61e5c46
Moved a batch of function from commands/* subpackage to commands (par…
cmaglie Mar 13, 2024
9e75b4d
Removed unused parameters
cmaglie Mar 13, 2024
f1a015c
Removed unused file
cmaglie Mar 13, 2024
c4ca852
Removed ToRPCStatus in favor of standardized GRPCStatus() interface
cmaglie Mar 13, 2024
23ccd43
Inlining methods in ArduinoCoreServiceImpl (part 1: BoardListAll)
cmaglie Mar 13, 2024
53f03e5
Inlining methods in ArduinoCoreServiceImpl (part 2: BoardDetails)
cmaglie Mar 13, 2024
0df2149
Inlining methods in ArduinoCoreServiceImpl (part 3: BoardList)
cmaglie Mar 13, 2024
f65eff2
Inlining methods in ArduinoCoreServiceImpl (part 4: BoardListWatch)
cmaglie Mar 14, 2024
06d6842
Inlining methods in ArduinoCoreServiceImpl (part 5: Create and Destroy)
cmaglie Mar 14, 2024
8bd0eef
Follow convetion where context must be the first argument
cmaglie Mar 14, 2024
a81069d
Inlining methods in ArduinoCoreServiceImpl (part 6: Init)
cmaglie Mar 14, 2024
917dcc5
Inlining methods in ArduinoCoreServiceImpl (part 7: UpdateIndex)
cmaglie Mar 14, 2024
bb815cf
Inlining methods in ArduinoCoreServiceImpl (part 8: Monitor)
cmaglie Mar 15, 2024
0e434f2
Inlining methods in ArduinoCoreServiceImpl (part 9: Compile)
cmaglie Mar 18, 2024
12cf52e
Inlining methods in ArduinoCoreServiceImpl (part 10: PlatformInstall,…
cmaglie Mar 18, 2024
cfe4b27
Inlining methods in ArduinoCoreServiceImpl (part 11: LibraryDownload,…
cmaglie Mar 18, 2024
a3800fa
Inlining methods in ArduinoCoreServiceImpl (part 12: UpdateLibrariesI…
cmaglie Mar 18, 2024
738ad7c
Inlining methods in ArduinoCoreServiceImpl (part 13: NewSketch, LoadS…
cmaglie Mar 18, 2024
0442319
Inlining methods in ArduinoCoreServiceImpl (part 14: Upload, UploadUs…
cmaglie Mar 18, 2024
65ecbaf
Inlining methods in ArduinoCoreServiceImpl (part 15: SupportedUserFie…
cmaglie Mar 18, 2024
0bdc07a
Inlining methods in ArduinoCoreServiceImpl (part 16: CleanDownloadCac…
cmaglie Mar 25, 2024
3193b7c
Made utility functions private and put them in their own file
cmaglie Mar 18, 2024
c08c59e
Run tests forcing the english language
cmaglie Mar 20, 2024
e8e1574
Use correct env var to force configuration in integration test
cmaglie Apr 19, 2024
9bab3c5
Fixed markdown link
cmaglie Apr 19, 2024
6320f6e
Always use arduino-cli in user-agent string
cmaglie Apr 19, 2024
1fddba7
Removed global *viper.Viper settings instance
cmaglie Mar 20, 2024
4c50868
Implementation of Viper replacement library
cmaglie Apr 17, 2024
0453677
Use custom type to avoid context-values collisions
cmaglie Apr 22, 2024
61b66a7
Fixed test
cmaglie Apr 19, 2024
087a6f5
Fixed FindConfigFileInArgsFallbackOnEnv unit test
cmaglie Apr 19, 2024
9cd9c97
Fixed TestUserAgentHeader and TestProxy
cmaglie Apr 19, 2024
384c30c
Improved error message
cmaglie Apr 21, 2024
6aa742f
Config set adds only unique values
cmaglie Apr 21, 2024
0aafda3
Fixed initialization sequence for 'config init' command
cmaglie Apr 21, 2024
921fa61
Config search now looks into ARDUINO_DIRECTORIES_DATA env too
cmaglie Apr 21, 2024
ad8dbd9
Fixed all config* integration test
cmaglie Apr 21, 2024
4061131
Added missing type schema
cmaglie Apr 21, 2024
fa835de
Added docs
cmaglie Apr 23, 2024
72e05ee
Updated documentation about configuration file format
cmaglie Apr 29, 2024
89a79cb
Fixed a small imperfection in test
cmaglie Apr 30, 2024
240c8b3
Pass context in upload and burn-bootloader
cmaglie Apr 30, 2024
24ac040
Pass down context in all places where it's needed
cmaglie Apr 30, 2024
6cf4eb7
Removed unused parameter
cmaglie Apr 30, 2024
27e9c3e
Tolerate errors in invalid config files, and report them as warnings
cmaglie May 2, 2024
7658db6
Improved handling of incomplete configs array
cmaglie May 2, 2024
a58c350
Disable logging until it is setup in the arduino-cli pre-run
cmaglie May 6, 2024
9585728
Show config-load warning after feedback package initialization
cmaglie May 6, 2024
b279d4b
Fixed 'feedback' package initialization order
cmaglie May 6, 2024
278a331
Applied changes from code review
cmaglie May 6, 2024
c355478
Updated client_example
cmaglie May 6, 2024
cec1fdb
Improved array handling in configmap, and unit-tests
cmaglie May 6, 2024
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
Moved a batch of function from commands/* subpackage to commands
This commit is preparatory to move all the implementation of
ArduinoCoreService interface directly as methods of ArduinoCoreService.

The goal is to turn ArduinoCoreService into a proper implementation instead
of being a mere proxy to global functions.
  • Loading branch information
cmaglie committed May 6, 2024
commit 8c07823c10bde9409a42e7b90febb6cf19e7cb2b
2 changes: 1 addition & 1 deletion .github/workflows/check-go-task.yml
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ jobs:
module:
- path: internal/arduino/discovery/discovery_client
- path: rpc/internal/client_example
- path: commands/daemon/term_example
- path: commands/term_example

steps:
- name: Checkout repository
Expand Down
2 changes: 0 additions & 2 deletions commands/instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ import (
"google.golang.org/grpc/status"
)

var tr = i18n.Tr

func installTool(pm *packagemanager.PackageManager, tool *cores.ToolRelease, downloadCB rpc.DownloadProgressCB, taskCB rpc.TaskProgressCB) error {
pme, release := pm.NewExplorer()
defer release()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// Arduino software without disclosing the source code of your own applications.
// To purchase a commercial license, send an email to license@arduino.cc.

package lib
package commands

import (
"strings"
Expand Down
52 changes: 23 additions & 29 deletions commands/daemon/daemon.go → commands/service.go
F987
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// Arduino software without disclosing the source code of your own applications.
// To purchase a commercial license, send an email to license@arduino.cc.

package daemon
package commands

import (
"context"
Expand All @@ -22,18 +22,14 @@ import (
"io"
"sync/atomic"

"github.com/arduino/arduino-cli/commands"
"github.com/arduino/arduino-cli/commands/board"
"github.com/arduino/arduino-cli/commands/cache"
"github.com/arduino/arduino-cli/commands/cmderrors"
"github.com/arduino/arduino-cli/commands/compile"
"github.com/arduino/arduino-cli/commands/core"
"github.com/arduino/arduino-cli/commands/lib"
"github.com/arduino/arduino-cli/commands/monitor"
"github.com/arduino/arduino-cli/commands/sketch"
"github.com/arduino/arduino-cli/commands/updatecheck"
"github.com/arduino/arduino-cli/commands/upload"
"github.com/arduino/arduino-cli/internal/i18n"
rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
"github.com/sirupsen/logrus"
"google.golang.org/grpc/metadata"
Expand All @@ -47,8 +43,6 @@ type ArduinoCoreServerImpl struct {
VersionString string
}

var tr = i18n.Tr

func convertErrorToRPCStatus(err error) error {
if err == nil {
return nil
Expand Down Expand Up @@ -78,13 +72,13 @@ func (s *ArduinoCoreServerImpl) BoardList(ctx context.Context, req *rpc.BoardLis

// BoardListAll FIXMEDOC
func (s *ArduinoCoreServerImpl) BoardListAll(ctx context.Context, req *rpc.BoardListAllRequest) (*rpc.BoardListAllResponse, error) {
resp, err := board.ListAll(ctx, req)
resp, err := BoardListAll(ctx, req)
return resp, convertErrorToRPCStatus(err)
}

// BoardSearch exposes to the gRPC interface the board search command
func (s *ArduinoCoreServerImpl) BoardSearch(ctx context.Context, req *rpc.BoardSearchRequest) (*rpc.BoardSearchResponse, error) {
resp, err := board.Search(ctx, req)
resp, err := BoardSearch(ctx, req)
return resp, convertErrorToRPCStatus(err)
}

Expand Down Expand Up @@ -116,14 +110,14 @@ func (s *ArduinoCoreServerImpl) BoardListWatch(req *rpc.BoardListWatchRequest, s

// Destroy FIXMEDOC
func (s *ArduinoCoreServerImpl) Destroy(ctx context.Context, req *rpc.DestroyRequest) (*rpc.DestroyResponse, error) {
resp, err := commands.Destroy(ctx, req)
resp, err := Destroy(ctx, req)
return resp, convertErrorToRPCStatus(err)
}

// UpdateIndex FIXMEDOC
func (s *ArduinoCoreServerImpl) UpdateIndex(req *rpc.UpdateIndexRequest, stream rpc.ArduinoCoreService_UpdateIndexServer) error {
syncSend := NewSynchronizedSend(stream.Send)
res, err := commands.UpdateIndex(stream.Context(), req,
res, err := UpdateIndex(stream.Context(), req,
func(p *rpc.DownloadProgress) {
syncSend.Send(&rpc.UpdateIndexResponse{
Message: &rpc.UpdateIndexResponse_DownloadProgress{DownloadProgress: p},
Expand All @@ -141,7 +135,7 @@ func (s *ArduinoCoreServerImpl) UpdateIndex(req *rpc.UpdateIndexRequest, stream
// UpdateLibrariesIndex FIXMEDOC
func (s *ArduinoCoreServerImpl) UpdateLibrariesIndex(req *rpc.UpdateLibrariesIndexRequest, stream rpc.ArduinoCoreService_UpdateLibrariesIndexServer) error {
syncSend := NewSynchronizedSend(stream.Send)
res, err := commands.UpdateLibrariesIndex(stream.Context(), req,
res, err := UpdateLibrariesIndex(stream.Context(), req,
func(p *rpc.DownloadProgress) {
syncSend.Send(&rpc.UpdateLibrariesIndexResponse{
Message: &rpc.UpdateLibrariesIndexResponse_DownloadProgress{DownloadProgress: p},
Expand All @@ -165,14 +159,14 @@ func (s *ArduinoCoreServerImpl) Create(ctx context.Context, req *rpc.CreateReque
if len(userAgent) == 0 {
userAgent = []string{"gRPCClientUnknown/0.0.0"}
}
res, err := commands.Create(req, userAgent...)
res, err := Create(req, userAgent...)
return res, convertErrorToRPCStatus(err)
}

// Init FIXMEDOC
func (s *ArduinoCoreServerImpl) Init(req *rpc.InitRequest, stream rpc.ArduinoCoreService_InitServer) error {
syncSend := NewSynchronizedSend(stream.Send)
err := commands.Init(req, func(message *rpc.InitResponse) { syncSend.Send(message) })
err := Init(req, func(message *rpc.InitResponse) { syncSend.Send(message) })
return convertErrorToRPCStatus(err)
}

Expand Down Expand Up @@ -237,7 +231,7 @@ func (s *ArduinoCoreServerImpl) Compile(req *rpc.CompileRequest, stream rpc.Ardu
// PlatformInstall FIXMEDOC
func (s *ArduinoCoreServerImpl) PlatformInstall(req *rpc.PlatformInstallRequest, stream rpc.ArduinoCoreService_PlatformInstallServer) error {
syncSend := NewSynchronizedSend(stream.Send)
resp, err := core.PlatformInstall(
resp, err := PlatformInstall(
stream.Context(), req,
func(p *rpc.DownloadProgress) { syncSend.Send(&rpc.PlatformInstallResponse{Progress: p}) },
func(p *rpc.TaskProgress) { syncSend.Send(&rpc.PlatformInstallResponse{TaskProgress: p}) },
Expand All @@ -251,7 +245,7 @@ func (s *ArduinoCoreServerImpl) PlatformInstall(req *rpc.PlatformInstallRequest,
// PlatformDownload FIXMEDOC
func (s *ArduinoCoreServerImpl) PlatformDownload(req *rpc.PlatformDownloadRequest, stream rpc.ArduinoCoreService_PlatformDownloadServer) error {
syncSend := NewSynchronizedSend(stream.Send)
resp, err := core.PlatformDownload(
resp, err := PlatformDownload(
stream.Context(), req,
func(p *rpc.DownloadProgress) { syncSend.Send(&rpc.PlatformDownloadResponse{Progress: p}) },
)
Expand All @@ -264,7 +258,7 @@ func (s *ArduinoCoreServerImpl) PlatformDownload(req *rpc.PlatformDownloadReques
// PlatformUninstall FIXMEDOC
func (s *ArduinoCoreServerImpl) PlatformUninstall(req *rpc.PlatformUninstallRequest, stream rpc.ArduinoCoreService_PlatformUninstallServer) error {
syncSend := NewSynchronizedSend(stream.Send)
resp, err := core.PlatformUninstall(
resp, err := PlatformUninstall(
stream.Context(), req,
func(p *rpc.TaskProgress) { syncSend.Send(&rpc.PlatformUninstallResponse{TaskProgress: p}) },
)
Expand All @@ -277,7 +271,7 @@ func (s *ArduinoCoreServerImpl) PlatformUninstall(req *rpc.PlatformUninstallRequ
// PlatformUpgrade FIXMEDOC
func (s *ArduinoCoreServerImpl) PlatformUpgrade(req *rpc.PlatformUpgradeRequest, stream rpc.ArduinoCoreService_PlatformUpgradeServer) error {
syncSend := NewSynchronizedSend(stream.Send)
resp, err := core.PlatformUpgrade(
resp, err := PlatformUpgrade(
stream.Context(), req,
func(p *rpc.DownloadProgress) { syncSend.Send(&rpc.PlatformUpgradeResponse{Progress: p}) },
func(p *rpc.TaskProgress) { syncSend.Send(&rpc.PlatformUpgradeResponse{TaskProgress: p}) },
Expand All @@ -290,7 +284,7 @@ func (s *ArduinoCoreServerImpl) PlatformUpgrade(req *rpc.PlatformUpgradeRequest,

// PlatformSearch FIXMEDOC
func (s *ArduinoCoreServerImpl) PlatformSearch(ctx context.Context, req *rpc.PlatformSearchRequest) (*rpc.PlatformSearchResponse, error) {
resp, err := core.PlatformSearch(req)
resp, err := PlatformSearch(req)
return resp, convertErrorToRPCStatus(err)
}

Expand Down Expand Up @@ -387,7 +381,7 @@ func (s *ArduinoCoreServerImpl) ListProgrammersAvailableForUpload(ctx context.Co
// LibraryDownload FIXMEDOC
func (s *ArduinoCoreServerImpl) LibraryDownload(req *rpc.LibraryDownloadRequest, stream rpc.ArduinoCoreService_LibraryDownloadServer) error {
syncSend := NewSynchronizedSend(stream.Send)
resp, err := lib.LibraryDownload(
resp, err := LibraryDownload(
stream.Context(), req,
func(p *rpc.DownloadProgress) { syncSend.Send(&rpc.LibraryDownloadResponse{Progress: p}) },
)
Expand All @@ -400,7 +394,7 @@ func (s *ArduinoCoreServerImpl) LibraryDownload(req *rpc.LibraryDownloadRequest,
// LibraryInstall FIXMEDOC
func (s *ArduinoCoreServerImpl) LibraryInstall(req *rpc.LibraryInstallRequest, stream rpc.ArduinoCoreService_LibraryInstallServer) error {
syncSend := NewSynchronizedSend(stream.Send)
err := lib.LibraryInstall(
err := LibraryInstall(
stream.Context(), req,
func(p *rpc.DownloadProgress) { syncSend.Send(&rpc.LibraryInstallResponse{Progress: p}) },
func(p *rpc.TaskProgress) { syncSend.Send(&rpc.LibraryInstallResponse{TaskProgress: p}) },
Expand All @@ -411,7 +405,7 @@ func (s *ArduinoCoreServerImpl) LibraryInstall(req *rpc.LibraryInstallRequest, s
// LibraryUpgrade FIXMEDOC
func (s *ArduinoCoreServerImpl) LibraryUpgrade(req *rpc.LibraryUpgradeRequest, stream rpc.ArduinoCoreService_LibraryUpgradeServer) error {
syncSend := NewSynchronizedSend(stream.Send)
err := lib.LibraryUpgrade(
err := LibraryUpgrade(
stream.Context(), req,
func(p *rpc.DownloadProgress) { syncSend.Send(&rpc.LibraryUpgradeResponse{Progress: p}) },
func(p *rpc.TaskProgress) { syncSend.Send(&rpc.LibraryUpgradeResponse{TaskProgress: p}) },
Expand All @@ -422,7 +416,7 @@ func (s *ArduinoCoreServerImpl) LibraryUpgrade(req *rpc.LibraryUpgradeRequest, s
// LibraryUninstall FIXMEDOC
func (s *ArduinoCoreServerImpl) LibraryUninstall(req *rpc.LibraryUninstallRequest, stream rpc.ArduinoCoreService_LibraryUninstallServer) error {
syncSend := NewSynchronizedSend(stream.Send)
err := lib.LibraryUninstall(stream.Context(), req,
err := LibraryUninstall(stream.Context(), req,
func(p *rpc.TaskProgress) { syncSend.Send(&rpc.LibraryUninstallResponse{TaskProgress: p}) },
)
return convertErrorToRPCStatus(err)
Expand All @@ -431,7 +425,7 @@ func (s *ArduinoCoreServerImpl) LibraryUninstall(req *rpc.LibraryUninstallReques
// LibraryUpgradeAll FIXMEDOC
func (s *ArduinoCoreServerImpl) LibraryUpgradeAll(req *rpc.LibraryUpgradeAllRequest, stream rpc.ArduinoCoreService_LibraryUpgradeAllServer) error {
syncSend := NewSynchronizedSend(stream.Send)
err := lib.LibraryUpgradeAll(req,
err := LibraryUpgradeAll(req,
func(p *rpc.DownloadProgress) { syncSend.Send(&rpc.LibraryUpgradeAllResponse{Progress: p}) },
func(p *rpc.TaskProgress) { syncSend.Send(&rpc.LibraryUpgradeAllResponse{TaskProgress: p}) },
)
Expand All @@ -440,19 +434,19 @@ func (s *ArduinoCoreServerImpl) LibraryUpgradeAll(req *rpc.LibraryUpgradeAllRequ

// LibraryResolveDependencies FIXMEDOC
func (s *ArduinoCoreServerImpl) LibraryResolveDependencies(ctx context.Context, req *rpc.LibraryResolveDependenciesRequest) (*rpc.LibraryResolveDependenciesResponse, error) {
resp, err := lib.LibraryResolveDependencies(ctx, req)
resp, err := LibraryResolveDependencies(ctx, req)
return resp, convertErrorToRPCStatus(err)
}

// LibrarySearch FIXMEDOC
func (s *ArduinoCoreServerImpl) LibrarySearch(ctx context.Context, req *rpc.LibrarySearchRequest) (*rpc.LibrarySearchResponse, error) {
resp, err := lib.LibrarySearch(ctx, req)
resp, err := LibrarySearch(ctx, req)
return resp, convertErrorToRPCStatus(err)
}

// LibraryList FIXMEDOC
func (s *ArduinoCoreServerImpl) LibraryList(ctx context.Context, req *rpc.LibraryListRequest) (*rpc.LibraryListResponse, error) {
resp, err := lib.LibraryList(ctx, req)
resp, err := LibraryList(ctx, req)
return resp, convertErrorToRPCStatus(err)
}

Expand All @@ -465,7 +459,7 @@ func (s *ArduinoCoreServerImpl) ArchiveSketch(ctx context.Context, req *rpc.Arch
// ZipLibraryInstall FIXMEDOC
func (s *ArduinoCoreServerImpl) ZipLibraryInstall(req *rpc.ZipLibraryInstallRequest, stream rpc.ArduinoCoreService_ZipLibraryInstallServer) error {
syncSend := NewSynchronizedSend(stream.Send)
err := lib.ZipLibraryInstall(
err := ZipLibraryInstall(
stream.Context(), req,
func(p *rpc.TaskProgress) { syncSend.Send(&rpc.ZipLibraryInstallResponse{TaskProgress: p}) },
)
Expand All @@ -475,7 +469,7 @@ func (s *ArduinoCoreServerImpl) ZipLibraryInstall(req *rpc.ZipLibraryInstallRequ
// GitLibraryInstall FIXMEDOC
func (s *ArduinoCoreServerImpl) GitLibraryInstall(req *rpc.GitLibraryInstallRequest, stream rpc.ArduinoCoreService_GitLibraryInstallServer) error {
syncSend := NewSynchronizedSend(stream.Send)
err := lib.GitLibraryInstall(
err := GitLibraryInstall(
stream.Context(), req,
func(p *rpc.TaskProgress) { syncSend.Send(&rpc.GitLibraryInstallResponse{TaskProgress: p}) },
)
Expand Down
11 changes: 5 additions & 6 deletions commands/board/listall.go → commands/service_board_listall.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,21 @@
// Arduino software without disclosing the source code of your own applications.
// To purchase a commercial license, send an email to license@arduino.cc.

package board
package commands

import (
"context"
"sort"
"strings"

"github.com/arduino/arduino-cli/commands"
"github.com/arduino/arduino-cli/commands/internal/instances"
"github.com/arduino/arduino-cli/internal/arduino/cores"
"github.com/arduino/arduino-cli/internal/arduino/utils"
rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
)

// ListAll FIXMEDOC
func ListAll(ctx context.Context, req *rpc.BoardListAllRequest) (*rpc.BoardListAllResponse, error) {
// BoardListAll FIXMEDOC
func BoardListAll(ctx context.Context, req *rpc.BoardListAllRequest) (*rpc.BoardListAllResponse, error) {
pme, release, err := instances.GetPackageManagerExplorer(req.GetInstance())
if err != nil {
return nil, err
Expand All @@ -47,8 +46,8 @@ func ListAll(ctx context.Context, req *rpc.BoardListAllRequest) (*rpc.BoardListA
}

rpcPlatform := &rpc.Platform{
Metadata: commands.PlatformToRPCPlatformMetadata(platform),
Release: commands.PlatformReleaseToRPC(installedPlatformRelease),
Metadata: PlatformToRPCPlatformMetadata(platform),
Release: PlatformReleaseToRPC(installedPlatformRelease),
}

toTest := []string{
Expand Down
15 changes: 7 additions & 8 deletions commands/board/search.go → commands/service_board_search.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,23 @@
// Arduino software without disclosing the source code of your own applications.
// To purchase a commercial license, send an email to license@arduino.cc.

package board
package commands

import (
"context"
"sort"
"strings"

"github.com/arduino/arduino-cli/commands"
"github.com/arduino/arduino-cli/commands/internal/instances"
"github.com/arduino/arduino-cli/internal/arduino/utils"
rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
)

// Search returns all boards that match the search arg.
// BoardSearch returns all boards that match the search arg.
// Boards are searched in all platforms, including those in the index that are not yet
// installed. Note that platforms that are not installed don't include boards' FQBNs.
// If no search argument is used all boards are returned.
func Search(ctx context.Context, req *rpc.BoardSearchRequest) (*rpc.BoardSearchResponse, error) {
func BoardSearch(ctx context.Context, req *rpc.BoardSearchRequest) (*rpc.BoardSearchResponse, error) {
pme, release, err := instances.GetPackageManagerExplorer(req.GetInstance())
if err != nil {
return nil, err
Expand Down Expand Up @@ -68,8 +67,8 @@ func Search(ctx context.Context, req *rpc.BoardSearchRequest) (*rpc.BoardSearchR
Fqbn: board.FQBN(),
IsHidden: board.IsHidden(),
Platform: &rpc.Platform{
Metadata: commands.PlatformToRPCPlatformMetadata(platform),
Release: commands.PlatformReleaseToRPC(installedPlatformRelease),
Metadata: PlatformToRPCPlatformMetadata(platform),
Release: PlatformReleaseToRPC(installedPlatformRelease),
},
})
}
Expand All @@ -83,8 +82,8 @@ func Search(ctx context.Context, req *rpc.BoardSearchRequest) (*rpc.BoardSearchR
foundBoards = append(foundBoards, &rpc.BoardListItem{
Name: strings.Trim(board.Name, " \n"),
Platform: &rpc.Platform{
Metadata: commands.PlatformToRPCPlatformMetadata(platform),
Release: commands.PlatformReleaseToRPC(latestPlatformRelease),
Metadata: PlatformToRPCPlatformMetadata(platform),
Release: PlatformReleaseToRPC(latestPlatformRelease),
},
})
}
Expand Down
2 changes: 1 addition & 1 deletion commands/daemon/debug.go → commands/service_debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// Arduino software without disclosing the source code of your own applications.
// To purchase a commercial license, send an email to license@arduino.cc.

package daemon
package commands

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,20 @@
// Arduino software without disclosing the source code of your own applications.
// To purchase a commercial license, send an email to license@arduino.cc.

package lib
package commands

import (
"context"

"github.com/arduino/arduino-cli/commands"
"github.com/arduino/arduino-cli/commands/cmderrors"
"github.com/arduino/arduino-cli/commands/internal/instances"
"github.com/arduino/arduino-cli/internal/arduino/httpclient"
"github.com/arduino/arduino-cli/internal/arduino/libraries/librariesindex"
"github.com/arduino/arduino-cli/internal/i18n"
rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
"github.com/arduino/go-paths-helper"
"github.com/sirupsen/logrus"
)

var tr = i18n.Tr

// LibraryDownload executes the download of the library.
// A DownloadProgressCB callback function must be passed to monitor download progress.
func LibraryDownload(ctx context.Context, req *rpc.LibraryDownloadRequest, downloadCB rpc.DownloadProgressCB) (*rpc.LibraryDownloadResponse, error) {
Expand All @@ -51,7 +47,7 @@ func LibraryDownload(ctx context.Context, req *rpc.LibraryDownloadRequest, downl

logrus.Info("Preparing download")

version, err := commands.ParseVersion(req.GetVersion())
version, err := ParseVersion(req.GetVersion())
if err != nil {
return nil, err
}
Expand Down
Loading
0