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

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
Follow convetion where context must be the first argument
  • Loading branch information
cmaglie committed May 6, 2024
commit 8bd0eef02ed248d92d9c803984b47d9a646e21f8
36 changes: 18 additions & 18 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, ctx context.Context) []string {
inst := instance.CreateAndInit(srv, ctx)
func GetInstalledBoards(ctx context.Context, srv rpc.ArduinoCoreServiceServer) []string {
inst := instance.CreateAndInit(ctx, srv)

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

// 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, ctx context.Context) []string {
inst := instance.CreateAndInit(srv, ctx)
func GetInstalledProgrammers(ctx context.Context, srv rpc.ArduinoCoreServiceServer) []string {
inst := instance.CreateAndInit(ctx, srv)

// 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, ctx context.Conte

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

platforms, _ := commands.PlatformSearch(&rpc.PlatformSearchRequest{
Instance: inst,
Expand All @@ -99,8 +99,8 @@ func GetUninstallableCores(srv rpc.ArduinoCoreServiceServer, ctx context.Context

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

platforms, _ := commands.PlatformSearch(&rpc.PlatformSearchRequest{
Instance: inst,
Expand All @@ -118,18 +118,18 @@ func GetInstallableCores(srv rpc.ArduinoCoreServiceServer, ctx context.Context)

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

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

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

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

libs, _ := commands.LibrarySearch(context.Background(), &rpc.LibrarySearchRequest{
Instance: inst,
Expand All @@ -165,9 +165,9 @@ func GetInstallableLibs(srv rpc.ArduinoCoreServiceServer, ctx context.Context) [
// 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, ctx context.Context) []*rpc.Port {
func GetAvailablePorts(ctx context.Context, srv rpc.ArduinoCoreServiceServer) []*rpc.Port {
// Get the port list
inst := instance.CreateAndInit(srv, ctx)
inst := instance.CreateAndInit(ctx, srv)
list, _ := srv.BoardList(ctx, &rpc.BoardListRequest{Instance: inst})

// Transform the data structure for the completion (DetectedPort -> Port)
Expand Down
2 changes: 1 addition & 1 deletion internal/cli/arguments/fqbn.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,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, context.Background()), cobra.ShellCompDirectiveDefault
return GetInstalledBoards(context.Background(), srv), 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, context.Background()), (*rpc.Port).GetAddress), cobra.ShellCompDirectiveDefault
return f.Map(GetAvailablePorts(context.Background(), srv), (*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, context.Background()), (*rpc.Port).GetProtocol), cobra.ShellCompDirectiveDefault
return f.Map(GetAvailablePorts(context.Background(), srv), (*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, context.Background()), cobra.ShellCompDirectiveDefault
return GetInstalledProgrammers(context.Background(), srv), cobra.ShellCompDirectiveDefault
})
}

Expand Down
8 changes: 4 additions & 4 deletions internal/cli/arguments/reference.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +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(srv rpc.ArduinoCoreServiceServer, ctx context.Context, args []string) ([]*Reference, error) {
func ParseReferences(ctx context.Context, srv rpc.ArduinoCoreServiceServer, args []string) ([]*Reference, error) {
ret := []*Reference{}
for _, arg := range args {
// TODO: This is quite resource consuming (since it creates a new instance for each call)
reference, err := ParseReference(srv, ctx, arg)
reference, err := ParseReference(ctx, srv, arg)
if err != nil {
return nil, err
}
Expand All @@ -62,7 +62,7 @@ func ParseReferences(srv rpc.ArduinoCoreServiceServer, ctx context.Context, args
// 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(srv rpc.ArduinoCoreServiceServer, ctx context.Context, arg string) (*Reference, error) {
func ParseReference(ctx context.Context, srv rpc.ArduinoCoreServiceServer, arg string) (*Reference, error) {
logrus.Infof("Parsing reference %s", arg)
ret := &Reference{}
if arg == "" {
Expand Down Expand Up @@ -98,7 +98,7 @@ func ParseReference(srv rpc.ArduinoCoreServiceServer, ctx context.Context, arg s
// 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(srv, ctx),
Instance: instance.CreateAndInit(ctx, srv),
})
foundPlatforms := []string{}
for _, platform := range platforms.GetSearchOutput() {
Expand Down
6 changes: 3 additions & 3 deletions internal/cli/arguments/reference_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ func TestParseReferenceCores(t *testing.T) {
srv := commands.NewArduinoCoreServer("")
ctx := context.Background()
for _, tt := range goodCores {
actual, err := arguments.ParseReference(srv, ctx, tt.in)
actual, err := arguments.ParseReference(ctx, srv, tt.in)
assert.Nil(t, err)
assert.Equal(t, tt.expected, actual)
}

for _, tt := range badCores {
actual, err := arguments.ParseReference(srv, ctx, tt.in)
actual, err := arguments.ParseReference(ctx, srv, 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 @@ -81,7 +81,7 @@ func TestParseArgs(t *testing.T) {
}

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

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

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

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

Expand Down
2 changes: 1 addition & 1 deletion internal/cli/board/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ 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) {
ctx := context.Background()
inst := instance.CreateAndInit(srv, ctx)
inst := instance.CreateAndInit(ctx, srv)

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

Expand Down
2 changes: 1 addition & 1 deletion internal/cli/board/listall.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ for a specific board if you specify the board name`),
// runListAllCommand list all installed boards
func runListAllCommand(args []string, srv rpc.ArduinoCoreServiceServer) {
ctx := context.Background()
inst := instance.CreateAndInit(srv, ctx)
inst := instance.CreateAndInit(ctx, srv)

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

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

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

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

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

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

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

Expand Down
4 changes: 2 additions & 2 deletions internal/cli/compile/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,9 @@ func runCompileCommand(cmd *cobra.Command, args []string, srv rpc.ArduinoCoreSer
var profile *rpc.SketchProfile

if profileArg.Get() == "" {
inst, profile = instance.CreateAndInitWithProfile(srv, ctx, sk.GetDefaultProfile().GetName(), sketchPath)
inst, profile = instance.CreateAndInitWithProfile(ctx, srv, sk.GetDefaultProfile().GetName(), sketchPath)
} else {
inst, profile = instance.CreateAndInitWithProfile(srv, ctx, profileArg.Get(), sketchPath)
inst, profile = instance.CreateAndInitWithProfile(ctx, srv, profileArg.Get(), sketchPath)
}

if fqbnArg.String() == "" {
Expand Down
6 changes: 3 additions & 3 deletions internal/cli/core/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,19 @@ func initDownloadCommand(srv rpc.ArduinoCoreServiceServer) *cobra.Command {
runDownloadCommand(srv, args)
},
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
return arguments.GetInstallableCores(srv, context.Background()), cobra.ShellCompDirectiveDefault
return arguments.GetInstallableCores(context.Background(), srv), cobra.ShellCompDirectiveDefault
},
}
return downloadCommand
}

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

logrus.Info("Executing `arduino-cli core download`")

platformsRefs, err := arguments.ParseReferences(srv, ctx, args)
platformsRefs, err := arguments.ParseReferences(ctx, srv, args)
if err != nil {
feedback.Fatal(tr("Invalid argument passed: %v", err), feedback.ErrBadArgument)
}
Expand Down
6 changes: 3 additions & 3 deletions internal/cli/core/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func initInstallCommand(srv rpc.ArduinoCoreServiceServer) *cobra.Command {
runInstallCommand(srv, args, scriptFlags, noOverwrite)
},
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
return arguments.GetInstallableCores(srv, context.Background()), cobra.ShellCompDirectiveDefault
return arguments.GetInstallableCores(context.Background(), srv), cobra.ShellCompDirectiveDefault
},
}
scriptFlags.AddToCommand(installCommand)
Expand All @@ -59,9 +59,9 @@ func initInstallCommand(srv rpc.ArduinoCoreServiceServer) *cobra.Command {
func runInstallCommand(srv rpc.ArduinoCoreServiceServer, args []string, scriptFlags arguments.PrePostScriptsFlags, noOverwrite bool) {
logrus.Info("Executing `arduino-cli core install`")
ctx := context.Background()
inst := instance.CreateAndInit(srv, ctx)
inst := instance.CreateAndInit(ctx, srv)

platformsRefs, err := arguments.ParseReferences(srv, ctx, args)
platformsRefs, err := arguments.ParseReferences(ctx, srv, args)
if err != nil {
feedback.Fatal(tr("Invalid argument passed: %v", err), feedback.ErrBadArgument)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/cli/core/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func initListCommand(srv rpc.ArduinoCoreServiceServer) *cobra.Command {

func runListCommand(srv rpc.ArduinoCoreServiceServer, all bool, updatableOnly bool) {
ctx := context.Background()
inst := instance.CreateAndInit(srv, ctx)
inst := instance.CreateAndInit(ctx, srv)
logrus.Info("Executing `arduino-cli core list`")
List(inst, all, updatableOnly)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/cli/core/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const indexUpdateInterval = 24 * time.Hour

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

res, err := commands.UpdateIndex(
context.Background(),
Expand Down
6 changes: 3 additions & 3 deletions internal/cli/core/uninstall.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func initUninstallCommand(srv rpc.ArduinoCoreServiceServer) *cobra.Command {
runUninstallCommand(srv, args, preUninstallFlags)
},
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
return arguments.GetUninstallableCores(srv, context.Background()), cobra.ShellCompDirectiveDefault
return arguments.GetUninstallableCores(context.Background(), srv), cobra.ShellCompDirectiveDefault
},
}
preUninstallFlags.AddToCommand(uninstallCommand)
Expand All @@ -51,9 +51,9 @@ func initUninstallCommand(srv rpc.ArduinoCoreServiceServer) *cobra.Command {
func runUninstallCommand(srv rpc.ArduinoCoreServiceServer, args []string, preUninstallFlags arguments.PrePostScriptsFlags) {
logrus.Info("Executing `arduino-cli core uninstall`")
ctx := context.Background()
inst := instance.CreateAndInit(srv, ctx)
inst := instance.CreateAndInit(ctx, srv)

platformsRefs, err := arguments.ParseReferences(srv, ctx, args)
platformsRefs, err := arguments.ParseReferences(ctx, srv, args)
if err != nil {
feedback.Fatal(tr("Invalid argument passed: %v", err), feedback.ErrBadArgument)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/cli/core/update_index.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func initUpdateIndexCommand(srv rpc.ArduinoCoreServiceServer) *cobra.Command {
func runUpdateIndexCommand(srv rpc.ArduinoCoreServiceServer) {
logrus.Info("Executing `arduino-cli core update-index`")
ctx := context.Background()
inst := instance.CreateAndInit(srv, ctx)
inst := instance.CreateAndInit(ctx, srv)
resp := UpdateIndex(inst)

feedback.PrintResult(&updateIndexResult{result.NewUpdateIndexResponse_ResultResult(resp)})
Expand Down
8 changes: 4 additions & 4 deletions internal/cli/core/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ func initUpgradeCommand(srv rpc.ArduinoCoreServiceServer) *cobra.Command {
func runUpgradeCommand(srv rpc.ArduinoCoreServiceServer, args []string, skipPostInstall bool, skipPreUninstall bool) {
logrus.Info("Executing `arduino-cli core upgrade`")
ctx := context.Background()
inst := instance.CreateAndInit(srv, ctx)
Upgrade(srv, ctx, inst, args, skipPostInstall, skipPreUninstall)
inst := instance.CreateAndInit(ctx, srv)
Upgrade(ctx, srv, inst, args, skipPostInstall, skipPreUninstall)
}

// Upgrade upgrades one or all installed platforms to the latest version.
func Upgrade(srv rpc.ArduinoCoreServiceServer, ctx context.Context, inst *rpc.Instance, args []string, skipPostInstall bool, skipPreUninstall bool) {
func Upgrade(ctx context.Context, srv rpc.ArduinoCoreServiceServer, inst *rpc.Instance, args []string, skipPostInstall bool, skipPreUninstall bool) {
// if no platform was passed, upgrade allthethings
if len(args) == 0 {
platforms, err := commands.PlatformSearch(&rpc.PlatformSearchRequest{
Expand Down Expand Up @@ -103,7 +103,7 @@ func Upgrade(srv rpc.ArduinoCoreServiceServer, ctx context.Context, inst *rpc.In
}

// proceed upgrading, if anything is upgradable
platformsRefs, err := arguments.ParseReferences(srv, ctx, args)
platformsRefs, err := arguments.ParseReferences(ctx, srv, args)
if err != nil {
feedback.Fatal(tr("Invalid argument passed: %v", err), feedback.ErrBadArgument)
}
Expand Down
4 changes: 2 additions & 2 deletions internal/cli/debug/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ func runDebugCommand(srv rpc.ArduinoCoreServiceServer, args []string, portArgs *
var profile *rpc.SketchProfile

if profileArg.Get() == "" {
inst, profile = instance.CreateAndInitWithProfile(srv, ctx, sk.GetDefaultProfile().GetName(), sketchPath)
inst, profile = instance.CreateAndInitWithProfile(ctx, srv, sk.GetDefaultProfile().GetName(), sketchPath)
} else {
inst, profile = instance.CreateAndInitWithProfile(srv, ctx, profileArg.Get(), sketchPath)
inst, profile = instance.CreateAndInitWithProfile(ctx, srv, profileArg.Get(), sketchPath)
}

if fqbnArg.String() == "" {
Expand Down
2 changes: 1 addition & 1 deletion internal/cli/debug/debug_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func newDebugCheckCommand(srv rpc.ArduinoCoreServiceServer) *cobra.Command {

func runDebugCheckCommand(srv rpc.ArduinoCoreServiceServer, portArgs *arguments.Port, fqbnArg *arguments.Fqbn, interpreter string, programmerArg *arguments.Programmer) {
ctx := context.Background()
instance := instance.CreateAndInit(srv, ctx)
instance := instance.CreateAndInit(ctx, srv)
logrus.Info("Executing `arduino-cli debug`")

port, err := portArgs.GetPort(instance, srv, "", "")
Expand Down
Loading