Skip to content
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

Add management mode to client-side AgentInfo structs #112

Merged
merged 1 commit into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 6 additions & 3 deletions pkg/client/client_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ type AgentInfo struct {
Version string
// Snapshot is true when the running version of the Elastic Agent is a snapshot.
Snapshot bool
// IsStandalone reports if the agent is running in standalone or managed mode
ManagedMode proto.AgentManagedMode
}

// VersionInfo is the version information for the connecting client.
Expand Down Expand Up @@ -573,9 +575,10 @@ func (c *clientV2) applyExpected(expected *proto.CheckinExpected) {
if expected.AgentInfo != nil {
c.agentInfoMu.Lock()
c.agentInfo = &AgentInfo{
ID: expected.AgentInfo.Id,
Version: expected.AgentInfo.Version,
Snapshot: expected.AgentInfo.Snapshot,
ID: expected.AgentInfo.Id,
Version: expected.AgentInfo.Version,
Snapshot: expected.AgentInfo.Snapshot,
ManagedMode: expected.AgentInfo.Mode,
}
c.agentInfoMu.Unlock()
}
Expand Down
11 changes: 7 additions & 4 deletions pkg/client/client_v2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,10 @@ func testClientV2CheckinInitial(t *testing.T, localRPC string, serverCreds, clie
packageVersion := "8.13.0+build20060102"
wantBuildHash := "build_hash"
wantAgentInfo := AgentInfo{
ID: "elastic-agent-id",
Version: packageVersion,
Snapshot: true,
ID: "elastic-agent-id",
Version: packageVersion,
Snapshot: true,
ManagedMode: proto.AgentManagedMode_STANDALONE,
}
vInfo := VersionInfo{
Name: "program",
Expand All @@ -185,6 +186,7 @@ func testClientV2CheckinInitial(t *testing.T, localRPC string, serverCreds, clie
Id: wantAgentInfo.ID,
Version: wantAgentInfo.Version,
Snapshot: wantAgentInfo.Snapshot,
Mode: wantAgentInfo.ManagedMode,
},
Features: &proto.Features{
Fqdn: &proto.FQDNFeature{Enabled: wantFQDN},
Expand Down Expand Up @@ -303,8 +305,9 @@ func testClientV2CheckinInitial(t *testing.T, localRPC string, serverCreds, clie
assert.Equal(t, wantAgentInfo.ID, agentInfo.ID)
assert.Equal(t, wantAgentInfo.Version, agentInfo.Version)
assert.True(t, wantAgentInfo.Snapshot, agentInfo.Snapshot)
assert.Equal(t, wantAgentInfo.ManagedMode, agentInfo.ManagedMode)
}

assert.Truef(t, gotFQDN, "FQND should be true")

if assert.Lenf(t, units, 2, "should have received 2 units") {
Expand Down
7 changes: 4 additions & 3 deletions pkg/client/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,10 @@ func NewV2FromReader(reader io.Reader, ver VersionInfo, opts ...V2ClientOption)

if info.AgentInfo != nil {
opts = append(opts, WithAgentInfo(AgentInfo{
ID: info.AgentInfo.Id,
Version: info.AgentInfo.Version,
Snapshot: info.AgentInfo.Snapshot,
ID: info.AgentInfo.Id,
Version: info.AgentInfo.Version,
Snapshot: info.AgentInfo.Snapshot,
ManagedMode: info.AgentInfo.Mode,
}))
}

Expand Down