From bd90692550a4e9973296fc2e2fcdc38a3ac48b62 Mon Sep 17 00:00:00 2001 From: Antoine Toulme Date: Thu, 23 May 2024 19:18:24 -0700 Subject: [PATCH] regenerate without using a deprecated method --- .../generated_component_test.go | 2 +- .../metadata/generated_config_test.go | 4 ++-- cmd/mdatagen/templates/component_test.go.tmpl | 10 ++++---- .../generated_component_test.go | 2 +- exporter/debugexporter/config_test.go | 7 +++--- .../debugexporter/generated_component_test.go | 2 +- exporter/loggingexporter/config_test.go | 7 +++--- .../generated_component_test.go | 2 +- .../nopexporter/generated_component_test.go | 2 +- exporter/otlpexporter/config_test.go | 6 ++--- .../otlpexporter/generated_component_test.go | 2 +- exporter/otlphttpexporter/config_test.go | 6 ++--- .../generated_component_test.go | 2 +- extension/ballastextension/config_test.go | 5 ++-- .../generated_component_test.go | 3 +-- .../generated_component_test.go | 3 +-- extension/zpagesextension/config_test.go | 5 ++-- .../generated_component_test.go | 3 +-- internal/memorylimiter/config_test.go | 5 ++-- otelcol/internal/configunmarshaler/configs.go | 2 +- processor/batchprocessor/config_test.go | 5 ++-- .../generated_component_test.go | 2 +- .../generated_component_test.go | 2 +- .../nopreceiver/generated_component_test.go | 2 +- receiver/otlpreceiver/config_test.go | 24 +++++++++---------- .../otlpreceiver/generated_component_test.go | 2 +- 26 files changed, 54 insertions(+), 63 deletions(-) diff --git a/cmd/mdatagen/internal/samplereceiver/generated_component_test.go b/cmd/mdatagen/internal/samplereceiver/generated_component_test.go index af315d20a854..d20ac9b6b4f8 100644 --- a/cmd/mdatagen/internal/samplereceiver/generated_component_test.go +++ b/cmd/mdatagen/internal/samplereceiver/generated_component_test.go @@ -60,7 +60,7 @@ func TestComponentLifecycle(t *testing.T) { cfg := factory.CreateDefaultConfig() sub, err := cm.Sub("tests::config") require.NoError(t, err) - require.NoError(t, component.UnmarshalConfig(sub, cfg)) + require.NoError(t, sub.Unmarshal(&cfg)) for _, test := range tests { t.Run(test.name+"-shutdown", func(t *testing.T) { diff --git a/cmd/mdatagen/internal/samplereceiver/internal/metadata/generated_config_test.go b/cmd/mdatagen/internal/samplereceiver/internal/metadata/generated_config_test.go index 0f581b137f7f..a046fe8059c5 100644 --- a/cmd/mdatagen/internal/samplereceiver/internal/metadata/generated_config_test.go +++ b/cmd/mdatagen/internal/samplereceiver/internal/metadata/generated_config_test.go @@ -84,7 +84,7 @@ func loadMetricsBuilderConfig(t *testing.T, name string) MetricsBuilderConfig { sub, err := cm.Sub(name) require.NoError(t, err) cfg := DefaultMetricsBuilderConfig() - require.NoError(t, component.UnmarshalConfig(sub, &cfg)) + require.NoError(t, sub.Unmarshal(&cfg)) return cfg } @@ -142,6 +142,6 @@ func loadResourceAttributesConfig(t *testing.T, name string) ResourceAttributesC sub, err = sub.Sub("resource_attributes") require.NoError(t, err) cfg := DefaultResourceAttributesConfig() - require.NoError(t, component.UnmarshalConfig(sub, &cfg)) + require.NoError(t, sub.Unmarshal(&cfg)) return cfg } diff --git a/cmd/mdatagen/templates/component_test.go.tmpl b/cmd/mdatagen/templates/component_test.go.tmpl index ca948214d80f..9379f672cab2 100644 --- a/cmd/mdatagen/templates/component_test.go.tmpl +++ b/cmd/mdatagen/templates/component_test.go.tmpl @@ -102,7 +102,7 @@ func TestComponentLifecycle(t *testing.T) { cfg := factory.CreateDefaultConfig() sub, err := cm.Sub("tests::config") require.NoError(t, err) - require.NoError(t, component.UnmarshalConfig(sub, cfg)) + require.NoError(t, sub.Unmarshal(&cfg)) for _, test := range tests { {{- if not .Tests.SkipShutdown }} @@ -199,7 +199,7 @@ func TestComponentLifecycle(t *testing.T) { cfg := factory.CreateDefaultConfig() sub, err := cm.Sub("tests::config") require.NoError(t, err) - require.NoError(t, component.UnmarshalConfig(sub, cfg)) + require.NoError(t, sub.Unmarshal(sub, &cfg)) for _, test := range tests { {{- if not .Tests.SkipShutdown }} @@ -294,7 +294,7 @@ func TestComponentLifecycle(t *testing.T) { cfg := factory.CreateDefaultConfig() sub, err := cm.Sub("tests::config") require.NoError(t, err) - require.NoError(t, component.UnmarshalConfig(sub, cfg)) + require.NoError(t, sub.Unmarshal(&cfg)) for _, test := range tests { {{- if not .Tests.SkipShutdown }} @@ -333,7 +333,7 @@ func TestComponentLifecycle(t *testing.T) { cfg := factory.CreateDefaultConfig() sub, err := cm.Sub("tests::config") require.NoError(t, err) - require.NoError(t, component.UnmarshalConfig(sub, cfg)) + require.NoError(t, sub.Unmarshal(&cfg)) {{- if not .Tests.SkipShutdown }} t.Run("shutdown", func(t *testing.T) { @@ -456,7 +456,7 @@ func TestComponentLifecycle(t *testing.T) { cfg := factory.CreateDefaultConfig() sub, err := cm.Sub("tests::config") require.NoError(t, err) - require.NoError(t, component.UnmarshalConfig(sub, cfg)) + require.NoError(t, sub.Unmarshal(&cfg)) for _, test := range tests { {{- if not .Tests.SkipShutdown }} diff --git a/connector/forwardconnector/generated_component_test.go b/connector/forwardconnector/generated_component_test.go index 9bbe4e5aa5f4..9371aa5a2b25 100644 --- a/connector/forwardconnector/generated_component_test.go +++ b/connector/forwardconnector/generated_component_test.go @@ -63,7 +63,7 @@ func TestComponentLifecycle(t *testing.T) { cfg := factory.CreateDefaultConfig() sub, err := cm.Sub("tests::config") require.NoError(t, err) - require.NoError(t, component.UnmarshalConfig(sub, cfg)) + require.NoError(t, sub.Unmarshal(&cfg)) for _, test := range tests { t.Run(test.name+"-shutdown", func(t *testing.T) { diff --git a/exporter/debugexporter/config_test.go b/exporter/debugexporter/config_test.go index 3e1b2534961d..cefe02964623 100644 --- a/exporter/debugexporter/config_test.go +++ b/exporter/debugexporter/config_test.go @@ -10,7 +10,6 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/config/configtelemetry" "go.opentelemetry.io/collector/confmap" "go.opentelemetry.io/collector/confmap/confmaptest" @@ -19,7 +18,7 @@ import ( func TestUnmarshalDefaultConfig(t *testing.T) { factory := NewFactory() cfg := factory.CreateDefaultConfig() - assert.NoError(t, component.UnmarshalConfig(confmap.New(), cfg)) + assert.NoError(t, confmap.New().Unmarshal(&cfg)) assert.Equal(t, factory.CreateDefaultConfig(), cfg) } @@ -49,7 +48,7 @@ func TestUnmarshalConfig(t *testing.T) { require.NoError(t, err) factory := NewFactory() cfg := factory.CreateDefaultConfig() - err = component.UnmarshalConfig(cm, cfg) + err = cm.Unmarshal(&cfg) if tt.expectedErr != "" { assert.EqualError(t, err, tt.expectedErr) } else { @@ -91,7 +90,7 @@ func Test_UnmarshalMarshalled(t *testing.T) { outCfg := &Config{} - err = component.UnmarshalConfig(conf, outCfg) + err = conf.Unmarshal(outCfg) if tc.expectedErr == "" { assert.NoError(t, err) diff --git a/exporter/debugexporter/generated_component_test.go b/exporter/debugexporter/generated_component_test.go index 3e18e6e887c1..3ae3f1c36072 100644 --- a/exporter/debugexporter/generated_component_test.go +++ b/exporter/debugexporter/generated_component_test.go @@ -63,7 +63,7 @@ func TestComponentLifecycle(t *testing.T) { cfg := factory.CreateDefaultConfig() sub, err := cm.Sub("tests::config") require.NoError(t, err) - require.NoError(t, component.UnmarshalConfig(sub, cfg)) + require.NoError(t, sub.Unmarshal(&cfg)) for _, test := range tests { t.Run(test.name+"-shutdown", func(t *testing.T) { diff --git a/exporter/loggingexporter/config_test.go b/exporter/loggingexporter/config_test.go index ead57851462d..a7f18e6643b9 100644 --- a/exporter/loggingexporter/config_test.go +++ b/exporter/loggingexporter/config_test.go @@ -11,7 +11,6 @@ import ( "github.com/stretchr/testify/require" "go.uber.org/zap/zapcore" - "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/config/configtelemetry" "go.opentelemetry.io/collector/confmap" "go.opentelemetry.io/collector/confmap/confmaptest" @@ -20,7 +19,7 @@ import ( func TestUnmarshalDefaultConfig(t *testing.T) { factory := NewFactory() cfg := factory.CreateDefaultConfig() - assert.NoError(t, component.UnmarshalConfig(confmap.New(), cfg)) + assert.NoError(t, confmap.New().Unmarshal(&cfg)) assert.Equal(t, factory.CreateDefaultConfig(), cfg) } @@ -75,7 +74,7 @@ func TestUnmarshalConfig(t *testing.T) { require.NoError(t, err) factory := NewFactory() cfg := factory.CreateDefaultConfig() - err = component.UnmarshalConfig(cm, cfg) + err = cm.Unmarshal(&cfg) if tt.expectedErr != "" { assert.EqualError(t, err, tt.expectedErr) } else { @@ -135,7 +134,7 @@ func Test_UnmarshalMarshalled(t *testing.T) { outCfg := &Config{} - err = component.UnmarshalConfig(conf, outCfg) + err = conf.Unmarshal(outCfg) if tc.expectedErr == "" { assert.NoError(t, err) diff --git a/exporter/loggingexporter/generated_component_test.go b/exporter/loggingexporter/generated_component_test.go index e5902b96208e..fc2245c31d86 100644 --- a/exporter/loggingexporter/generated_component_test.go +++ b/exporter/loggingexporter/generated_component_test.go @@ -63,7 +63,7 @@ func TestComponentLifecycle(t *testing.T) { cfg := factory.CreateDefaultConfig() sub, err := cm.Sub("tests::config") require.NoError(t, err) - require.NoError(t, component.UnmarshalConfig(sub, cfg)) + require.NoError(t, sub.Unmarshal(&cfg)) for _, test := range tests { t.Run(test.name+"-shutdown", func(t *testing.T) { diff --git a/exporter/nopexporter/generated_component_test.go b/exporter/nopexporter/generated_component_test.go index 675dee1a0eeb..2b65f482fdf2 100644 --- a/exporter/nopexporter/generated_component_test.go +++ b/exporter/nopexporter/generated_component_test.go @@ -63,7 +63,7 @@ func TestComponentLifecycle(t *testing.T) { cfg := factory.CreateDefaultConfig() sub, err := cm.Sub("tests::config") require.NoError(t, err) - require.NoError(t, component.UnmarshalConfig(sub, cfg)) + require.NoError(t, sub.Unmarshal(&cfg)) for _, test := range tests { t.Run(test.name+"-shutdown", func(t *testing.T) { diff --git a/exporter/otlpexporter/config_test.go b/exporter/otlpexporter/config_test.go index 7a644b7ef0ed..2167f803ef3b 100644 --- a/exporter/otlpexporter/config_test.go +++ b/exporter/otlpexporter/config_test.go @@ -25,7 +25,7 @@ import ( func TestUnmarshalDefaultConfig(t *testing.T) { factory := NewFactory() cfg := factory.CreateDefaultConfig() - assert.NoError(t, component.UnmarshalConfig(confmap.New(), cfg)) + assert.NoError(t, confmap.New().Unmarshal(&cfg)) assert.Equal(t, factory.CreateDefaultConfig(), cfg) } @@ -34,7 +34,7 @@ func TestUnmarshalConfig(t *testing.T) { require.NoError(t, err) factory := NewFactory() cfg := factory.CreateDefaultConfig() - assert.NoError(t, component.UnmarshalConfig(cm, cfg)) + assert.NoError(t, cm.Unmarshal(&cfg)) assert.Equal(t, &Config{ TimeoutSettings: exporterhelper.TimeoutSettings{ @@ -124,7 +124,7 @@ func TestUnmarshalInvalidConfig(t *testing.T) { cfg := factory.CreateDefaultConfig() sub, err := cm.Sub(test.name) require.NoError(t, err) - assert.NoError(t, component.UnmarshalConfig(sub, cfg)) + assert.NoError(t, sub.Unmarshal(&cfg)) assert.ErrorContains(t, component.ValidateConfig(cfg), test.errorMsg) }) } diff --git a/exporter/otlpexporter/generated_component_test.go b/exporter/otlpexporter/generated_component_test.go index 27a3b7da3d09..7a410496a466 100644 --- a/exporter/otlpexporter/generated_component_test.go +++ b/exporter/otlpexporter/generated_component_test.go @@ -63,7 +63,7 @@ func TestComponentLifecycle(t *testing.T) { cfg := factory.CreateDefaultConfig() sub, err := cm.Sub("tests::config") require.NoError(t, err) - require.NoError(t, component.UnmarshalConfig(sub, cfg)) + require.NoError(t, sub.Unmarshal(&cfg)) for _, test := range tests { t.Run(test.name+"-shutdown", func(t *testing.T) { diff --git a/exporter/otlphttpexporter/config_test.go b/exporter/otlphttpexporter/config_test.go index e158891dd75b..9a9e261308f5 100644 --- a/exporter/otlphttpexporter/config_test.go +++ b/exporter/otlphttpexporter/config_test.go @@ -24,7 +24,7 @@ import ( func TestUnmarshalDefaultConfig(t *testing.T) { factory := NewFactory() cfg := factory.CreateDefaultConfig() - assert.NoError(t, component.UnmarshalConfig(confmap.New(), cfg)) + assert.NoError(t, confmap.New().Unmarshal(&cfg)) assert.Equal(t, factory.CreateDefaultConfig(), cfg) // Default/Empty config is invalid. assert.Error(t, component.ValidateConfig(cfg)) @@ -35,7 +35,7 @@ func TestUnmarshalConfig(t *testing.T) { require.NoError(t, err) factory := NewFactory() cfg := factory.CreateDefaultConfig() - assert.NoError(t, component.UnmarshalConfig(cm, cfg)) + assert.NoError(t, cm.Unmarshal(&cfg)) assert.Equal(t, &Config{ RetryConfig: configretry.BackOffConfig{ @@ -80,7 +80,7 @@ func TestUnmarshalConfigInvalidEncoding(t *testing.T) { require.NoError(t, err) factory := NewFactory() cfg := factory.CreateDefaultConfig() - assert.Error(t, component.UnmarshalConfig(cm, cfg)) + assert.Error(t, cm.Unmarshal(&cfg)) } func TestUnmarshalEncoding(t *testing.T) { diff --git a/exporter/otlphttpexporter/generated_component_test.go b/exporter/otlphttpexporter/generated_component_test.go index 443b94841b43..c378698b41e6 100644 --- a/exporter/otlphttpexporter/generated_component_test.go +++ b/exporter/otlphttpexporter/generated_component_test.go @@ -63,7 +63,7 @@ func TestComponentLifecycle(t *testing.T) { cfg := factory.CreateDefaultConfig() sub, err := cm.Sub("tests::config") require.NoError(t, err) - require.NoError(t, component.UnmarshalConfig(sub, cfg)) + require.NoError(t, sub.Unmarshal(&cfg)) for _, test := range tests { t.Run(test.name+"-shutdown", func(t *testing.T) { diff --git a/extension/ballastextension/config_test.go b/extension/ballastextension/config_test.go index 4d23c5ebc392..25e3223fe450 100644 --- a/extension/ballastextension/config_test.go +++ b/extension/ballastextension/config_test.go @@ -10,7 +10,6 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/confmap" "go.opentelemetry.io/collector/confmap/confmaptest" ) @@ -18,7 +17,7 @@ import ( func TestUnmarshalDefaultConfig(t *testing.T) { factory := NewFactory() cfg := factory.CreateDefaultConfig() - assert.NoError(t, component.UnmarshalConfig(confmap.New(), cfg)) + assert.NoError(t, confmap.New().Unmarshal(&cfg)) assert.Equal(t, factory.CreateDefaultConfig(), cfg) } @@ -27,7 +26,7 @@ func TestUnmarshalConfig(t *testing.T) { require.NoError(t, err) factory := NewFactory() cfg := factory.CreateDefaultConfig() - assert.NoError(t, component.UnmarshalConfig(cm, cfg)) + assert.NoError(t, cm.Unmarshal(&cfg)) assert.Equal(t, &Config{ SizeMiB: 123, diff --git a/extension/ballastextension/generated_component_test.go b/extension/ballastextension/generated_component_test.go index 779e5631778d..2e685378c41e 100644 --- a/extension/ballastextension/generated_component_test.go +++ b/extension/ballastextension/generated_component_test.go @@ -8,7 +8,6 @@ import ( "github.com/stretchr/testify/require" - "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/component/componenttest" "go.opentelemetry.io/collector/confmap/confmaptest" "go.opentelemetry.io/collector/extension/extensiontest" @@ -30,7 +29,7 @@ func TestComponentLifecycle(t *testing.T) { cfg := factory.CreateDefaultConfig() sub, err := cm.Sub("tests::config") require.NoError(t, err) - require.NoError(t, component.UnmarshalConfig(sub, cfg)) + require.NoError(t, sub.Unmarshal(&cfg)) t.Run("shutdown", func(t *testing.T) { e, err := factory.CreateExtension(context.Background(), extensiontest.NewNopCreateSettings(), cfg) require.NoError(t, err) diff --git a/extension/memorylimiterextension/generated_component_test.go b/extension/memorylimiterextension/generated_component_test.go index 7580d8a30c9e..b410b246b94b 100644 --- a/extension/memorylimiterextension/generated_component_test.go +++ b/extension/memorylimiterextension/generated_component_test.go @@ -8,7 +8,6 @@ import ( "github.com/stretchr/testify/require" - "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/component/componenttest" "go.opentelemetry.io/collector/confmap/confmaptest" "go.opentelemetry.io/collector/extension/extensiontest" @@ -30,7 +29,7 @@ func TestComponentLifecycle(t *testing.T) { cfg := factory.CreateDefaultConfig() sub, err := cm.Sub("tests::config") require.NoError(t, err) - require.NoError(t, component.UnmarshalConfig(sub, cfg)) + require.NoError(t, sub.Unmarshal(&cfg)) t.Run("lifecycle", func(t *testing.T) { firstExt, err := factory.CreateExtension(context.Background(), extensiontest.NewNopCreateSettings(), cfg) require.NoError(t, err) diff --git a/extension/zpagesextension/config_test.go b/extension/zpagesextension/config_test.go index f79e74d25c9c..f73b9744b0e1 100644 --- a/extension/zpagesextension/config_test.go +++ b/extension/zpagesextension/config_test.go @@ -10,7 +10,6 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/config/confignet" "go.opentelemetry.io/collector/confmap" "go.opentelemetry.io/collector/confmap/confmaptest" @@ -19,7 +18,7 @@ import ( func TestUnmarshalDefaultConfig(t *testing.T) { factory := NewFactory() cfg := factory.CreateDefaultConfig() - assert.NoError(t, component.UnmarshalConfig(confmap.New(), cfg)) + assert.NoError(t, confmap.New().Unmarshal(&cfg)) assert.Equal(t, factory.CreateDefaultConfig(), cfg) } @@ -28,7 +27,7 @@ func TestUnmarshalConfig(t *testing.T) { require.NoError(t, err) factory := NewFactory() cfg := factory.CreateDefaultConfig() - assert.NoError(t, component.UnmarshalConfig(cm, cfg)) + assert.NoError(t, cm.Unmarshal(&cfg)) assert.Equal(t, &Config{ TCPAddr: confignet.TCPAddrConfig{ diff --git a/extension/zpagesextension/generated_component_test.go b/extension/zpagesextension/generated_component_test.go index df6ede48a056..8caba7a6d95d 100644 --- a/extension/zpagesextension/generated_component_test.go +++ b/extension/zpagesextension/generated_component_test.go @@ -8,7 +8,6 @@ import ( "github.com/stretchr/testify/require" - "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/component/componenttest" "go.opentelemetry.io/collector/confmap/confmaptest" "go.opentelemetry.io/collector/extension/extensiontest" @@ -30,7 +29,7 @@ func TestComponentLifecycle(t *testing.T) { cfg := factory.CreateDefaultConfig() sub, err := cm.Sub("tests::config") require.NoError(t, err) - require.NoError(t, component.UnmarshalConfig(sub, cfg)) + require.NoError(t, sub.Unmarshal(&cfg)) t.Run("shutdown", func(t *testing.T) { e, err := factory.CreateExtension(context.Background(), extensiontest.NewNopCreateSettings(), cfg) require.NoError(t, err) diff --git a/internal/memorylimiter/config_test.go b/internal/memorylimiter/config_test.go index 29db1dc6defb..032f4798988d 100644 --- a/internal/memorylimiter/config_test.go +++ b/internal/memorylimiter/config_test.go @@ -11,7 +11,6 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/confmap/confmaptest" ) @@ -19,7 +18,7 @@ func TestUnmarshalConfig(t *testing.T) { cm, err := confmaptest.LoadConf(filepath.Join("testdata", "config.yaml")) require.NoError(t, err) cfg := &Config{} - assert.NoError(t, component.UnmarshalConfig(cm, cfg)) + assert.NoError(t, cm.Unmarshal(&cfg)) assert.Equal(t, &Config{ CheckInterval: 5 * time.Second, @@ -98,7 +97,7 @@ func TestUnmarshalInvalidConfig(t *testing.T) { cm, err := confmaptest.LoadConf(filepath.Join("testdata", "negative_unsigned_limits_config.yaml")) require.NoError(t, err) cfg := &Config{} - err = component.UnmarshalConfig(cm, cfg) + err = cm.Unmarshal(&cfg) require.Error(t, err) require.Contains(t, err.Error(), "error decoding 'limit_mib': cannot convert negative value -2000 to an unsigned integer") require.Contains(t, err.Error(), "error decoding 'spike_limit_mib': cannot convert negative value -2300 to an unsigned integer") diff --git a/otelcol/internal/configunmarshaler/configs.go b/otelcol/internal/configunmarshaler/configs.go index 05cc8b112963..7f864fdfd32a 100644 --- a/otelcol/internal/configunmarshaler/configs.go +++ b/otelcol/internal/configunmarshaler/configs.go @@ -43,7 +43,7 @@ func (c *Configs[F]) Unmarshal(conf *confmap.Conf) error { // Now that the default config struct is created we can Unmarshal into it, // and it will apply user-defined config on top of the default. - if err := component.UnmarshalConfig(confmap.NewFromStringMap(value), cfg); err != nil { + if err := confmap.NewFromStringMap(value).Unmarshal(&cfg); err != nil { return errorUnmarshalError(id, err) } diff --git a/processor/batchprocessor/config_test.go b/processor/batchprocessor/config_test.go index 981f28a97fa7..c5d3f693f929 100644 --- a/processor/batchprocessor/config_test.go +++ b/processor/batchprocessor/config_test.go @@ -11,7 +11,6 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/confmap" "go.opentelemetry.io/collector/confmap/confmaptest" ) @@ -19,7 +18,7 @@ import ( func TestUnmarshalDefaultConfig(t *testing.T) { factory := NewFactory() cfg := factory.CreateDefaultConfig() - assert.NoError(t, component.UnmarshalConfig(confmap.New(), cfg)) + assert.NoError(t, confmap.New().Unmarshal(&cfg)) assert.Equal(t, factory.CreateDefaultConfig(), cfg) } @@ -28,7 +27,7 @@ func TestUnmarshalConfig(t *testing.T) { require.NoError(t, err) factory := NewFactory() cfg := factory.CreateDefaultConfig() - assert.NoError(t, component.UnmarshalConfig(cm, cfg)) + assert.NoError(t, cm.Unmarshal(&cfg)) assert.Equal(t, &Config{ SendBatchSize: uint32(10000), diff --git a/processor/batchprocessor/generated_component_test.go b/processor/batchprocessor/generated_component_test.go index 656dad9986b1..2e8f51f9c896 100644 --- a/processor/batchprocessor/generated_component_test.go +++ b/processor/batchprocessor/generated_component_test.go @@ -64,7 +64,7 @@ func TestComponentLifecycle(t *testing.T) { cfg := factory.CreateDefaultConfig() sub, err := cm.Sub("tests::config") require.NoError(t, err) - require.NoError(t, component.UnmarshalConfig(sub, cfg)) + require.NoError(t, sub.Unmarshal(sub, &cfg)) for _, test := range tests { t.Run(test.name+"-shutdown", func(t *testing.T) { diff --git a/processor/memorylimiterprocessor/generated_component_test.go b/processor/memorylimiterprocessor/generated_component_test.go index 7144d4a3901b..a2b46532b211 100644 --- a/processor/memorylimiterprocessor/generated_component_test.go +++ b/processor/memorylimiterprocessor/generated_component_test.go @@ -64,7 +64,7 @@ func TestComponentLifecycle(t *testing.T) { cfg := factory.CreateDefaultConfig() sub, err := cm.Sub("tests::config") require.NoError(t, err) - require.NoError(t, component.UnmarshalConfig(sub, cfg)) + require.NoError(t, sub.Unmarshal(sub, &cfg)) for _, test := range tests { t.Run(test.name+"-lifecycle", func(t *testing.T) { diff --git a/receiver/nopreceiver/generated_component_test.go b/receiver/nopreceiver/generated_component_test.go index 14f8840b1e7f..92e563ad6456 100644 --- a/receiver/nopreceiver/generated_component_test.go +++ b/receiver/nopreceiver/generated_component_test.go @@ -59,7 +59,7 @@ func TestComponentLifecycle(t *testing.T) { cfg := factory.CreateDefaultConfig() sub, err := cm.Sub("tests::config") require.NoError(t, err) - require.NoError(t, component.UnmarshalConfig(sub, cfg)) + require.NoError(t, sub.Unmarshal(&cfg)) for _, test := range tests { t.Run(test.name+"-shutdown", func(t *testing.T) { diff --git a/receiver/otlpreceiver/config_test.go b/receiver/otlpreceiver/config_test.go index 9604d5078126..3059f97471d8 100644 --- a/receiver/otlpreceiver/config_test.go +++ b/receiver/otlpreceiver/config_test.go @@ -25,7 +25,7 @@ func TestUnmarshalDefaultConfig(t *testing.T) { require.NoError(t, err) factory := NewFactory() cfg := factory.CreateDefaultConfig() - assert.NoError(t, component.UnmarshalConfig(cm, cfg)) + assert.NoError(t, cm.Unmarshal(&cfg)) assert.Equal(t, factory.CreateDefaultConfig(), cfg) } @@ -34,7 +34,7 @@ func TestUnmarshalConfigOnlyGRPC(t *testing.T) { require.NoError(t, err) factory := NewFactory() cfg := factory.CreateDefaultConfig() - assert.NoError(t, component.UnmarshalConfig(cm, cfg)) + assert.NoError(t, cm.Unmarshal(&cfg)) defaultOnlyGRPC := factory.CreateDefaultConfig().(*Config) defaultOnlyGRPC.HTTP = nil @@ -46,7 +46,7 @@ func TestUnmarshalConfigOnlyHTTP(t *testing.T) { require.NoError(t, err) factory := NewFactory() cfg := factory.CreateDefaultConfig() - assert.NoError(t, component.UnmarshalConfig(cm, cfg)) + assert.NoError(t, cm.Unmarshal(&cfg)) defaultOnlyHTTP := factory.CreateDefaultConfig().(*Config) defaultOnlyHTTP.GRPC = nil @@ -58,7 +58,7 @@ func TestUnmarshalConfigOnlyHTTPNull(t *testing.T) { require.NoError(t, err) factory := NewFactory() cfg := factory.CreateDefaultConfig() - assert.NoError(t, component.UnmarshalConfig(cm, cfg)) + assert.NoError(t, cm.Unmarshal(&cfg)) defaultOnlyHTTP := factory.CreateDefaultConfig().(*Config) defaultOnlyHTTP.GRPC = nil @@ -70,7 +70,7 @@ func TestUnmarshalConfigOnlyHTTPEmptyMap(t *testing.T) { require.NoError(t, err) factory := NewFactory() cfg := factory.CreateDefaultConfig() - assert.NoError(t, component.UnmarshalConfig(cm, cfg)) + assert.NoError(t, cm.Unmarshal(&cfg)) defaultOnlyHTTP := factory.CreateDefaultConfig().(*Config) defaultOnlyHTTP.GRPC = nil @@ -82,7 +82,7 @@ func TestUnmarshalConfig(t *testing.T) { require.NoError(t, err) factory := NewFactory() cfg := factory.CreateDefaultConfig() - assert.NoError(t, component.UnmarshalConfig(cm, cfg)) + assert.NoError(t, cm.Unmarshal(&cfg)) assert.Equal(t, &Config{ Protocols: Protocols{ @@ -143,7 +143,7 @@ func TestUnmarshalConfigUnix(t *testing.T) { require.NoError(t, err) factory := NewFactory() cfg := factory.CreateDefaultConfig() - assert.NoError(t, component.UnmarshalConfig(cm, cfg)) + assert.NoError(t, cm.Unmarshal(&cfg)) assert.Equal(t, &Config{ Protocols: Protocols{ @@ -171,7 +171,7 @@ func TestUnmarshalConfigTypoDefaultProtocol(t *testing.T) { require.NoError(t, err) factory := NewFactory() cfg := factory.CreateDefaultConfig() - assert.EqualError(t, component.UnmarshalConfig(cm, cfg), "1 error(s) decoding:\n\n* 'protocols' has invalid keys: htttp") + assert.EqualError(t, cm.Unmarshal(&cfg), "1 error(s) decoding:\n\n* 'protocols' has invalid keys: htttp") } func TestUnmarshalConfigInvalidProtocol(t *testing.T) { @@ -179,7 +179,7 @@ func TestUnmarshalConfigInvalidProtocol(t *testing.T) { require.NoError(t, err) factory := NewFactory() cfg := factory.CreateDefaultConfig() - assert.EqualError(t, component.UnmarshalConfig(cm, cfg), "1 error(s) decoding:\n\n* 'protocols' has invalid keys: thrift") + assert.EqualError(t, cm.Unmarshal(&cfg), "1 error(s) decoding:\n\n* 'protocols' has invalid keys: thrift") } func TestUnmarshalConfigEmptyProtocols(t *testing.T) { @@ -187,7 +187,7 @@ func TestUnmarshalConfigEmptyProtocols(t *testing.T) { require.NoError(t, err) factory := NewFactory() cfg := factory.CreateDefaultConfig() - assert.NoError(t, component.UnmarshalConfig(cm, cfg)) + assert.NoError(t, cm.Unmarshal(&cfg)) assert.EqualError(t, component.ValidateConfig(cfg), "must specify at least one protocol when using the OTLP receiver") } @@ -216,7 +216,7 @@ func TestUnmarshalConfigInvalidSignalPath(t *testing.T) { require.NoError(t, err) factory := NewFactory() cfg := factory.CreateDefaultConfig() - assert.EqualError(t, component.UnmarshalConfig(cm, cfg), "invalid HTTP URL path set for signal: parse \":invalid\": missing protocol scheme") + assert.EqualError(t, cm.Unmarshal(&cfg), "invalid HTTP URL path set for signal: parse \":invalid\": missing protocol scheme") }) } } @@ -224,6 +224,6 @@ func TestUnmarshalConfigInvalidSignalPath(t *testing.T) { func TestUnmarshalConfigEmpty(t *testing.T) { factory := NewFactory() cfg := factory.CreateDefaultConfig() - assert.NoError(t, component.UnmarshalConfig(confmap.New(), cfg)) + assert.NoError(t, confmap.New().Unmarshal(&cfg)) assert.EqualError(t, component.ValidateConfig(cfg), "must specify at least one protocol when using the OTLP receiver") } diff --git a/receiver/otlpreceiver/generated_component_test.go b/receiver/otlpreceiver/generated_component_test.go index e4c99be47ac4..0f54074cff2b 100644 --- a/receiver/otlpreceiver/generated_component_test.go +++ b/receiver/otlpreceiver/generated_component_test.go @@ -59,7 +59,7 @@ func TestComponentLifecycle(t *testing.T) { cfg := factory.CreateDefaultConfig() sub, err := cm.Sub("tests::config") require.NoError(t, err) - require.NoError(t, component.UnmarshalConfig(sub, cfg)) + require.NoError(t, sub.Unmarshal(&cfg)) for _, test := range tests { t.Run(test.name+"-shutdown", func(t *testing.T) {