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
Implementation of Viper replacement library
- Using configmap allows better handling of config types
- The CLI "instances" now caches all the configuration at Create-time
- Setting are now only accessible via gRPC calls
- Helper methods have been implemented to access all key/value pairs
  • Loading branch information
cmaglie committed May 6, 2024
commit 4c50868a2ad1733a280479acb3b5f1a3f3bbccbc
25 changes: 13 additions & 12 deletions commands/instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import (
"github.com/arduino/arduino-cli/internal/arduino/resources"
"github.com/arduino/arduino-cli/internal/arduino/sketch"
"github.com/arduino/arduino-cli/internal/arduino/utils"
"github.com/arduino/arduino-cli/internal/cli/configuration"
"github.com/arduino/arduino-cli/internal/i18n"
rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
paths "github.com/arduino/go-paths-helper"
Expand Down Expand Up @@ -72,7 +71,7 @@ func (s *arduinoCoreServerImpl) Create(ctx context.Context, req *rpc.CreateReque
}

// Setup downloads directory
downloadsDir := configuration.DownloadsDir(s.settings)
downloadsDir := s.settings.DownloadsDir()
if downloadsDir.NotExist() {
err := downloadsDir.MkdirAll()
if err != nil {
Expand All @@ -81,8 +80,9 @@ func (s *arduinoCoreServerImpl) Create(ctx context.Context, req *rpc.CreateReque
}

// Setup data directory
dataDir := configuration.DataDir(s.settings)
packagesDir := configuration.PackagesDir(s.settings)
dataDir := s.settings.DataDir()
userPackagesDir := s.settings.UserDir().Join("hardware")
packagesDir := s.settings.PackagesDir()
if packagesDir.NotExist() {
err := packagesDir.MkdirAll()
if err != nil {
Expand All @@ -94,7 +94,7 @@ func (s *arduinoCoreServerImpl) Create(ctx context.Context, req *rpc.CreateReque
if err != nil {
return nil, err
}
inst, err := instances.Create(dataDir, packagesDir, downloadsDir, userAgent, config)
inst, err := instances.Create(dataDir, packagesDir, userPackagesDir, downloadsDir, userAgent, config)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -177,7 +177,7 @@ func (s *arduinoCoreServerImpl) Init(req *rpc.InitRequest, stream rpc.ArduinoCor
defaultIndexURL, _ := utils.URLParse(globals.DefaultIndexURL)
allPackageIndexUrls := []*url.URL{defaultIndexURL}
if profile == nil {
for _, u := range s.settings.GetStringSlice("board_manager.additional_urls") {
for _, u := range s.settings.BoardManagerAdditionalUrls() {
URL, err := utils.URLParse(u)
if err != nil {
e := &cmderrors.InitFailedError{
Expand All @@ -192,7 +192,7 @@ func (s *arduinoCoreServerImpl) Init(req *rpc.InitRequest, stream rpc.ArduinoCor
}
}

if err := firstUpdate(ctx, s, req.GetInstance(), configuration.DataDir(s.settings), downloadCallback, allPackageIndexUrls); err != nil {
if err := firstUpdate(ctx, s, req.GetInstance(), s.settings.DataDir(), downloadCallback, allPackageIndexUrls); err != nil {
e := &cmderrors.InitFailedError{
Code: codes.InvalidArgument,
Cause: err,
Expand Down Expand Up @@ -245,7 +245,7 @@ func (s *arduinoCoreServerImpl) Init(req *rpc.InitRequest, stream rpc.ArduinoCor

// Load Platforms
if profile == nil {
for _, err := range pmb.LoadHardware(s.settings) {
for _, err := range pmb.LoadHardware() {
s := &cmderrors.PlatformLoadingError{Cause: err}
responseError(s.GRPCStatus())
}
Expand Down Expand Up @@ -349,7 +349,7 @@ func (s *arduinoCoreServerImpl) Init(req *rpc.InitRequest, stream rpc.ArduinoCor

if profile == nil {
// Add directories of libraries bundled with IDE
if bundledLibsDir := configuration.IDEBuiltinLibrariesDir(s.settings); bundledLibsDir != nil {
if bundledLibsDir := s.settings.IDEBuiltinLibrariesDir(); bundledLibsDir != nil {
lmb.AddLibrariesDir(librariesmanager.LibrariesDir{
Path: bundledLibsDir,
Location: libraries.IDEBuiltIn,
Expand All @@ -358,14 +358,14 @@ func (s *arduinoCoreServerImpl) Init(req *rpc.InitRequest, stream rpc.ArduinoCor

// Add libraries directory from config file
lmb.AddLibrariesDir(librariesmanager.LibrariesDir{
Path: configuration.LibrariesDir(s.settings),
Path: s.settings.LibrariesDir(),
Location: libraries.User,
})
} else {
// Load libraries required for profile
for _, libraryRef := range profile.Libraries {
uid := libraryRef.InternalUniqueIdentifier()
libRoot := configuration.ProfilesCacheDir(s.settings).Join(uid)
libRoot := s.settings.ProfilesCacheDir().Join(uid)
libDir := libRoot.Join(libraryRef.Library)

if !libDir.IsDir() {
Expand Down Expand Up @@ -548,7 +548,7 @@ func (s *arduinoCoreServerImpl) UpdateIndex(req *rpc.UpdateIndexRequest, stream
Message: &rpc.UpdateIndexResponse_DownloadProgress{DownloadProgress: p},
})
}
indexpath := configuration.DataDir(s.settings)
indexpath := s.settings.DataDir()

urls := []string{globals.DefaultIndexURL}
if !req.GetIgnoreCustomPackageIndexes() {
Expand Down Expand Up @@ -614,6 +614,7 @@ func (s *arduinoCoreServerImpl) UpdateIndex(req *rpc.UpdateIndexRequest, stream
downloadCB.Start(u, tr("Downloading index: %s", filepath.Base(URL.Path)))
downloadCB.End(false, tr("Invalid network configuration: %s", err))
failed = true
continue
}

if strings.HasSuffix(URL.Host, "arduino.cc") && strings.HasSuffix(URL.Path, ".json") {
Expand Down
4 changes: 2 additions & 2 deletions commands/internal/instances/instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,15 @@ func SetLibraryManager(inst *rpc.Instance, lm *librariesmanager.LibrariesManager
}

// Create a new *rpc.Instance ready to be initialized
func Create(dataDir, packagesDir, downloadsDir *paths.Path, extraUserAgent string, downloaderConfig downloader.Config) (*rpc.Instance, error) {
func Create(dataDir, packagesDir, userPackagesDir, downloadsDir *paths.Path, extraUserAgent string, downloaderConfig downloader.Config) (*rpc.Instance, error) {
// Create package manager
userAgent := "arduino-cli/" + version.VersionInfo.VersionString
if extraUserAgent != "" {
userAgent += " " + extraUserAgent
}
tempDir := dataDir.Join("tmp")

pm := packagemanager.NewBuilder(dataDir, packagesDir, downloadsDir, tempDir, userAgent, downloaderConfig).Build()
pm := packagemanager.NewBuilder(dataDir, packagesDir, userPackagesDir, downloadsDir, tempDir, userAgent, downloaderConfig).Build()
lm, _ := librariesmanager.NewBuilder().Build()

instance := &coreInstance{
Expand Down
18 changes: 10 additions & 8 deletions commands/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,30 @@ import (
"context"

"github.com/arduino/arduino-cli/internal/cli/configuration"
"github.com/arduino/arduino-cli/internal/i18n"
rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
"github.com/arduino/arduino-cli/version"
)

// NewArduinoCoreServer returns an implementation of the ArduinoCoreService gRPC service
// that uses the provided version string.
func NewArduinoCoreServer(version string, settings *configuration.Settings) rpc.ArduinoCoreServiceServer {
return &arduinoCoreServerImpl{
versionString: version,
settings: settings,
}
func NewArduinoCoreServer() rpc.ArduinoCoreServiceServer {
settings := configuration.NewSettings()

// Setup i18n
i18n.Init(settings.Locale())

return &arduinoCoreServerImpl{settings: settings}
}

type arduinoCoreServerImpl struct {
rpc.UnsafeArduinoCoreServiceServer // Force compile error for unimplemented methods

versionString string

// Settings holds configurations of the CLI and the gRPC consumers
settings *configuration.Settings
}

// Version returns the version of the Arduino CLI
func (s *arduinoCoreServerImpl) Version(ctx context.Context, req *rpc.VersionRequest) (*rpc.VersionResponse, error) {
return &rpc.VersionResponse{Version: s.versionString}, nil
return &rpc.VersionResponse{Version: version.VersionInfo.VersionString}, nil
}
24 changes: 16 additions & 8 deletions commands/service_board_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,59 +48,67 @@ func TestGetByVidPid(t *testing.T) {
defer ts.Close()

vidPidURL = ts.URL
res, err := apiByVidPid("0xf420", "0XF069", configuration.Init(""))
settings := configuration.NewSettings()
res, err := apiByVidPid("0xf420", "0XF069", settings)
require.Nil(t, err)
require.Len(t, res, 1)
require.Equal(t, "Arduino/Genuino MKR1000", res[0].GetName())
require.Equal(t, "arduino:samd:mkr1000", res[0].GetFqbn())

// wrong vid (too long), wrong pid (not an hex value)

_, err = apiByVidPid("0xfffff", "0xDEFG", configuration.Init(""))
_, err = apiByVidPid("0xfffff", "0xDEFG", settings)
require.NotNil(t, err)
}

func TestGetByVidPidNotFound(t *testing.T) {
settings := configuration.NewSettings()

ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusNotFound)
}))
defer ts.Close()

vidPidURL = ts.URL
res, err := apiByVidPid("0x0420", "0x0069", configuration.Init(""))
res, err := apiByVidPid("0x0420", "0x0069", settings)
require.NoError(t, err)
require.Empty(t, res)
}

func TestGetByVidPid5xx(t *testing.T) {
settings := configuration.NewSettings()

ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusInternalServerError)
w.Write([]byte("500 - Ooooops!"))
}))
defer ts.Close()

vidPidURL = ts.URL
res, err := apiByVidPid("0x0420", "0x0069", configuration.Init(""))
res, err := apiByVidPid("0x0420", "0x0069", settings)
require.NotNil(t, err)
require.Equal(t, "the server responded with status 500 Internal Server Error", err.Error())
require.Len(t, res, 0)
}

func TestGetByVidPidMalformedResponse(t *testing.T) {
settings := configuration.NewSettings()

ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "{}")
}))
defer ts.Close()

vidPidURL = ts.URL
res, err := apiByVidPid("0x0420", "0x0069", configuration.Init(""))
res, err := apiByVidPid("0x0420", "0x0069", settings)
require.NotNil(t, err)
require.Equal(t, "wrong format in server response", err.Error())
require.Len(t, res, 0)
}

func TestBoardDetectionViaAPIWithNonUSBPort(t *testing.T) {
items, err := identifyViaCloudAPI(properties.NewMap(), configuration.Init(""))
settings := configuration.NewSettings()
items, err := identifyViaCloudAPI(properties.NewMap(), settings)
require.NoError(t, err)
require.Empty(t, items)
}
Expand All @@ -112,7 +120,7 @@ func TestBoardIdentifySorting(t *testing.T) {
defer paths.TempDir().Join("test").RemoveAll()

// We don't really care about the paths in this case
pmb := packagemanager.NewBuilder(dataDir, dataDir, dataDir, dataDir, "test", downloader.GetDefaultConfig())
pmb := packagemanager.NewBuilder(dataDir, dataDir, nil, dataDir, dataDir, "test", downloader.GetDefaultConfig())

// Create some boards with identical VID:PID combination
pack := pmb.GetOrCreatePackage("packager")
Expand Down Expand Up @@ -148,7 +156,7 @@ func TestBoardIdentifySorting(t *testing.T) {
pme, release := pm.NewExplorer()
defer release()

settings := configuration.Init("")
settings := configuration.NewSettings()
res, err := identify(pme, &discovery.Port{Properties: idPrefs}, settings)
require.NoError(t, err)
require.NotNil(t, res)
Expand Down
3 changes: 1 addition & 2 deletions commands/service_cache_clean.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@ package commands
import (
"context"

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

// CleanDownloadCacheDirectory clean the download cache directory (where archives are downloaded).
func (s *arduinoCoreServerImpl) CleanDownloadCacheDirectory(ctx context.Context, req *rpc.CleanDownloadCacheDirectoryRequest) (*rpc.CleanDownloadCacheDirectoryResponse, error) {
cachePath := configuration.DownloadsDir(s.settings)
cachePath := s.settings.DownloadsDir()
err := cachePath.RemoveAll()
if err != nil {
return nil, err
Expand Down
13 changes: 6 additions & 7 deletions commands/service_compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import (
"github.com/arduino/arduino-cli/internal/arduino/sketch"
"github.com/arduino/arduino-cli/internal/arduino/utils"
"github.com/arduino/arduino-cli/internal/buildcache"
"github.com/arduino/arduino-cli/internal/cli/configuration"
"github.com/arduino/arduino-cli/internal/inventory"
rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
paths "github.com/arduino/go-paths-helper"
Expand Down Expand Up @@ -67,7 +66,7 @@ func (s *arduinoCoreServerImpl) Compile(req *rpc.CompileRequest, stream rpc.Ardu
ctx := stream.Context()
syncSend := NewSynchronizedSend(stream.Send)

exportBinaries := s.settings.GetBool("sketch.always_export_binaries")
exportBinaries := s.settings.SketchAlwaysExportBinaries()
if e := req.ExportBinaries; e != nil {
exportBinaries = *e
}
Expand Down Expand Up @@ -175,8 +174,8 @@ func (s *arduinoCoreServerImpl) Compile(req *rpc.CompileRequest, stream rpc.Ardu
// cache is purged after compilation to not remove entries that might be required

defer maybePurgeBuildCache(
s.settings.GetUint("build_cache.compilations_before_purge"),
s.settings.GetDuration("build_cache.ttl").Abs())
s.settings.GetCompilationsBeforeBuildCachePurge(),
s.settings.GetBuildCacheTTL().Abs())

var coreBuildCachePath *paths.Path
if req.GetBuildCachePath() == "" {
Expand All @@ -198,7 +197,7 @@ func (s *arduinoCoreServerImpl) Compile(req *rpc.CompileRequest, stream rpc.Ardu

actualPlatform := buildPlatform
otherLibrariesDirs := paths.NewPathList(req.GetLibraries()...)
otherLibrariesDirs.Add(configuration.LibrariesDir(s.settings))
otherLibrariesDirs.Add(s.settings.LibrariesDir())

var libsManager *librariesmanager.LibrariesManager
if pme.GetProfile() != nil {
Expand Down Expand Up @@ -231,9 +230,9 @@ func (s *arduinoCoreServerImpl) Compile(req *rpc.CompileRequest, stream rpc.Ardu
coreBuildCachePath,
int(req.GetJobs()),
req.GetBuildProperties(),
configuration.HardwareDirectories(s.settings),
s.settings.HardwareDirectories(),
otherLibrariesDirs,
configuration.IDEBuiltinLibrariesDir(s.settings),
s.settings.IDEBuiltinLibrariesDir(),
fqbn,
req.GetClean(),
req.GetSourceOverride(),
Expand Down
2 changes: 1 addition & 1 deletion commands/service_debug_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func TestGetCommandLine(t *testing.T) {
sketchPath := paths.New("testdata", "debug", sketch)
require.NoError(t, sketchPath.ToAbs())

pmb := packagemanager.NewBuilder(nil, nil, nil, nil, "test", downloader.GetDefaultConfig())
pmb := packagemanager.NewBuilder(nil, nil, nil, nil, nil, "test", downloader.GetDefaultConfig())
pmb.LoadHardwareFromDirectory(customHardware)
pmb.LoadHardwareFromDirectory(dataDir)

Expand Down
24 changes: 19 additions & 5 deletions commands/service_platform_search_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"context"
"testing"

"github.com/arduino/arduino-cli/internal/cli/configuration"
rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
"github.com/arduino/go-paths-helper"
"github.com/stretchr/testify/require"
Expand All @@ -36,9 +35,17 @@ func TestPlatformSearch(t *testing.T) {
err := paths.New("testdata", "platform", "package_index.json").CopyTo(dataDir.Join("package_index.json"))
require.Nil(t, err)

settings := configuration.Init(paths.TempDir().Join("test", "arduino-cli.yaml").String())
srv := NewArduinoCoreServer("", settings)
ctx := context.Background()
srv := NewArduinoCoreServer()

conf, err := paths.TempDir().Join("test", "arduino-cli.yaml").ReadFile()
require.NoError(t, err)
_, err = srv.ConfigurationOpen(ctx, &rpc.ConfigurationOpenRequest{
SettingsFormat: "yaml",
EncodedSettings: string(conf),
})
require.NoError(t, err)

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

Expand Down Expand Up @@ -337,9 +344,16 @@ func TestPlatformSearchSorting(t *testing.T) {
err := paths.New("testdata", "platform", "package_index.json").CopyTo(dataDir.Join("package_index.json"))
require.Nil(t, err)

settings := configuration.Init(paths.TempDir().Join("test", "arduino-cli.yaml").String())
srv := NewArduinoCoreServer("", settings)
ctx := context.Background()
srv := NewArduinoCoreServer()

conf, err := paths.TempDir().Join("test", "arduino-cli.yaml").ReadFile()
require.NoError(t, err)
_, err = srv.ConfigurationOpen(ctx, &rpc.ConfigurationOpenRequest{
SettingsFormat: "yaml",
EncodedSettings: string(conf),
})
require.NoError(t, err)

createResp, err := srv.Create(ctx, &rpc.CreateRequest{})
require.NoError(t, err)
Expand Down
Loading
0