Skip to content

Commit 74ae1d1

Browse files
committed
Add InstallDescriptorSource abstraction
1 parent 1c65022 commit 74ae1d1

File tree

10 files changed

+1039
-163
lines changed

10 files changed

+1039
-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
@@ -26,6 +26,7 @@ import (
2626

2727
"github.com/elastic/elastic-agent-client/v7/pkg/proto"
2828
"github.com/elastic/elastic-agent/internal/pkg/testutils"
29+
"github.com/elastic/elastic-agent/pkg/utils/install"
2930

3031
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/status"
3132
"go.opentelemetry.io/collector/component/componentstatus"
@@ -462,7 +463,8 @@ func TestCoordinatorReportsInvalidPolicy(t *testing.T) {
462463
}
463464
}()
464465

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

468470
// 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)