diff --git a/cmd/cluster-agent/app/compliance_cmd.go b/cmd/cluster-agent/app/compliance_cmd.go index 397abf7abbf733..32c1ff7beceb33 100644 --- a/cmd/cluster-agent/app/compliance_cmd.go +++ b/cmd/cluster-agent/app/compliance_cmd.go @@ -11,7 +11,7 @@ package app import ( "github.com/spf13/cobra" - "github.com/DataDog/datadog-agent/cmd/security-agent/app/subcommands/check" + "github.com/DataDog/datadog-agent/cmd/security-agent/subcommands/check" "github.com/DataDog/datadog-agent/comp/core" "github.com/DataDog/datadog-agent/comp/core/config" "github.com/DataDog/datadog-agent/comp/core/log" @@ -34,6 +34,7 @@ func init() { LogParams: log.LogForOneShot(string(loggerName), "off", true), } - complianceCmd.AddCommand(check.Commands(bundleParams)...) + // TODO: The SecAgent Check package should be a component + complianceCmd.AddCommand(check.CommandsWrapped(bundleParams)...) ClusterAgentCmd.AddCommand(complianceCmd) } diff --git a/cmd/security-agent/subcommands/check/command.go b/cmd/security-agent/subcommands/check/command.go index 5deedfb87d9cbd..7dc48dfa78d1e3 100644 --- a/cmd/security-agent/subcommands/check/command.go +++ b/cmd/security-agent/subcommands/check/command.go @@ -49,6 +49,16 @@ type CliParams struct { // Commands returns a cobra command to run security agent checks func Commands(globalParams *command.GlobalParams) []*cobra.Command { + bundleParams := core.BundleParams{ + ConfigParams: config.NewSecurityAgentParams(globalParams.ConfigFilePaths), + LogParams: log.LogForOneShot(command.LoggerName, "info", true), + } + + return CommandsWrapped(bundleParams) +} + +// CommandsWrapped exists to allow for an entry point from the Cluster-Agent. We should remove this and refactor once Check becomes a component that both the Cluster Agent and the Security Agent can use. +func CommandsWrapped(bundleParams core.BundleParams) []*cobra.Command { checkArgs := &CliParams{} cmd := &cobra.Command{ @@ -57,10 +67,6 @@ func Commands(globalParams *command.GlobalParams) []*cobra.Command { Long: ``, RunE: func(cmd *cobra.Command, args []string) error { checkArgs.args = args - bundleParams := core.BundleParams{ - ConfigParams: config.NewSecurityAgentParams(globalParams.ConfigFilePaths), - LogParams: log.LogForOneShot(command.LoggerName, "info", true), - } if checkArgs.verbose { bundleParams.LogParams = log.LogForOneShot(bundleParams.LogParams.LoggerName(), "trace", true) }