From 57d8f0147bcc3f6cbe09d37b109e42b5d57b8c5b Mon Sep 17 00:00:00 2001 From: Bogdan Drutu Date: Wed, 3 Mar 2021 08:53:21 -0800 Subject: [PATCH] Remove support for deprecated unmarshaler Updates https://github.com/open-telemetry/opentelemetry-collector/issues/2540 Signed-off-by: Bogdan Drutu --- CHANGELOG.md | 1 + component/componenttest/example_factories.go | 13 +++---------- config/config.go | 16 ---------------- 3 files changed, 4 insertions(+), 26 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b9056d019b9..f4a528cc049 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - Remove `consumerdata.TraceData` (#2551) - Move `consumerdata.MetricsData` to `internaldata.MetricsData` (#2512) - Remove custom OpenCensus sematic conventions that have equivalent in otel (#2552) +- Remove support for deprecated unmarshaler `CustomUnmarshaler`, only `Unmarshal` is supported (#2591) ## v0.21.0 Beta diff --git a/component/componenttest/example_factories.go b/component/componenttest/example_factories.go index c79f7bed5b0..07688bbeb64 100644 --- a/component/componenttest/example_factories.go +++ b/component/componenttest/example_factories.go @@ -73,11 +73,6 @@ func (f *ExampleReceiverFactory) CreateDefaultConfig() configmodels.Receiver { } } -// CustomUnmarshaler implements the deprecated way to provide custom unmarshalers. -func (f *ExampleReceiverFactory) CustomUnmarshaler() component.CustomUnmarshaler { - return nil -} - // CreateTraceReceiver creates a trace receiver based on this config. func (f *ExampleReceiverFactory) CreateTracesReceiver( _ context.Context, @@ -280,11 +275,9 @@ func (f *ExampleExporterFactory) CreateDefaultConfig() configmodels.Exporter { } } -// CustomUnmarshaler implements the deprecated way to provide custom unmarshalers. -func (f *ExampleExporterFactory) CustomUnmarshaler() component.CustomUnmarshaler { - return func(componentViperSection *viper.Viper, intoCfg interface{}) error { - return componentViperSection.UnmarshalExact(intoCfg) - } +// Unmarshal implements the custom unmarshalers. +func (f *ExampleExporterFactory) Unmarshal(componentViperSection *viper.Viper, intoCfg interface{}) error { + return componentViperSection.UnmarshalExact(intoCfg) } // CreateTracesExporter creates a trace exporter based on this config. diff --git a/config/config.go b/config/config.go index 5bbfcd0669c..d93cba25487 100644 --- a/config/config.go +++ b/config/config.go @@ -105,14 +105,6 @@ type pipelineSettings struct { Exporters []string `mapstructure:"exporters"` } -// deprecatedUnmarshaler is the old/deprecated way to provide custom unmarshaler. -type deprecatedUnmarshaler interface { - // CustomUnmarshaler returns a custom unmarshaler for the configuration or nil if - // there is no need for custom unmarshaling. This is typically used if viper.UnmarshalExact() - // is not sufficient to unmarshal correctly. - CustomUnmarshaler() component.CustomUnmarshaler -} - // typeAndNameSeparator is the separator that is used between type and name in type/name composite keys. const typeAndNameSeparator = "/" @@ -736,14 +728,6 @@ func unmarshaler(factory component.Factory) component.CustomUnmarshaler { if fu, ok := factory.(component.ConfigUnmarshaler); ok { return fu.Unmarshal } - - if du, ok := factory.(deprecatedUnmarshaler); ok { - cu := du.CustomUnmarshaler() - if cu != nil { - return cu - } - } - return defaultUnmarshaler }