From 798ac2eb6cd48d0c0c76bfee3a74d610f48ab3d5 Mon Sep 17 00:00:00 2001 From: Bogdan Drutu Date: Tue, 5 Apr 2022 10:35:06 -0700 Subject: [PATCH] Deprecate configunmarshaler package, move it to internal Folllowup: * When the deprecated funcs/types are removed the internal package can be moved to service/internal. * Part of https://github.com/open-telemetry/opentelemetry-collector/pull/4936 do not offer ability to configure ConfigUnmarshaler. Motivation: This package is removed because with the latest addition of the `service.ConfigProvider` the usecase to change the unmarshaled config.Config can be achieved by wrapping/implementing that interface, so no clear use-case for this. In the future we can expose it again if we have good reasons. Updates https://github.com/open-telemetry/opentelemetry-collector/issues/4605 Signed-off-by: Bogdan Drutu --- CHANGELOG.md | 2 ++ config/common.go | 9 ++++++ config/configunmarshaler/unmarshaler.go | 16 ++++++---- config/exporter.go | 7 ++++ config/extension.go | 7 ++++ config/processor.go | 7 ++++ config/receiver.go | 7 ++++ .../configunmarshaler/defaultunmarshaler.go | 32 +++++++++---------- .../defaultunmarshaler_test.go | 0 .../testdata/duplicate-exporter.yaml | 0 .../testdata/duplicate-extension.yaml | 0 .../testdata/duplicate-pipeline.yaml | 0 .../testdata/duplicate-processor.yaml | 0 .../testdata/duplicate-receiver.yaml | 0 .../testdata/empty-all-sections.yaml | 0 .../testdata/empty-config.yaml | 0 .../invalid-exporter-name-after-slash.yaml | 0 .../testdata/invalid-exporter-section.yaml | 0 .../testdata/invalid-exporter-sub-config.yaml | 0 .../testdata/invalid-exporter-type.yaml | 0 .../invalid-extension-name-after-slash.yaml | 0 .../testdata/invalid-extension-section.yaml | 0 .../invalid-extension-sub-config.yaml | 0 .../testdata/invalid-extension-type.yaml | 0 .../testdata/invalid-logs-level.yaml | 0 .../testdata/invalid-metrics-level.yaml | 0 .../invalid-pipeline-name-after-slash.yaml | 0 .../testdata/invalid-pipeline-section.yaml | 0 .../testdata/invalid-pipeline-sub-config.yaml | 0 .../testdata/invalid-pipeline-type.yaml | 0 .../invalid-processor-name-after-slash.yaml | 0 .../testdata/invalid-processor-section.yaml | 0 .../invalid-processor-sub-config.yaml | 0 .../testdata/invalid-processor-type.yaml | 0 .../invalid-receiver-name-after-slash.yaml | 0 .../testdata/invalid-receiver-section.yaml | 0 .../testdata/invalid-receiver-sub-config.yaml | 0 .../testdata/invalid-receiver-type.yaml | 0 .../testdata/invalid-sequence-value.yaml | 0 .../invalid-service-extensions-section.yaml | 0 .../testdata/invalid-service-section.yaml | 0 .../testdata/invalid-top-level-section.yaml | 0 .../testdata/unknown-exporter-type.yaml | 0 .../testdata/unknown-extension-type.yaml | 0 .../testdata/unknown-pipeline-type.yaml | 0 .../testdata/unknown-processor-type.yaml | 0 .../testdata/unknown-receiver-type.yaml | 0 .../testdata/valid-config.yaml | 0 service/config_provider.go | 5 ++- service/config_provider_test.go | 2 +- 50 files changed, 68 insertions(+), 26 deletions(-) create mode 100644 config/common.go rename {config => internal}/configunmarshaler/defaultunmarshaler.go (91%) rename {config => internal}/configunmarshaler/defaultunmarshaler_test.go (100%) rename {config => internal}/configunmarshaler/testdata/duplicate-exporter.yaml (100%) rename {config => internal}/configunmarshaler/testdata/duplicate-extension.yaml (100%) rename {config => internal}/configunmarshaler/testdata/duplicate-pipeline.yaml (100%) rename {config => internal}/configunmarshaler/testdata/duplicate-processor.yaml (100%) rename {config => internal}/configunmarshaler/testdata/duplicate-receiver.yaml (100%) rename {config => internal}/configunmarshaler/testdata/empty-all-sections.yaml (100%) rename {config => internal}/configunmarshaler/testdata/empty-config.yaml (100%) rename {config => internal}/configunmarshaler/testdata/invalid-exporter-name-after-slash.yaml (100%) rename {config => internal}/configunmarshaler/testdata/invalid-exporter-section.yaml (100%) rename {config => internal}/configunmarshaler/testdata/invalid-exporter-sub-config.yaml (100%) rename {config => internal}/configunmarshaler/testdata/invalid-exporter-type.yaml (100%) rename {config => internal}/configunmarshaler/testdata/invalid-extension-name-after-slash.yaml (100%) rename {config => internal}/configunmarshaler/testdata/invalid-extension-section.yaml (100%) rename {config => internal}/configunmarshaler/testdata/invalid-extension-sub-config.yaml (100%) rename {config => internal}/configunmarshaler/testdata/invalid-extension-type.yaml (100%) rename {config => internal}/configunmarshaler/testdata/invalid-logs-level.yaml (100%) rename {config => internal}/configunmarshaler/testdata/invalid-metrics-level.yaml (100%) rename {config => internal}/configunmarshaler/testdata/invalid-pipeline-name-after-slash.yaml (100%) rename {config => internal}/configunmarshaler/testdata/invalid-pipeline-section.yaml (100%) rename {config => internal}/configunmarshaler/testdata/invalid-pipeline-sub-config.yaml (100%) rename {config => internal}/configunmarshaler/testdata/invalid-pipeline-type.yaml (100%) rename {config => internal}/configunmarshaler/testdata/invalid-processor-name-after-slash.yaml (100%) rename {config => internal}/configunmarshaler/testdata/invalid-processor-section.yaml (100%) rename {config => internal}/configunmarshaler/testdata/invalid-processor-sub-config.yaml (100%) rename {config => internal}/configunmarshaler/testdata/invalid-processor-type.yaml (100%) rename {config => internal}/configunmarshaler/testdata/invalid-receiver-name-after-slash.yaml (100%) rename {config => internal}/configunmarshaler/testdata/invalid-receiver-section.yaml (100%) rename {config => internal}/configunmarshaler/testdata/invalid-receiver-sub-config.yaml (100%) rename {config => internal}/configunmarshaler/testdata/invalid-receiver-type.yaml (100%) rename {config => internal}/configunmarshaler/testdata/invalid-sequence-value.yaml (100%) rename {config => internal}/configunmarshaler/testdata/invalid-service-extensions-section.yaml (100%) rename {config => internal}/configunmarshaler/testdata/invalid-service-section.yaml (100%) rename {config => internal}/configunmarshaler/testdata/invalid-top-level-section.yaml (100%) rename {config => internal}/configunmarshaler/testdata/unknown-exporter-type.yaml (100%) rename {config => internal}/configunmarshaler/testdata/unknown-extension-type.yaml (100%) rename {config => internal}/configunmarshaler/testdata/unknown-pipeline-type.yaml (100%) rename {config => internal}/configunmarshaler/testdata/unknown-processor-type.yaml (100%) rename {config => internal}/configunmarshaler/testdata/unknown-receiver-type.yaml (100%) rename {config => internal}/configunmarshaler/testdata/valid-config.yaml (100%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 138846a725b..0d9728d27cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,8 @@ ### 🚩 Deprecations 🚩 +- Deprecate `configunmarshaler` package, move it to internal (#5151) + ### 💡 Enhancements 💡 - OTLP HTTP receiver will use HTTP/2 over TLS if client supports it (#5190) diff --git a/config/common.go b/config/common.go new file mode 100644 index 00000000000..d02fb1109be --- /dev/null +++ b/config/common.go @@ -0,0 +1,9 @@ +package config + +func unmarshal(componentSection *Map, intoCfg interface{}) error { + if cu, ok := intoCfg.(Unmarshallable); ok { + return cu.Unmarshal(componentSection) + } + + return componentSection.UnmarshalExact(intoCfg) +} diff --git a/config/configunmarshaler/unmarshaler.go b/config/configunmarshaler/unmarshaler.go index 7c649e70440..044392f0a71 100644 --- a/config/configunmarshaler/unmarshaler.go +++ b/config/configunmarshaler/unmarshaler.go @@ -15,12 +15,14 @@ package configunmarshaler // import "go.opentelemetry.io/collector/config/configunmarshaler" import ( - "go.opentelemetry.io/collector/component" - "go.opentelemetry.io/collector/config" + "go.opentelemetry.io/collector/internal/configunmarshaler" ) -// ConfigUnmarshaler is the interface that unmarshalls the collector configuration from the config.Map. -type ConfigUnmarshaler interface { - // Unmarshal the configuration from the given parser and factories. - Unmarshal(v *config.Map, factories component.Factories) (*config.Config, error) -} +// Deprecated: if you need to update the config.Config implement custom (or wrap) service.ConfigProvider. +type ConfigUnmarshaler = configunmarshaler.ConfigUnmarshaler + +// Deprecated: not needed since interface will be removed. +var NewDefault = configunmarshaler.NewDefault + +// Deprecated: use config.UnmarshalReceiver. +var LoadReceiver = configunmarshaler.LoadReceiver diff --git a/config/exporter.go b/config/exporter.go index 3bba3874c99..a63e93318ce 100644 --- a/config/exporter.go +++ b/config/exporter.go @@ -23,6 +23,13 @@ type Exporter interface { privateConfigExporter() } +// UnmarshalExporter helper function to unmarshal an Exporter config. +// It checks if the config implements Unmarshallable and uses that if needed. +// It uses Map.UnmarshalExact, if +func UnmarshalExporter(cfgMap *Map, cfg Exporter) error { + return unmarshal(cfgMap, cfg) +} + // ExporterSettings defines common settings for a component.Exporter configuration. // Specific exporters can embed this struct and extend it with more fields if needed. // diff --git a/config/extension.go b/config/extension.go index 44d87c8d86b..c66e59ae655 100644 --- a/config/extension.go +++ b/config/extension.go @@ -23,6 +23,13 @@ type Extension interface { privateConfigExtension() } +// UnmarshalExtension helper function to unmarshal an Extension config. +// It checks if the config implements Unmarshallable and uses that if needed. +// It uses Map.UnmarshalExact, if +func UnmarshalExtension(cfgMap *Map, cfg Extension) error { + return unmarshal(cfgMap, cfg) +} + // ExtensionSettings defines common settings for a component.Extension configuration. // Specific processors can embed this struct and extend it with more fields if needed. // diff --git a/config/processor.go b/config/processor.go index 212ba32ac17..fe5dc2d8cb6 100644 --- a/config/processor.go +++ b/config/processor.go @@ -23,6 +23,13 @@ type Processor interface { privateConfigProcessor() } +// UnmarshalProcessor helper function to unmarshal a Processor config. +// It checks if the config implements Unmarshallable and uses that if needed. +// It uses Map.UnmarshalExact, if +func UnmarshalProcessor(cfgMap *Map, cfg Processor) error { + return unmarshal(cfgMap, cfg) +} + // ProcessorSettings defines common settings for a component.Processor configuration. // Specific processors can embed this struct and extend it with more fields if needed. // diff --git a/config/receiver.go b/config/receiver.go index 5935b78d59a..cea55d39a7e 100644 --- a/config/receiver.go +++ b/config/receiver.go @@ -23,6 +23,13 @@ type Receiver interface { privateConfigReceiver() } +// UnmarshalReceiver helper function to unmarshal a Receiver config. +// It checks if the config implements Unmarshallable and uses that if needed. +// It uses Map.UnmarshalExact, if +func UnmarshalReceiver(cfgMap *Map, cfg Receiver) error { + return unmarshal(cfgMap, cfg) +} + // ReceiverSettings defines common settings for a component.Receiver configuration. // Specific receivers can embed this struct and extend it with more fields if needed. // diff --git a/config/configunmarshaler/defaultunmarshaler.go b/internal/configunmarshaler/defaultunmarshaler.go similarity index 91% rename from config/configunmarshaler/defaultunmarshaler.go rename to internal/configunmarshaler/defaultunmarshaler.go index 7956b54a0f7..3ea9f4a682b 100644 --- a/config/configunmarshaler/defaultunmarshaler.go +++ b/internal/configunmarshaler/defaultunmarshaler.go @@ -25,6 +25,12 @@ import ( "go.opentelemetry.io/collector/config/configtelemetry" ) +// ConfigUnmarshaler is the interface that unmarshalls the collector configuration from the config.Map. +type ConfigUnmarshaler interface { + // Unmarshal the configuration from the given parser and factories. + Unmarshal(v *config.Map, factories component.Factories) (*config.Config, error) +} + // These are errors that can be returned by Unmarshal(). Note that error codes are not part // of Unmarshal()'s public API, they are for internal unit testing only. type configErrorCode int @@ -75,17 +81,17 @@ type configSettings struct { Service map[string]interface{} `mapstructure:"service"` } -type defaultUnmarshaler struct{} +type DefaultUnmarshaler struct{} // NewDefault returns a default ConfigUnmarshaler that unmarshalls every configuration // using the custom unmarshaler if present or default to strict -func NewDefault() ConfigUnmarshaler { - return &defaultUnmarshaler{} +func NewDefault() *DefaultUnmarshaler { + return &DefaultUnmarshaler{} } // Unmarshal the Config from a config.Map. // After the config is unmarshalled, `Validate()` must be called to validate. -func (*defaultUnmarshaler) Unmarshal(v *config.Map, factories component.Factories) (*config.Config, error) { +func (*DefaultUnmarshaler) Unmarshal(v *config.Map, factories component.Factories) (*config.Config, error) { var cfg config.Config // Unmarshal top level sections and validate. @@ -154,7 +160,7 @@ func unmarshalExtensions(exts map[config.ComponentID]map[string]interface{}, fac // 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 := unmarshal(config.NewMapFromStringMap(value), extensionCfg); err != nil { + if err := config.UnmarshalExtension(config.NewMapFromStringMap(value), extensionCfg); err != nil { return nil, errorUnmarshalError(extensionsKeyName, id, err) } @@ -183,7 +189,7 @@ func unmarshalService(srvRaw map[string]interface{}) (config.Service, error) { }, } - if err := unmarshal(config.NewMapFromStringMap(srvRaw), &srv); err != nil { + if err := config.NewMapFromStringMap(srvRaw).UnmarshalExact(&srv); err != nil { return srv, fmt.Errorf("error reading service configuration: %w", err) } @@ -210,7 +216,7 @@ func LoadReceiver(componentConfig *config.Map, id config.ComponentID, factory co // 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 := unmarshal(componentConfig, receiverCfg); err != nil { + if err := config.UnmarshalReceiver(componentConfig, receiverCfg); err != nil { return nil, errorUnmarshalError(receiversKeyName, id, err) } @@ -259,7 +265,7 @@ func unmarshalExporters(exps map[config.ComponentID]map[string]interface{}, fact // 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 := unmarshal(config.NewMapFromStringMap(value), exporterCfg); err != nil { + if err := config.UnmarshalExporter(config.NewMapFromStringMap(value), exporterCfg); err != nil { return nil, errorUnmarshalError(exportersKeyName, id, err) } @@ -287,7 +293,7 @@ func unmarshalProcessors(procs map[config.ComponentID]map[string]interface{}, fa // 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 := unmarshal(config.NewMapFromStringMap(value), processorCfg); err != nil { + if err := config.UnmarshalProcessor(config.NewMapFromStringMap(value), processorCfg); err != nil { return nil, errorUnmarshalError(processorsKeyName, id, err) } @@ -297,14 +303,6 @@ func unmarshalProcessors(procs map[config.ComponentID]map[string]interface{}, fa return processors, nil } -func unmarshal(componentSection *config.Map, intoCfg interface{}) error { - if cu, ok := intoCfg.(config.Unmarshallable); ok { - return cu.Unmarshal(componentSection) - } - - return componentSection.UnmarshalExact(intoCfg) -} - func errorUnknownType(component string, id config.ComponentID, factories []reflect.Value) error { return fmt.Errorf("unknown %s type %q for %q (valid values: %v)", component, id.Type(), id, factories) } diff --git a/config/configunmarshaler/defaultunmarshaler_test.go b/internal/configunmarshaler/defaultunmarshaler_test.go similarity index 100% rename from config/configunmarshaler/defaultunmarshaler_test.go rename to internal/configunmarshaler/defaultunmarshaler_test.go diff --git a/config/configunmarshaler/testdata/duplicate-exporter.yaml b/internal/configunmarshaler/testdata/duplicate-exporter.yaml similarity index 100% rename from config/configunmarshaler/testdata/duplicate-exporter.yaml rename to internal/configunmarshaler/testdata/duplicate-exporter.yaml diff --git a/config/configunmarshaler/testdata/duplicate-extension.yaml b/internal/configunmarshaler/testdata/duplicate-extension.yaml similarity index 100% rename from config/configunmarshaler/testdata/duplicate-extension.yaml rename to internal/configunmarshaler/testdata/duplicate-extension.yaml diff --git a/config/configunmarshaler/testdata/duplicate-pipeline.yaml b/internal/configunmarshaler/testdata/duplicate-pipeline.yaml similarity index 100% rename from config/configunmarshaler/testdata/duplicate-pipeline.yaml rename to internal/configunmarshaler/testdata/duplicate-pipeline.yaml diff --git a/config/configunmarshaler/testdata/duplicate-processor.yaml b/internal/configunmarshaler/testdata/duplicate-processor.yaml similarity index 100% rename from config/configunmarshaler/testdata/duplicate-processor.yaml rename to internal/configunmarshaler/testdata/duplicate-processor.yaml diff --git a/config/configunmarshaler/testdata/duplicate-receiver.yaml b/internal/configunmarshaler/testdata/duplicate-receiver.yaml similarity index 100% rename from config/configunmarshaler/testdata/duplicate-receiver.yaml rename to internal/configunmarshaler/testdata/duplicate-receiver.yaml diff --git a/config/configunmarshaler/testdata/empty-all-sections.yaml b/internal/configunmarshaler/testdata/empty-all-sections.yaml similarity index 100% rename from config/configunmarshaler/testdata/empty-all-sections.yaml rename to internal/configunmarshaler/testdata/empty-all-sections.yaml diff --git a/config/configunmarshaler/testdata/empty-config.yaml b/internal/configunmarshaler/testdata/empty-config.yaml similarity index 100% rename from config/configunmarshaler/testdata/empty-config.yaml rename to internal/configunmarshaler/testdata/empty-config.yaml diff --git a/config/configunmarshaler/testdata/invalid-exporter-name-after-slash.yaml b/internal/configunmarshaler/testdata/invalid-exporter-name-after-slash.yaml similarity index 100% rename from config/configunmarshaler/testdata/invalid-exporter-name-after-slash.yaml rename to internal/configunmarshaler/testdata/invalid-exporter-name-after-slash.yaml diff --git a/config/configunmarshaler/testdata/invalid-exporter-section.yaml b/internal/configunmarshaler/testdata/invalid-exporter-section.yaml similarity index 100% rename from config/configunmarshaler/testdata/invalid-exporter-section.yaml rename to internal/configunmarshaler/testdata/invalid-exporter-section.yaml diff --git a/config/configunmarshaler/testdata/invalid-exporter-sub-config.yaml b/internal/configunmarshaler/testdata/invalid-exporter-sub-config.yaml similarity index 100% rename from config/configunmarshaler/testdata/invalid-exporter-sub-config.yaml rename to internal/configunmarshaler/testdata/invalid-exporter-sub-config.yaml diff --git a/config/configunmarshaler/testdata/invalid-exporter-type.yaml b/internal/configunmarshaler/testdata/invalid-exporter-type.yaml similarity index 100% rename from config/configunmarshaler/testdata/invalid-exporter-type.yaml rename to internal/configunmarshaler/testdata/invalid-exporter-type.yaml diff --git a/config/configunmarshaler/testdata/invalid-extension-name-after-slash.yaml b/internal/configunmarshaler/testdata/invalid-extension-name-after-slash.yaml similarity index 100% rename from config/configunmarshaler/testdata/invalid-extension-name-after-slash.yaml rename to internal/configunmarshaler/testdata/invalid-extension-name-after-slash.yaml diff --git a/config/configunmarshaler/testdata/invalid-extension-section.yaml b/internal/configunmarshaler/testdata/invalid-extension-section.yaml similarity index 100% rename from config/configunmarshaler/testdata/invalid-extension-section.yaml rename to internal/configunmarshaler/testdata/invalid-extension-section.yaml diff --git a/config/configunmarshaler/testdata/invalid-extension-sub-config.yaml b/internal/configunmarshaler/testdata/invalid-extension-sub-config.yaml similarity index 100% rename from config/configunmarshaler/testdata/invalid-extension-sub-config.yaml rename to internal/configunmarshaler/testdata/invalid-extension-sub-config.yaml diff --git a/config/configunmarshaler/testdata/invalid-extension-type.yaml b/internal/configunmarshaler/testdata/invalid-extension-type.yaml similarity index 100% rename from config/configunmarshaler/testdata/invalid-extension-type.yaml rename to internal/configunmarshaler/testdata/invalid-extension-type.yaml diff --git a/config/configunmarshaler/testdata/invalid-logs-level.yaml b/internal/configunmarshaler/testdata/invalid-logs-level.yaml similarity index 100% rename from config/configunmarshaler/testdata/invalid-logs-level.yaml rename to internal/configunmarshaler/testdata/invalid-logs-level.yaml diff --git a/config/configunmarshaler/testdata/invalid-metrics-level.yaml b/internal/configunmarshaler/testdata/invalid-metrics-level.yaml similarity index 100% rename from config/configunmarshaler/testdata/invalid-metrics-level.yaml rename to internal/configunmarshaler/testdata/invalid-metrics-level.yaml diff --git a/config/configunmarshaler/testdata/invalid-pipeline-name-after-slash.yaml b/internal/configunmarshaler/testdata/invalid-pipeline-name-after-slash.yaml similarity index 100% rename from config/configunmarshaler/testdata/invalid-pipeline-name-after-slash.yaml rename to internal/configunmarshaler/testdata/invalid-pipeline-name-after-slash.yaml diff --git a/config/configunmarshaler/testdata/invalid-pipeline-section.yaml b/internal/configunmarshaler/testdata/invalid-pipeline-section.yaml similarity index 100% rename from config/configunmarshaler/testdata/invalid-pipeline-section.yaml rename to internal/configunmarshaler/testdata/invalid-pipeline-section.yaml diff --git a/config/configunmarshaler/testdata/invalid-pipeline-sub-config.yaml b/internal/configunmarshaler/testdata/invalid-pipeline-sub-config.yaml similarity index 100% rename from config/configunmarshaler/testdata/invalid-pipeline-sub-config.yaml rename to internal/configunmarshaler/testdata/invalid-pipeline-sub-config.yaml diff --git a/config/configunmarshaler/testdata/invalid-pipeline-type.yaml b/internal/configunmarshaler/testdata/invalid-pipeline-type.yaml similarity index 100% rename from config/configunmarshaler/testdata/invalid-pipeline-type.yaml rename to internal/configunmarshaler/testdata/invalid-pipeline-type.yaml diff --git a/config/configunmarshaler/testdata/invalid-processor-name-after-slash.yaml b/internal/configunmarshaler/testdata/invalid-processor-name-after-slash.yaml similarity index 100% rename from config/configunmarshaler/testdata/invalid-processor-name-after-slash.yaml rename to internal/configunmarshaler/testdata/invalid-processor-name-after-slash.yaml diff --git a/config/configunmarshaler/testdata/invalid-processor-section.yaml b/internal/configunmarshaler/testdata/invalid-processor-section.yaml similarity index 100% rename from config/configunmarshaler/testdata/invalid-processor-section.yaml rename to internal/configunmarshaler/testdata/invalid-processor-section.yaml diff --git a/config/configunmarshaler/testdata/invalid-processor-sub-config.yaml b/internal/configunmarshaler/testdata/invalid-processor-sub-config.yaml similarity index 100% rename from config/configunmarshaler/testdata/invalid-processor-sub-config.yaml rename to internal/configunmarshaler/testdata/invalid-processor-sub-config.yaml diff --git a/config/configunmarshaler/testdata/invalid-processor-type.yaml b/internal/configunmarshaler/testdata/invalid-processor-type.yaml similarity index 100% rename from config/configunmarshaler/testdata/invalid-processor-type.yaml rename to internal/configunmarshaler/testdata/invalid-processor-type.yaml diff --git a/config/configunmarshaler/testdata/invalid-receiver-name-after-slash.yaml b/internal/configunmarshaler/testdata/invalid-receiver-name-after-slash.yaml similarity index 100% rename from config/configunmarshaler/testdata/invalid-receiver-name-after-slash.yaml rename to internal/configunmarshaler/testdata/invalid-receiver-name-after-slash.yaml diff --git a/config/configunmarshaler/testdata/invalid-receiver-section.yaml b/internal/configunmarshaler/testdata/invalid-receiver-section.yaml similarity index 100% rename from config/configunmarshaler/testdata/invalid-receiver-section.yaml rename to internal/configunmarshaler/testdata/invalid-receiver-section.yaml diff --git a/config/configunmarshaler/testdata/invalid-receiver-sub-config.yaml b/internal/configunmarshaler/testdata/invalid-receiver-sub-config.yaml similarity index 100% rename from config/configunmarshaler/testdata/invalid-receiver-sub-config.yaml rename to internal/configunmarshaler/testdata/invalid-receiver-sub-config.yaml diff --git a/config/configunmarshaler/testdata/invalid-receiver-type.yaml b/internal/configunmarshaler/testdata/invalid-receiver-type.yaml similarity index 100% rename from config/configunmarshaler/testdata/invalid-receiver-type.yaml rename to internal/configunmarshaler/testdata/invalid-receiver-type.yaml diff --git a/config/configunmarshaler/testdata/invalid-sequence-value.yaml b/internal/configunmarshaler/testdata/invalid-sequence-value.yaml similarity index 100% rename from config/configunmarshaler/testdata/invalid-sequence-value.yaml rename to internal/configunmarshaler/testdata/invalid-sequence-value.yaml diff --git a/config/configunmarshaler/testdata/invalid-service-extensions-section.yaml b/internal/configunmarshaler/testdata/invalid-service-extensions-section.yaml similarity index 100% rename from config/configunmarshaler/testdata/invalid-service-extensions-section.yaml rename to internal/configunmarshaler/testdata/invalid-service-extensions-section.yaml diff --git a/config/configunmarshaler/testdata/invalid-service-section.yaml b/internal/configunmarshaler/testdata/invalid-service-section.yaml similarity index 100% rename from config/configunmarshaler/testdata/invalid-service-section.yaml rename to internal/configunmarshaler/testdata/invalid-service-section.yaml diff --git a/config/configunmarshaler/testdata/invalid-top-level-section.yaml b/internal/configunmarshaler/testdata/invalid-top-level-section.yaml similarity index 100% rename from config/configunmarshaler/testdata/invalid-top-level-section.yaml rename to internal/configunmarshaler/testdata/invalid-top-level-section.yaml diff --git a/config/configunmarshaler/testdata/unknown-exporter-type.yaml b/internal/configunmarshaler/testdata/unknown-exporter-type.yaml similarity index 100% rename from config/configunmarshaler/testdata/unknown-exporter-type.yaml rename to internal/configunmarshaler/testdata/unknown-exporter-type.yaml diff --git a/config/configunmarshaler/testdata/unknown-extension-type.yaml b/internal/configunmarshaler/testdata/unknown-extension-type.yaml similarity index 100% rename from config/configunmarshaler/testdata/unknown-extension-type.yaml rename to internal/configunmarshaler/testdata/unknown-extension-type.yaml diff --git a/config/configunmarshaler/testdata/unknown-pipeline-type.yaml b/internal/configunmarshaler/testdata/unknown-pipeline-type.yaml similarity index 100% rename from config/configunmarshaler/testdata/unknown-pipeline-type.yaml rename to internal/configunmarshaler/testdata/unknown-pipeline-type.yaml diff --git a/config/configunmarshaler/testdata/unknown-processor-type.yaml b/internal/configunmarshaler/testdata/unknown-processor-type.yaml similarity index 100% rename from config/configunmarshaler/testdata/unknown-processor-type.yaml rename to internal/configunmarshaler/testdata/unknown-processor-type.yaml diff --git a/config/configunmarshaler/testdata/unknown-receiver-type.yaml b/internal/configunmarshaler/testdata/unknown-receiver-type.yaml similarity index 100% rename from config/configunmarshaler/testdata/unknown-receiver-type.yaml rename to internal/configunmarshaler/testdata/unknown-receiver-type.yaml diff --git a/config/configunmarshaler/testdata/valid-config.yaml b/internal/configunmarshaler/testdata/valid-config.yaml similarity index 100% rename from config/configunmarshaler/testdata/valid-config.yaml rename to internal/configunmarshaler/testdata/valid-config.yaml diff --git a/service/config_provider.go b/service/config_provider.go index 02e9bbd3fb2..e704569af8a 100644 --- a/service/config_provider.go +++ b/service/config_provider.go @@ -26,11 +26,11 @@ import ( "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/config" "go.opentelemetry.io/collector/config/configmapprovider" - "go.opentelemetry.io/collector/config/configunmarshaler" "go.opentelemetry.io/collector/config/experimental/configsource" "go.opentelemetry.io/collector/config/mapprovider/envmapprovider" "go.opentelemetry.io/collector/config/mapprovider/filemapprovider" "go.opentelemetry.io/collector/config/mapprovider/yamlmapprovider" + "go.opentelemetry.io/collector/internal/configunmarshaler" ) // ConfigProvider provides the service configuration. @@ -92,6 +92,9 @@ func MustNewConfigProvider( // Safe copy, ensures the slice cannot be changed from the caller. locationsCopy := make([]string, len(locations)) copy(locationsCopy, locations) + if configUnmarshaler == nil { + configUnmarshaler = configunmarshaler.NewDefault() + } return &configProvider{ locations: locationsCopy, configMapProviders: configMapProviders, diff --git a/service/config_provider_test.go b/service/config_provider_test.go index 15bcc6492d5..d665df66d95 100644 --- a/service/config_provider_test.go +++ b/service/config_provider_test.go @@ -28,9 +28,9 @@ import ( "go.opentelemetry.io/collector/component/componenttest" "go.opentelemetry.io/collector/config" "go.opentelemetry.io/collector/config/configtest" - "go.opentelemetry.io/collector/config/configunmarshaler" "go.opentelemetry.io/collector/config/experimental/configsource" "go.opentelemetry.io/collector/config/mapprovider/filemapprovider" + "go.opentelemetry.io/collector/internal/configunmarshaler" ) type mockProvider struct {