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
3 changes: 2 additions & 1 deletion cmd/agent/subcommands/check/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/spf13/cobra"

"github.com/DataDog/datadog-agent/cmd/agent/command"
wmcatalog "github.com/DataDog/datadog-agent/comp/core/workloadmeta/collectors/catalog"
"github.com/DataDog/datadog-agent/pkg/cli/subcommands/check"
)

Expand All @@ -24,7 +25,7 @@ func Commands(globalParams *command.GlobalParams) []*cobra.Command {
ConfigName: command.ConfigName,
LoggerName: command.LoggerName,
}
})
}, wmcatalog.GetCatalog())

return []*cobra.Command{cmd}
}
3 changes: 2 additions & 1 deletion cmd/cluster-agent/subcommands/check/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ package check

import (
"github.com/DataDog/datadog-agent/cmd/cluster-agent/command"
wmcatalog "github.com/DataDog/datadog-agent/comp/core/workloadmeta/collectors/catalog-clusteragent"
"github.com/DataDog/datadog-agent/pkg/cli/subcommands/check"
pkgconfigsetup "github.com/DataDog/datadog-agent/pkg/config/setup"
pkgcommon "github.com/DataDog/datadog-agent/pkg/util/common"
Expand All @@ -32,7 +33,7 @@ func Commands(globalParams *command.GlobalParams) []*cobra.Command {
ConfigName: command.ConfigName,
LoggerName: command.LoggerName,
}
})
}, wmcatalog.GetCatalog())

return []*cobra.Command{cmd}
}
2 changes: 1 addition & 1 deletion cmd/cluster-agent/subcommands/start/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ import (
telemetry "github.com/DataDog/datadog-agent/comp/core/telemetry/def"
workloadfilter "github.com/DataDog/datadog-agent/comp/core/workloadfilter/def"
workloadfilterfx "github.com/DataDog/datadog-agent/comp/core/workloadfilter/fx"
wmcatalog "github.com/DataDog/datadog-agent/comp/core/workloadmeta/collectors/catalog"
wmcatalog "github.com/DataDog/datadog-agent/comp/core/workloadmeta/collectors/catalog-clusteragent"
workloadmeta "github.com/DataDog/datadog-agent/comp/core/workloadmeta/def"
workloadmetafx "github.com/DataDog/datadog-agent/comp/core/workloadmeta/fx"
workloadmetainit "github.com/DataDog/datadog-agent/comp/core/workloadmeta/init"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// 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.

// Package catalog is a wrapper that loads the available workloadmeta
// collectors. This is the catalog used by the cluster agent.
package catalog

import (
"go.uber.org/fx"
)

// GetCatalog returns the set of FX options to populate the catalog
func GetCatalog() fx.Option {
options := getCollectorOptions()

// remove nil options
opts := make([]fx.Option, 0, len(options))
for _, item := range options {
if item != nil {
opts = append(opts, item)
}
}
return fx.Options(opts...)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// 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.

package catalog

import (
"go.uber.org/fx"

"github.com/DataDog/datadog-agent/comp/core/workloadmeta/collectors/internal/kubeapiserver"
)

func getCollectorOptions() []fx.Option {
return []fx.Option{
kubeapiserver.GetFxOptions(),
}
}
2 changes: 0 additions & 2 deletions comp/core/workloadmeta/collectors/catalog/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
"github.com/DataDog/datadog-agent/comp/core/workloadmeta/collectors/internal/crio"
"github.com/DataDog/datadog-agent/comp/core/workloadmeta/collectors/internal/docker"
"github.com/DataDog/datadog-agent/comp/core/workloadmeta/collectors/internal/ecs"
"github.com/DataDog/datadog-agent/comp/core/workloadmeta/collectors/internal/kubeapiserver"
"github.com/DataDog/datadog-agent/comp/core/workloadmeta/collectors/internal/kubelet"
"github.com/DataDog/datadog-agent/comp/core/workloadmeta/collectors/internal/kubemetadata"
"github.com/DataDog/datadog-agent/comp/core/workloadmeta/collectors/internal/nvml"
Expand All @@ -34,7 +33,6 @@ func getCollectorOptions() []fx.Option {
crio.GetFxOptions(),
docker.GetFxOptions(),
ecs.GetFxOptions(),
kubeapiserver.GetFxOptions(),
kubelet.GetFxOptions(),
kubemetadata.GetFxOptions(),
podman.GetFxOptions(),
Expand Down
5 changes: 2 additions & 3 deletions pkg/cli/subcommands/check/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ import (
telemetry "github.com/DataDog/datadog-agent/comp/core/telemetry/def"
workloadfilter "github.com/DataDog/datadog-agent/comp/core/workloadfilter/def"
workloadfilterfx "github.com/DataDog/datadog-agent/comp/core/workloadfilter/fx"
wmcatalog "github.com/DataDog/datadog-agent/comp/core/workloadmeta/collectors/catalog"
workloadmeta "github.com/DataDog/datadog-agent/comp/core/workloadmeta/def"
"github.com/DataDog/datadog-agent/comp/core/workloadmeta/defaults"
workloadmetafx "github.com/DataDog/datadog-agent/comp/core/workloadmeta/fx"
Expand Down Expand Up @@ -144,7 +143,7 @@ type GlobalParams struct {
}

// MakeCommand returns a `check` command to be used by agent binaries.
func MakeCommand(globalParamsGetter func() GlobalParams) *cobra.Command {
func MakeCommand(globalParamsGetter func() GlobalParams, wmCatalog fx.Option) *cobra.Command {
cliParams := &cliParams{}
cmd := &cobra.Command{
Use: "check <check_name>",
Expand Down Expand Up @@ -175,7 +174,7 @@ func MakeCommand(globalParamsGetter func() GlobalParams) *cobra.Command {
hostnameimpl.Module(),

// workloadmeta setup
wmcatalog.GetCatalog(),
wmCatalog,
workloadmetafx.Module(defaults.DefaultParams()),
apiimpl.Module(),
grpcNonefx.Module(),
Expand Down
5 changes: 3 additions & 2 deletions pkg/cli/subcommands/check/command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
secretsmock "github.com/DataDog/datadog-agent/comp/core/secrets/mock"
taggerfxmock "github.com/DataDog/datadog-agent/comp/core/tagger/fx-mock"
workloadfilterfxmock "github.com/DataDog/datadog-agent/comp/core/workloadfilter/fx-mock"
wmcatalog "github.com/DataDog/datadog-agent/comp/core/workloadmeta/collectors/catalog"
workloadmeta "github.com/DataDog/datadog-agent/comp/core/workloadmeta/def"
workloadmetafxmock "github.com/DataDog/datadog-agent/comp/core/workloadmeta/fx-mock"
"github.com/DataDog/datadog-agent/pkg/util/fxutil"
Expand All @@ -43,7 +44,7 @@ func TestCommand(t *testing.T) {
return GlobalParams{
ConfFilePath: config,
}
}),
}, wmcatalog.GetCatalog()),
}

fxutil.TestOneShotSubcommand(t,
Expand Down Expand Up @@ -115,7 +116,7 @@ func TestCommandWithInstanceID(t *testing.T) {
return GlobalParams{
ConfFilePath: config,
}
}),
}, wmcatalog.GetCatalog()),
}

fxutil.TestOneShotSubcommand(t,
Expand Down
Loading