Skip to content

Commit

Permalink
[skip-changelog] Removed dep from 'configuration' package in Discover…
Browse files Browse the repository at this point in the history
…yManager (#2568)
  • Loading branch information
cmaglie authored Mar 19, 2024
1 parent 6a45713 commit 31e3288
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
3 changes: 2 additions & 1 deletion internal/arduino/cores/packagemanager/package_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
"github.com/arduino/arduino-cli/internal/arduino/cores/packageindex"
"github.com/arduino/arduino-cli/internal/arduino/discovery/discoverymanager"
"github.com/arduino/arduino-cli/internal/arduino/sketch"
"github.com/arduino/arduino-cli/internal/cli/configuration"
"github.com/arduino/arduino-cli/internal/i18n"
paths "github.com/arduino/go-paths-helper"
properties "github.com/arduino/go-properties-orderedmap"
Expand Down Expand Up @@ -83,7 +84,7 @@ func NewBuilder(indexDir, packagesDir, downloadDir, tempDir *paths.Path, userAge
DownloadDir: downloadDir,
tempDir: tempDir,
packagesCustomGlobalProperties: properties.NewMap(),
discoveryManager: discoverymanager.New(),
discoveryManager: discoverymanager.New(configuration.UserAgent(configuration.Settings)),
userAgent: userAgent,
}
}
Expand Down
2 changes: 1 addition & 1 deletion internal/arduino/discovery/discovery_client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func main() {
os.Exit(1)
}
logrus.SetLevel(logrus.ErrorLevel)
dm := discoverymanager.New()
dm := discoverymanager.New("discovery_client/1.0.0")
for _, discCmd := range os.Args[1:] {
dm.Add(discCmd, discCmd)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"sync"
"time"

"github.com/arduino/arduino-cli/internal/cli/configuration"
"github.com/arduino/arduino-cli/internal/i18n"
discovery "github.com/arduino/pluggable-discovery-protocol-handler/v2"
"github.com/sirupsen/logrus"
Expand All @@ -41,17 +40,19 @@ type DiscoveryManager struct {
watchersMutex sync.Mutex
watchers map[*PortWatcher]bool // all registered Watcher
watchersCache map[string]map[string]*discovery.Event // this is a cache of all active ports
userAgent string
}

var tr = i18n.Tr

// New creates a new DiscoveryManager
func New() *DiscoveryManager {
func New(userAgent string) *DiscoveryManager {
return &DiscoveryManager{
discoveries: map[string]*discovery.Client{},
watchers: map[*PortWatcher]bool{},
feed: make(chan *discovery.Event, 50),
watchersCache: map[string]map[string]*discovery.Event{},
userAgent: userAgent,
}
}

Expand Down Expand Up @@ -121,7 +122,7 @@ func (dm *DiscoveryManager) Start() []error {
func (dm *DiscoveryManager) Add(id string, args ...string) error {
d := discovery.NewClient(id, args...)
d.SetLogger(logrus.WithField("discovery", id))
d.SetUserAgent(configuration.UserAgent(configuration.Settings))
d.SetUserAgent(dm.userAgent)
return dm.add(d)
}

Expand Down

0 comments on commit 31e3288

Please sign in to comment.