From 80bd83651b0e6dd57f5bf839042c94e38cc0b72d Mon Sep 17 00:00:00 2001 From: odubajDT Date: Fri, 4 Oct 2024 07:50:14 +0200 Subject: [PATCH] move default values to kubeadm.go Signed-off-by: odubajDT --- .../internal/kubeadm/config.go | 7 ------- .../internal/kubeadm/config_test.go | 16 ---------------- .../internal/kubeadm/kubeadm.go | 6 ++++-- 3 files changed, 4 insertions(+), 25 deletions(-) delete mode 100644 processor/resourcedetectionprocessor/internal/kubeadm/config_test.go diff --git a/processor/resourcedetectionprocessor/internal/kubeadm/config.go b/processor/resourcedetectionprocessor/internal/kubeadm/config.go index 66d7155adf60..c9932dc332d5 100644 --- a/processor/resourcedetectionprocessor/internal/kubeadm/config.go +++ b/processor/resourcedetectionprocessor/internal/kubeadm/config.go @@ -11,18 +11,11 @@ import ( type Config struct { k8sconfig.APIConfig `mapstructure:",squash"` ResourceAttributes metadata.ResourceAttributesConfig `mapstructure:"resource_attributes"` - configMapName string - configMapNamespace string } -const defaultConfigMapName = "kubeadm-config" -const defaultConfigMapNamespace = "kube-system" - func CreateDefaultConfig() Config { return Config{ APIConfig: k8sconfig.APIConfig{AuthType: k8sconfig.AuthTypeServiceAccount}, ResourceAttributes: metadata.DefaultResourceAttributesConfig(), - configMapName: defaultConfigMapName, - configMapNamespace: defaultConfigMapNamespace, } } diff --git a/processor/resourcedetectionprocessor/internal/kubeadm/config_test.go b/processor/resourcedetectionprocessor/internal/kubeadm/config_test.go deleted file mode 100644 index 8f07cc90febb..000000000000 --- a/processor/resourcedetectionprocessor/internal/kubeadm/config_test.go +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -package kubeadm - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestUpdateDefaults(t *testing.T) { - cfg := CreateDefaultConfig() - assert.Equal(t, defaultConfigMapName, cfg.configMapName) - assert.Equal(t, defaultConfigMapNamespace, cfg.configMapNamespace) -} diff --git a/processor/resourcedetectionprocessor/internal/kubeadm/kubeadm.go b/processor/resourcedetectionprocessor/internal/kubeadm/kubeadm.go index 41bf2d995763..ca39c6dde262 100644 --- a/processor/resourcedetectionprocessor/internal/kubeadm/kubeadm.go +++ b/processor/resourcedetectionprocessor/internal/kubeadm/kubeadm.go @@ -18,7 +18,9 @@ import ( ) const ( - TypeStr = "kubeadm" + TypeStr = "kubeadm" + defaultConfigMapName = "kubeadm-config" + defaultConfigMapNamespace = "kube-system" ) var _ internal.Detector = (*detector)(nil) @@ -33,7 +35,7 @@ type detector struct { func NewDetector(set processor.Settings, dcfg internal.DetectorConfig) (internal.Detector, error) { cfg := dcfg.(Config) - kubeadmProvider, err := kubeadm.NewProvider(cfg.configMapName, cfg.configMapNamespace, cfg.APIConfig) + kubeadmProvider, err := kubeadm.NewProvider(defaultConfigMapName, defaultConfigMapNamespace, cfg.APIConfig) if err != nil { return nil, fmt.Errorf("failed creating kubeadm provider: %w", err) }