Skip to content

Commit c51fb1b

Browse files
committed
Add InstallDescriptorSource abstraction
1 parent 848916b commit c51fb1b

File tree

10 files changed

+1044
-163
lines changed

10 files changed

+1044
-163
lines changed

.mockery.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,4 @@ packages:
5454
interfaces:
5555
WatcherHelper:
5656
watcherGrappler:
57+
installDescriptorSource:

internal/pkg/agent/application/application.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@ package application
77
import (
88
"context"
99
"fmt"
10+
"path/filepath"
1011
"time"
1112

1213
"go.elastic.co/apm/v2"
1314

15+
"github.com/elastic/elastic-agent/pkg/utils/install"
1416
"github.com/elastic/go-ucfg"
1517

1618
"github.com/elastic/elastic-agent-libs/logp"
@@ -124,7 +126,7 @@ func New(
124126

125127
// monitoring is not supported in bootstrap mode https://github.com/elastic/elastic-agent/issues/1761
126128
isMonitoringSupported := !disableMonitoring && cfg.Settings.V1MonitoringEnabled
127-
upgrader, err := upgrade.NewUpgrader(log, cfg.Settings.DownloadConfig, cfg.Settings.Upgrade, agentInfo, new(upgrade.AgentWatcherHelper))
129+
upgrader, err := upgrade.NewUpgrader(log, cfg.Settings.DownloadConfig, cfg.Settings.Upgrade, agentInfo, new(upgrade.AgentWatcherHelper), install.NewFileDescriptorSource(filepath.Join(paths.Top(), paths.MarkerFileName)))
128130
if err != nil {
129131
return nil, nil, nil, fmt.Errorf("failed to create upgrader: %w", err)
130132
}

internal/pkg/agent/application/coordinator/coordinator_unit_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import (
2929
"github.com/elastic/elastic-agent-client/v7/pkg/proto"
3030
"github.com/elastic/elastic-agent/internal/pkg/fleetapi/acker"
3131
"github.com/elastic/elastic-agent/internal/pkg/testutils"
32+
"github.com/elastic/elastic-agent/pkg/utils/install"
3233

3334
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/status"
3435
"go.opentelemetry.io/collector/component/componentstatus"
@@ -467,7 +468,8 @@ func TestCoordinatorReportsInvalidPolicy(t *testing.T) {
467468
}
468469
}()
469470

470-
upgradeMgr, err := upgrade.NewUpgrader(log, &artifact.Config{}, nil, &info.AgentInfo{}, new(upgrade.AgentWatcherHelper))
471+
tmpDir := t.TempDir()
472+
upgradeMgr, err := upgrade.NewUpgrader(log, &artifact.Config{}, nil, &info.AgentInfo{}, new(upgrade.AgentWatcherHelper), install.NewFileDescriptorSource(filepath.Join(tmpDir, paths.MarkerFileName)))
471473
require.NoError(t, err, "errored when creating a new upgrader")
472474

473475
// Channels have buffer length 1, so we don't have to run on multiple

internal/pkg/agent/application/upgrade/mock_installdescriptorsource_test.go

Lines changed: 214 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)