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

[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
8000

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
Prev Previous commit
Next Next commit
Inlining methods in ArduinoCoreServiceImpl (part 5: Create and Destroy)
  • Loading branch information
cmaglie committed May 6, 2024
commit 06d6842ab2a5f6e03b2b783b4e4c308448a2decf
19 changes: 14 additions & 5 deletions commands/instances.go
< 8000 /tr>
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import (
paths "github.com/arduino/go-paths-helper"
"github.com/sirupsen/logrus"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/metadata"
"google.golang.org/grpc/status"
)

Expand All @@ -59,8 +60,16 @@ func installTool(pm *packagemanager.PackageManager, tool *cores.ToolRelease, dow
return nil
}

// Create a new CoreInstance ready to be initialized, supporting directories are also created.
func Create(req *rpc.CreateRequest, extraUserAgent ...string) (*rpc.CreateResponse, error) {
// Create a new Instance ready to be initialized, supporting directories are also created.
func (s *arduinoCoreServerImpl) Create(ctx context.Context, req *rpc.CreateRequest) (*rpc.CreateResponse, error) {
var userAgent []string
if md, ok := metadata.FromIncomingContext(ctx); ok {
userAgent = md.Get("user-agent")
}
if len(userAgent) == 0 {
userAgent = []string{"gRPCClientUnknown/0.0.0"}
}

// Setup downloads directory
downloadsDir := configuration.DownloadsDir(configuration.Settings)
if downloadsDir.NotExist() {
Expand All @@ -80,7 +89,7 @@ func Create(req *rpc.CreateRequest, extraUserAgent ...string) (*rpc.CreateRespon
}
}

inst, err := instances.Create(dataDir, packagesDir, downloadsDir, extraUserAgent...)
inst, err := instances.Create(dataDir, packagesDir, downloadsDir, userAgent...)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -397,8 +406,8 @@ func Init(req *rpc.InitRequest, responseCallback func(r *rpc.InitResponse)) erro
return nil
}

// Destroy FIXMEDOC
func Destroy(ctx context.Context, req *rpc.DestroyRequest) (*rpc.DestroyResponse, error) {
// Destroy deletes an instance.
func (s *arduinoCoreServerImpl) Destroy(ctx context.Context, req *rpc.DestroyRequest) (*rpc.DestroyResponse, error) {
if ok := instances.Delete(req.GetInstance()); !ok {
return nil, &cmderrors.InvalidInstanceError{}
}
Expand Down
18 changes: 0 additions & 18 deletions commands/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"github.com/arduino/arduino-cli/commands/updatecheck"
rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
"github.com/sirupsen/logrus"
"google.golang.org/grpc/metadata"
)

// NewArduinoCoreServer returns an implementation of the ArduinoCoreService gRPC service
Expand All @@ -43,11 +42,6 @@ type arduinoCoreServerImpl struct {
versionString string
}

// Destroy FIXMEDOC
func (s *arduinoCoreServerImpl) Destroy(ctx context.Context, req *rpc.DestroyRequest) (*rpc.DestroyResponse, error) {
return Destroy(ctx, req)
}

// UpdateIndex FIXMEDOC
func (s *arduinoCoreServerImpl) UpdateIndex(req *rpc.UpdateIndexRequest, stream rpc.ArduinoCoreService_UpdateIndexServer) error {
syncSend := NewSynchronizedSend(stream.Send)
Expand Down Expand Up @@ -84,18 +78,6 @@ func (s *arduinoCoreServerImpl) UpdateLibrariesIndex(req *rpc.UpdateLibrariesInd
return err
}

// Create FIXMEDOC
func (s *arduinoCoreServerImpl) Create(ctx context.Context, req *rpc.CreateRequest) (*rpc.CreateResponse, error) {
var userAgent []string
if md, ok := metadata.FromIncomingContext(ctx); ok {
userAgent = md.Get("user-agent")
}
if len(userAgent) == 0 {
userAgent = []string{"gRPCClientUnknown/0.0.0"}
}
return Create(req, userAgent...)
}

// Init FIXMEDOC
func (s *arduinoCoreServerImpl) Init(req *rpc.InitRequest, stream rpc.ArduinoCoreService_InitServer) error {
syncSend := NewSynchronizedSend(stream.Send)
Expand Down
10 changes: 8 additions & 2 deletions commands/service_platform_search_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package commands

import (
"context"
"testing"

"github.com/arduino/arduino-cli/internal/cli/configuration"
Expand All @@ -37,7 +38,9 @@ func TestPlatformSearch(t *testing.T) {

configuration.Settings = configuration.Init(paths.TempDir().Join("test", "arduino-cli.yaml").String())

createResp, err := Create(&rpc.CreateRequest{})
srv := NewArduinoCoreServer("")
ctx := context.Background()
createResp, err := srv.Create(ctx, &rpc.CreateRequest{})
require.NoError(t, err)

inst := createResp.GetInstance()
Expand Down Expand Up @@ -337,7 +340,10 @@ func TestPlatformSearchSorting(t *testing.T) {

configuration.Settings = configuration.Init(paths.TempDir().Join("test", "arduino-cli.yaml").String())

createResp, err := Create(&rpc.CreateRequest{})
srv := NewArduinoCoreServer("")
ctx := context.Background()

createResp, err := srv.Create(ctx, &rpc.CreateRequest{})
require.NoError(t, err)
inst := createResp.GetInstance()
require.NotNil(t, inst)
Expand Down
38 changes: 19 additions & 19 deletions internal/cli/arguments/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ import (
// GetInstalledBoards is an helper function useful to autocomplete.
// It returns a list of fqbn
// it's taken from cli/board/listall.go
func GetInstalledBoards(srv rpc.ArduinoCoreServiceServer) []string {
inst := instance.CreateAndInit()
func GetInstalledBoards(srv rpc.ArduinoCoreServiceServer, ctx context.Context) []string {
inst := instance.CreateAndInit(srv, ctx)

list, _ := srv.BoardListAll(context.Background(), &rpc.BoardListAllRequest{
Instance: inst,
Expand All @@ -45,8 +45,8 @@ func GetInstalledBoards(srv rpc.ArduinoCoreServiceServer) []string {

// GetInstalledProgrammers is an helper function useful to autocomplete.
// It returns a list of programmers available based on the installed boards
func GetInstalledProgrammers(srv rpc.ArduinoCoreServiceServer) []string {
inst := instance.CreateAndInit()
func GetInstalledProgrammers(srv rpc.ArduinoCoreServiceServer, ctx context.Context) []string {
inst := instance.CreateAndInit(srv, ctx)

// we need the list of the available fqbn in order to get the list of the programmers
listAllReq := &rpc.BoardListAllRequest{
Expand Down Expand Up @@ -78,8 +78,8 @@ func GetInstalledProgrammers(srv rpc.ArduinoCoreServiceServer) []string {

// GetUninstallableCores is an helper function useful to autocomplete.
// It returns a list of cores which can be uninstalled
func GetUninstallableCores() []string {
inst := instance.CreateAndInit()
func GetUninstallableCores(srv rpc.ArduinoCoreServiceServer, ctx context.Context) []string {
inst := instance.CreateAndInit(srv, ctx)

platforms, _ := commands.PlatformSearch(&rpc.PlatformSearchRequest{
Instance: inst,
Expand All @@ -99,8 +99,8 @@ func GetUninstallableCores() []string {

// GetInstallableCores is an helper function useful to autocomplete.
// It returns a list of cores which can be installed/downloaded
func GetInstallableCores() []string {
inst := instance.CreateAndInit()
func GetInstallableCores(srv rpc.ArduinoCoreServiceServer, ctx context.Context) []string {
inst := instance.CreateAndInit(srv, ctx)

platforms, _ := commands.PlatformSearch(&rpc.PlatformSearchRequest{
Instance: inst,
Expand All @@ -118,18 +118,18 @@ func GetInstallableCores() []string {

// GetInstalledLibraries is an helper function useful to autocomplete.
// It returns a list of libs which are currently installed, including the builtin ones
func GetInstalledLibraries() []string {
return getLibraries(true)
func GetInstalledLibraries(srv rpc.ArduinoCoreServiceServer, ctx context.Context) []string {
return getLibraries(srv, ctx, true)
}

// GetUninstallableLibraries is an helper function useful to autocomplete.
// It returns a list of libs which can be uninstalled
func GetUninstallableLibraries() []string {
return getLibraries(false)
func GetUninstallableLibraries(srv rpc.ArduinoCoreServiceServer, ctx context.Context) []string {
return getLibraries(srv, ctx, false)
}

func getLibraries(all bool) []string {
inst := instance.CreateAndInit()
func getLibraries(srv rpc.ArduinoCoreServiceServer, ctx context.Context, all bool) []string {
inst := instance.CreateAndInit(srv, ctx)
libs, _ := commands.LibraryList(context.Background(), &rpc.LibraryListRequest{
Instance: inst,
All: all,
Expand All @@ -147,8 +147,8 @@ func getLibraries(all bool) []string {

// GetInstallableLibs is an helper function useful to autocomplete.
// It returns a list of libs which can be installed/downloaded
func GetInstallableLibs() []string {
inst := instance.CreateAndInit()
func GetInstallableLibs(srv rpc.ArduinoCoreServiceServer, ctx context.Context) []string {
inst := instance.CreateAndInit(srv, ctx)

libs, _ := commands.LibrarySearch(context.Background(), &rpc.LibrarySearchRequest{
Instance: inst,
Expand All @@ -165,10 +165,10 @@ func GetInstallableLibs() []string {
// GetAvailablePorts is an helper function useful to autocomplete.
// It returns a list of upload port of the boards which are currently connected.
// It will not suggests network ports because the timeout is not set.
func GetAvailablePorts(srv rpc.ArduinoCoreServiceServer) []*rpc.Port {
func GetAvailablePorts(srv rpc.ArduinoCoreServiceServer, ctx context.Context) []*rpc.Port {
// Get the port list
inst := instance.CreateAndInit()
list, _ := srv.BoardList(context.Background(), &rpc.BoardListRequest{Instance: inst})
inst := instance.CreateAndInit(srv, ctx)
list, _ := srv.BoardList(ctx, &rpc.BoardListRequest{Instance: inst})

// Transform the data structure for the completion (DetectedPort -> Port)
return f.Map(list.GetPorts(), (*rpc.DetectedPort).GetPort)
Expand Down
3 changes: 2 additions & 1 deletion internal/cli/arguments/fqbn.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package arguments

import (
"context"
"strings"

"github.com/arduino/arduino-cli/commands/cmderrors"
Expand All @@ -36,7 +37,7 @@ type Fqbn struct {
func (f *Fqbn) AddToCommand(cmd *cobra.Command, srv rpc.ArduinoCoreServiceServer) {
cmd.Flags().StringVarP(&f.fqbn, "fqbn", "b", "", tr("Fully Qualified Board Name, e.g.: arduino:avr:uno"))
cmd.RegisterFlagCompletionFunc("fqbn", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
return GetInstalledBoards(srv), cobra.ShellCompDirectiveDefault
return GetInstalledBoards(srv, context.Background()), cobra.ShellCompDirectiveDefault
})
cmd.Flags().StringSliceVar(&f.boardOptions, "board-options", []string{},
tr("List of board options separated by commas. Or can be used multiple times for multiple options."))
Expand Down
4 changes: 2 additions & 2 deletions internal/cli/arguments/port.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ type Port struct {
func (p *Port) AddToCommand(cmd *cobra.Command, srv rpc.ArduinoCoreServiceServer) {
cmd.Flags().StringVarP(&p.address, "port", "p", "", tr("Upload port address, e.g.: COM3 or /dev/ttyACM2"))
cmd.RegisterFlagCompletionFunc("port", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
return f.Map(GetAvailablePorts(srv), (*rpc.Port).GetAddress), cobra.ShellCompDirectiveDefault
return f.Map(GetAvailablePorts(srv, context.Background()), (*rpc.Port).GetAddress), cobra.ShellCompDirectiveDefault
})
cmd.Flags().StringVarP(&p.protocol, "protocol", "l", "", tr("Upload port protocol, e.g: serial"))
cmd.RegisterFlagCompletionFunc("protocol", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
return f.Map(GetAvailablePorts(srv), (*rpc.Port).GetProtocol), cobra.ShellCompDirectiveDefault
return f.Map(GetAvailablePorts(srv, context.Background()), (*rpc.Port).GetProtocol), cobra.ShellCompDirectiveDefault
})
p.timeout.AddToCommand(cmd)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/cli/arguments/programmer.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type Programmer struct {
func (p *Programmer) AddToCommand(cmd *cobra.Command, srv rpc.ArduinoCoreServiceServer) {
cmd.Flags().StringVarP(&p.programmer, "programmer", "P", "", tr("Programmer to use, e.g: atmel_ice"))
cmd.RegisterFlagCompletionFunc("programmer", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
return GetInstalledProgrammers(srv), cobra.ShellCompDirectiveDefault
return GetInstalledProgrammers(srv, context.Background()), cobra.ShellCompDirectiveDefault
})
}

Expand Down
10 changes: 6 additions & 4 deletions internal/cli/arguments/reference.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package arguments

import (
"context"
"fmt"
"strings"

Expand Down Expand Up @@ -43,10 +44,11 @@ func (r *Reference) String() string {

// ParseReferences is a convenient wrapper that operates on a slice of strings and
// calls ParseReference for each of them. It returns at the first invalid argument.
func ParseReferences(args []string) ([]*Reference, error) {
func ParseReferences(srv rpc.ArduinoCoreServiceServer, ctx context.Context, args []string) ([]*Reference, error) {
ret := []*Reference{}
for _, arg := range args {
reference, err := ParseReference(arg)
// TODO: This is quite resource consuming (since it creates a new instance for each call)
reference, err := ParseReference(srv, ctx, arg)
if err != nil {
return nil, err
}
Expand All @@ -60,7 +62,7 @@ func ParseReferences(args []string) ([]*Reference, error) {
// To achieve that, it tries to use github.com/arduino/arduino-cli/commands/core.GetPlatform
// Note that the Reference is returned rightaway if the arg inserted by the user matches perfectly one in the response of core.GetPlatform
// A MultiplePlatformsError is returned if the platform searched by the user matches multiple platforms
func ParseReference(arg string) (*Reference, error) {
func ParseReference(srv rpc.ArduinoCoreServiceServer, ctx context.Context, arg string) (*Reference, error) {
logrus.Infof("Parsing reference %s", arg)
ret := &Reference{}
if arg == "" {
Expand Down Expand Up @@ -96,7 +98,7 @@ func ParseReference(arg string) (*Reference, error) {
// 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, _ := commands.PlatformSearch(&rpc.PlatformSearchRequest{
Instance: instance.CreateAndInit(),
Instance: instance.CreateAndInit(srv, ctx),
})
foundPlatforms := []string{}
for _, platform := range platforms.GetSearchOutput() {
Expand Down
11 changes: 8 additions & 3 deletions internal/cli/arguments/reference_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
package arguments_test

import (
"context"
"testing"

"github.com/arduino/arduino-cli/commands"
"github.com/arduino/arduino-cli/internal/cli/arguments"
"github.com/arduino/arduino-cli/internal/cli/configuration"
"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -57,14 +59,16 @@ func TestArgsStringify(t *testing.T) {
}

func TestParseReferenceCores(t *testing.T) {
srv := commands.NewArduinoCoreServer("")
ctx := context.Background()
for _, tt := range goodCores {
actual, err := arguments.ParseReference(tt.in)
actual, err := arguments.ParseReference(srv, ctx, tt.in)
assert.Nil(t, err)
assert.Equal(t, tt.expected, actual)
}

for _, tt := range badCores {
actual, err := arguments.ParseReference(tt.in)
actual, err := arguments.ParseReference(srv, ctx, tt.in)
require.NotNil(t, err, "Testing bad core '%s'", tt.in)
require.Equal(t, tt.expected, actual, "Testing bad core '%s'", tt.in)
}
Expand All @@ -76,7 +80,8 @@ func TestParseArgs(t *testing.T) {
input = append(input, tt.in)
}

refs, err := arguments.ParseReferences(input)
srv := commands.NewArduinoCoreServer("")
refs, err := arguments.ParseReferences(srv, context.Background(), input)
assert.Nil(t, err)
assert.Equal(t, len(goodCores), len(refs))

Expand Down
3 changes: 2 additions & 1 deletion internal/cli/board/details.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ func initDetailsCommand(srv rpc.ArduinoCoreServiceServer) *cobra.Command {
}

func runDetailsCommand(srv rpc.ArduinoCoreServiceServer, fqbn string, showFullDetails, listProgrammers bool, showProperties arguments.ShowProperties) {
inst := instance.CreateAndInit()
ctx := context.Background()
inst := instance.CreateAndInit(srv, ctx)

logrus.Info("Executing `arduino-cli board details`")

Expand Down
3 changes: 2 additions & 1 deletion internal/cli/board/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ func initListCommand(srv rpc.ArduinoCoreServiceServer) *cobra.Command {

// runListCommand detects and lists the connected arduino boards
func runListCommand(srv rpc.ArduinoCoreServiceServer, watch bool, timeout int64, fqbn string) {
inst := instance.CreateAndInit()
ctx := context.Background()
inst := instance.CreateAndInit(srv, ctx)

logrus.Info("Executing `arduino-cli board list`")

Expand Down
3 changes: 2 additions & 1 deletion internal/cli/board/listall.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ for a specific board if you specify the board name`),

// runListAllCommand list all installed boards
func runListAllCommand(args []string, srv rpc.ArduinoCoreServiceServer) {
inst := instance.CreateAndInit()
ctx := context.Background()
inst := instance.CreateAndInit(srv, ctx)

logrus.Info("Executing `arduino-cli board listall`")

Expand Down
3 changes: 2 additions & 1 deletion internal/cli/board/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ func initSearchCommand(srv rpc.ArduinoCoreServiceServer) *cobra.Command {
}

func runSearchCommand(srv rpc.ArduinoCoreServiceServer, args []string) {
inst := instance.CreateAndInit()
ctx := context.Background()
inst := instance.CreateAndInit(srv, ctx)

logrus.Info("Executing `arduino-cli board search`")

Expand Down
3 changes: 2 additions & 1 deletion internal/cli/burnbootloader/burnbootloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ func NewCommand(srv rpc.ArduinoCoreServiceServer) *cobra.Command {
}

func runBootloaderCommand(srv rpc.ArduinoCoreServiceServer) {
instance := instance.CreateAndInit()
ctx := context.Background()
instance := instance.CreateAndInit(srv, ctx)

logrus.Info("Executing `arduino-cli burn-bootloader`")

Expand Down
Loading
0