Skip to content

Commit

Permalink
Add winregistry module to the check subcommand (#23303)
Browse files Browse the repository at this point in the history
* Add `winregistry` and `agentcrashdetect` modules to the check subcommand

* [skip-ci] Add release note

* Remove the crash detect module

* Update release notes

* Renamed release note

* Update command_not_windows.go

* Update command_not_windows.go

* Rename not_windows into notwindows

* Ensure unit test pass by creating the config
  • Loading branch information
julien-lebot authored and alexgallotta committed May 9, 2024
1 parent c2739c9 commit 295a14b
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 1 deletion.
2 changes: 2 additions & 0 deletions pkg/cli/subcommands/check/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@ func MakeCommand(globalParamsGetter func() GlobalParams) *cobra.Command {
fx.Provide(func() packagesigning.Component { return nil }),
fx.Provide(func() optional.Option[rcservice.Component] { return optional.NewNoneOption[rcservice.Component]() }),
fx.Provide(func() optional.Option[rcserviceha.Component] { return optional.NewNoneOption[rcserviceha.Component]() }),

getPlatformModules(),
)
},
}
Expand Down
14 changes: 14 additions & 0 deletions pkg/cli/subcommands/check/command_notwindows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Unless explicitly stated otherwise all files in this repository are licensed
// under the Apache License Version 2.0.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2016-present Datadog, Inc.

//go:build !windows

package check

import "go.uber.org/fx"

func getPlatformModules() fx.Option {
return fx.Options()
}
11 changes: 10 additions & 1 deletion pkg/cli/subcommands/check/command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
package check

import (
"os"
"path"
"testing"

"github.com/spf13/cobra"
Expand All @@ -19,7 +21,14 @@ import (
func TestCommand(t *testing.T) {
commands := []*cobra.Command{
MakeCommand(func() GlobalParams {
return GlobalParams{}
// the config needs an existing config file when initializing
config := path.Join(t.TempDir(), "datadog.yaml")
err := os.WriteFile(config, []byte("hostname: test"), 0644)
require.NoError(t, err)

return GlobalParams{
ConfFilePath: config,
}
}),
}

Expand Down
21 changes: 21 additions & 0 deletions pkg/cli/subcommands/check/command_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Unless explicitly stated otherwise all files in this repository are licensed
// under the Apache License Version 2.0.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2016-present Datadog, Inc.

//go:build windows

package check

import (
"github.com/DataDog/datadog-agent/comp/checks/winregistry"
winregistryimpl "github.com/DataDog/datadog-agent/comp/checks/winregistry/impl"
"go.uber.org/fx"
)

func getPlatformModules() fx.Option {
return fx.Options(
winregistryimpl.Module(),
fx.Invoke(func(_ winregistry.Component) {}),
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
fixes:
- |
The `windows_registry` check can be run with the `check` sub-command.

0 comments on commit 295a14b

Please sign in to comment.