Skip to content
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

refactor: Made command functions to access PackageManager unavailable from public API #2335

Merged
merged 7 commits into from
Oct 19, 2023
4 changes: 2 additions & 2 deletions commands/board/details.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ import (
"github.com/arduino/arduino-cli/arduino"
"github.com/arduino/arduino-cli/arduino/cores"
"github.com/arduino/arduino-cli/arduino/utils"
"github.com/arduino/arduino-cli/commands"
"github.com/arduino/arduino-cli/commands/internal/instances"
rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
)

// Details returns all details for a board including tools and HW identifiers.
// This command basically gather al the information and translates it into the required grpc struct properties
func Details(ctx context.Context, req *rpc.BoardDetailsRequest) (*rpc.BoardDetailsResponse, error) {
pme, release := commands.GetPackageManagerExplorer(req)
pme, release := instances.GetPackageManagerExplorer(req.GetInstance())
if pme == nil {
return nil, &arduino.InvalidInstanceError{}
}
Expand Down
6 changes: 3 additions & 3 deletions commands/board/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
"github.com/arduino/arduino-cli/arduino/cores/packagemanager"
"github.com/arduino/arduino-cli/arduino/discovery"
"github.com/arduino/arduino-cli/arduino/httpclient"
"github.com/arduino/arduino-cli/commands"
"github.com/arduino/arduino-cli/commands/internal/instances"
"github.com/arduino/arduino-cli/internal/inventory"
rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
"github.com/arduino/go-properties-orderedmap"
Expand Down Expand Up @@ -203,7 +203,7 @@ func identify(pme *packagemanager.Explorer, port *discovery.Port) ([]*rpc.BoardL
// In case of errors partial results from discoveries that didn't fail
// are returned.
func List(req *rpc.BoardListRequest) (r []*rpc.DetectedPort, discoveryStartErrors []error, e error) {
pme, release := commands.GetPackageManagerExplorer(req)
pme, release := instances.GetPackageManagerExplorer(req.GetInstance())
if pme == nil {
return nil, nil, &arduino.InvalidInstanceError{}
}
Expand Down Expand Up @@ -258,7 +258,7 @@ func hasMatchingBoard(b *rpc.DetectedPort, fqbnFilter *cores.FQBN) bool {

// Watch returns a channel that receives boards connection and disconnection events.
func Watch(ctx context.Context, req *rpc.BoardListWatchRequest) (<-chan *rpc.BoardListWatchResponse, error) {
pme, release := commands.GetPackageManagerExplorer(req)
pme, release := instances.GetPackageManagerExplorer(req.GetInstance())
if pme == nil {
return nil, &arduino.InvalidInstanceError{}
}
Expand Down
4 changes: 2 additions & 2 deletions commands/board/listall.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ import (
"github.com/arduino/arduino-cli/arduino"
"github.com/arduino/arduino-cli/arduino/cores"
"github.com/arduino/arduino-cli/arduino/utils"
"github.com/arduino/arduino-cli/commands"
"github.com/arduino/arduino-cli/commands/internal/instances"
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) {
pme, release := commands.GetPackageManagerExplorer(req)
pme, release := instances.GetPackageManagerExplorer(req.GetInstance())
if pme == nil {
return nil, &arduino.InvalidInstanceError{}
}
Expand Down
4 changes: 2 additions & 2 deletions commands/board/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (

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

Expand All @@ -31,7 +31,7 @@ import (
// 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) {
pme, release := commands.GetPackageManagerExplorer(req)
pme, release := instances.GetPackageManagerExplorer(req.GetInstance())
if pme == nil {
return nil, &arduino.InvalidInstanceError{}
}
Expand Down
6 changes: 3 additions & 3 deletions commands/compile/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
"github.com/arduino/arduino-cli/arduino/sketch"
"github.com/arduino/arduino-cli/arduino/utils"
"github.com/arduino/arduino-cli/buildcache"
"github.com/arduino/arduino-cli/commands"
"github.com/arduino/arduino-cli/commands/internal/instances"
"github.com/arduino/arduino-cli/configuration"
"github.com/arduino/arduino-cli/i18n"
"github.com/arduino/arduino-cli/internal/inventory"
Expand All @@ -57,13 +57,13 @@ func Compile(ctx context.Context, req *rpc.CompileRequest, outStream, errStream
exportBinaries = reqExportBinaries.Value
}

pme, release := commands.GetPackageManagerExplorer(req)
pme, release := instances.GetPackageManagerExplorer(req.GetInstance())
if pme == nil {
return nil, &arduino.InvalidInstanceError{}
}
defer release()

lm := commands.GetLibraryManager(req)
lm := instances.GetLibraryManager(req.GetInstance())
if lm == nil {
return nil, &arduino.InvalidInstanceError{}
}
Expand Down
3 changes: 2 additions & 1 deletion commands/core/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"github.com/arduino/arduino-cli/arduino"
"github.com/arduino/arduino-cli/arduino/cores/packagemanager"
"github.com/arduino/arduino-cli/commands"
"github.com/arduino/arduino-cli/commands/internal/instances"
"github.com/arduino/arduino-cli/i18n"
rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
)
Expand All @@ -29,7 +30,7 @@ var tr = i18n.Tr

// PlatformDownload FIXMEDOC
func PlatformDownload(ctx context.Context, req *rpc.PlatformDownloadRequest, downloadCB rpc.DownloadProgressCB) (*rpc.PlatformDownloadResponse, error) {
pme, release := commands.GetPackageManagerExplorer(req)
pme, release := instances.GetPackageManagerExplorer(req.GetInstance())
if pme == nil {
return nil, &arduino.InvalidInstanceError{}
}
Expand Down
3 changes: 2 additions & 1 deletion commands/core/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ import (
"github.com/arduino/arduino-cli/arduino"
"github.com/arduino/arduino-cli/arduino/cores/packagemanager"
"github.com/arduino/arduino-cli/commands"
"github.com/arduino/arduino-cli/commands/internal/instances"
rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
)

// PlatformInstall FIXMEDOC
func PlatformInstall(ctx context.Context, req *rpc.PlatformInstallRequest, downloadCB rpc.DownloadProgressCB, taskCB rpc.TaskProgressCB) (*rpc.PlatformInstallResponse, error) {
install := func() error {
pme, release := commands.GetPackageManagerExplorer(req)
pme, release := instances.GetPackageManagerExplorer(req.GetInstance())
if pme == nil {
return &arduino.InvalidInstanceError{}
}
Expand Down
3 changes: 2 additions & 1 deletion commands/core/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ import (

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

// PlatformList returns a list of installed platforms, optionally filtered by
// those requiring an update.
func PlatformList(req *rpc.PlatformListRequest) (*rpc.PlatformListResponse, error) {
pme, release := commands.GetPackageManagerExplorer(req)
pme, release := instances.GetPackageManagerExplorer(req.GetInstance())
if pme == nil {
return nil, &arduino.InvalidInstanceError{}
}
Expand Down
3 changes: 2 additions & 1 deletion commands/core/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@ import (
"github.com/arduino/arduino-cli/arduino/cores"
"github.com/arduino/arduino-cli/arduino/utils"
"github.com/arduino/arduino-cli/commands"
"github.com/arduino/arduino-cli/commands/internal/instances"
rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
)

// PlatformSearch FIXMEDOC
func PlatformSearch(req *rpc.PlatformSearchRequest) (*rpc.PlatformSearchResponse, error) {
pme, release := commands.GetPackageManagerExplorer(req)
pme, release := instances.GetPackageManagerExplorer(req.GetInstance())
if pme == nil {
return nil, &arduino.InvalidInstanceError{}
}
Expand Down
3 changes: 2 additions & 1 deletion commands/core/uninstall.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"github.com/arduino/arduino-cli/arduino"
"github.com/arduino/arduino-cli/arduino/cores/packagemanager"
"github.com/arduino/arduino-cli/commands"
"github.com/arduino/arduino-cli/commands/internal/instances"
rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
)

Expand All @@ -37,7 +38,7 @@ func PlatformUninstall(ctx context.Context, req *rpc.PlatformUninstallRequest, t

// platformUninstall is the implementation of platform unistaller
func platformUninstall(ctx context.Context, req *rpc.PlatformUninstallRequest, taskCB rpc.TaskProgressCB) error {
pme, release := commands.GetPackageManagerExplorer(req)
pme, release := instances.GetPackageManagerExplorer(req.GetInstance())
if pme == nil {
return &arduino.InvalidInstanceError{}
}
Expand Down
6 changes: 3 additions & 3 deletions commands/core/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ package core
import (
"context"

"github.com/arduino/arduino-cli/arduino/cores"

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

// PlatformUpgrade FIXMEDOC
func PlatformUpgrade(ctx context.Context, req *rpc.PlatformUpgradeRequest, downloadCB rpc.DownloadProgressCB, taskCB rpc.TaskProgressCB) (*rpc.PlatformUpgradeResponse, error) {
upgrade := func() (*cores.PlatformRelease, error) {
pme, release := commands.GetPackageManagerExplorer(req)
pme, release := instances.GetPackageManagerExplorer(req.GetInstance())
if pme == nil {
return nil, &arduino.InvalidInstanceError{}
}
Expand Down
4 changes: 2 additions & 2 deletions commands/debug/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (

"github.com/arduino/arduino-cli/arduino"
"github.com/arduino/arduino-cli/arduino/cores/packagemanager"
"github.com/arduino/arduino-cli/commands"
"github.com/arduino/arduino-cli/commands/internal/instances"
"github.com/arduino/arduino-cli/executils"
"github.com/arduino/arduino-cli/i18n"
rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
Expand All @@ -45,7 +45,7 @@ var tr = i18n.Tr
func Debug(ctx context.Context, req *rpc.GetDebugConfigRequest, inStream io.Reader, out io.Writer, interrupt <-chan os.Signal) (*rpc.DebugResponse, error) {

// Get debugging command line to run debugger
pme, release := commands.GetPackageManagerExplorer(req)
pme, release := instances.GetPackageManagerExplorer(req.GetInstance())
if pme == nil {
return nil, &arduino.InvalidInstanceError{}
}
Expand Down
4 changes: 2 additions & 2 deletions commands/debug/debug_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"github.com/arduino/arduino-cli/arduino/cores"
"github.com/arduino/arduino-cli/arduino/cores/packagemanager"
"github.com/arduino/arduino-cli/arduino/sketch"
"github.com/arduino/arduino-cli/commands"
"github.com/arduino/arduino-cli/commands/internal/instances"
rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
"github.com/arduino/go-paths-helper"
"github.com/arduino/go-properties-orderedmap"
Expand All @@ -35,7 +35,7 @@ import (

// GetDebugConfig returns metadata to start debugging with the specified board
func GetDebugConfig(ctx context.Context, req *rpc.GetDebugConfigRequest) (*rpc.GetDebugConfigResponse, error) {
pme, release := commands.GetPackageManagerExplorer(req)
pme, release := instances.GetPackageManagerExplorer(req.GetInstance())
if pme == nil {
return nil, &arduino.InvalidInstanceError{}
}
Expand Down
Loading
Loading