Skip to content

Commit

Permalink
[CSPM] Disabling host benchmarks should be propagated to the agent
Browse files Browse the repository at this point in the history
  • Loading branch information
jinroh committed Jul 8, 2024
1 parent 4c1f839 commit 3477a3d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
10 changes: 4 additions & 6 deletions controllers/datadogagent/feature/cspm/feature.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,13 +383,11 @@ func (f *cspmFeature) ManageNodeAgent(managers feature.PodTemplateManagers, prov
managers.EnvVar().AddEnvVarToContainer(apicommonv1.SecurityAgentContainerName, intervalEnvVar)
}

if f.hostBenchmarksEnabled {
hostBenchmarksEnabledEnvVar := &corev1.EnvVar{
Name: apicommon.DDComplianceHostBenchmarksEnabled,
Value: apiutils.BoolToString(&f.hostBenchmarksEnabled),
}
managers.EnvVar().AddEnvVarToContainer(apicommonv1.SecurityAgentContainerName, hostBenchmarksEnabledEnvVar)
hostBenchmarksEnabledEnvVar := &corev1.EnvVar{
Name: apicommon.DDComplianceHostBenchmarksEnabled,
Value: apiutils.BoolToString(&f.hostBenchmarksEnabled),
}
managers.EnvVar().AddEnvVarToContainer(apicommonv1.SecurityAgentContainerName, hostBenchmarksEnabledEnvVar)

return nil
}
Expand Down
5 changes: 5 additions & 0 deletions controllers/datadogagent/feature/cspm/feature_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,11 @@ func cspmAgentNodeWantFunc(useDDAV2 bool) *test.ComponentTest {
Name: apicommon.DDComplianceHostBenchmarksEnabled,
Value: "true",
})
} else {
want = append(want, &corev1.EnvVar{
Name: apicommon.DDComplianceHostBenchmarksEnabled,
Value: "false",
})
}
securityAgentEnvVars := mgr.EnvVarMgr.EnvVarsByC[apicommonv1.SecurityAgentContainerName]
assert.True(t, apiutils.IsEqualStruct(securityAgentEnvVars, want), "Agent envvars \ndiff = %s", cmp.Diff(securityAgentEnvVars, want))
Expand Down

0 comments on commit 3477a3d

Please sign in to comment.