Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,15 @@ describe('test agent checkin new action services', () => {
expect(
await createAgentActionFromPolicyAction(
mockSavedObjectsClient,
{ ...mockAgent, local_metadata: { elastic: { agent: { version: '7.10.1-SNAPSHOT' } } } },
{ ...mockAgent, local_metadata: { elastic: { agent: { version: '7.10.0-SNAPSHOT' } } } },
mockPolicyAction
)
).toEqual(expectedResult);

expect(
await createAgentActionFromPolicyAction(
mockSavedObjectsClient,
{ ...mockAgent, local_metadata: { elastic: { agent: { version: '7.10.2' } } } },
mockPolicyAction
)
).toEqual(expectedResult);
Expand Down Expand Up @@ -131,15 +139,15 @@ describe('test agent checkin new action services', () => {
expect(
await createAgentActionFromPolicyAction(
mockSavedObjectsClient,
{ ...mockAgent, local_metadata: { elastic: { agent: { version: '7.9.1-SNAPSHOT' } } } },
{ ...mockAgent, local_metadata: { elastic: { agent: { version: '7.9.3' } } } },
mockPolicyAction
)
).toEqual(expectedResult);

expect(
await createAgentActionFromPolicyAction(
mockSavedObjectsClient,
{ ...mockAgent, local_metadata: { elastic: { agent: { version: '7.9.3' } } } },
{ ...mockAgent, local_metadata: { elastic: { agent: { version: '7.9.1-SNAPSHOT' } } } },
mockPolicyAction
)
).toEqual(expectedResult);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,21 @@ export async function createAgentActionFromPolicyAction(
agent: Agent,
policyAction: AgentPolicyAction
) {
// Transform the policy action for agent version <= 7.9 for BWC
// Transform the policy action for agent version <= 7.9.x for BWC
const agentVersion = semver.parse((agent.local_metadata?.elastic as any)?.agent?.version);
const agentPolicyAction: AgentPolicyAction | AgentPolicyActionV7_9 =
agentVersion && semver.lt(agentVersion, '7.10.0')
agentVersion &&
semver.lt(
agentVersion,
// A prerelease tag is added here so that agent versions with prerelease tags can be compared
// correctly using `semvar`
'7.10.0-SNAPSHOT',
// `@types/semvar` is out of date with the version of `semvar` we use and doesn't have a
// corresponding release version we can update the typing to :( so, the typing error is
// suppressed here even though it is supported by `semvar`
// @ts-expect-error
{ includePrerelease: true }
)
? {
...policyAction,
type: 'CONFIG_CHANGE',
Expand Down