From 26fb7cbb170e9a7d0d825c6dae2c814fc6948d15 Mon Sep 17 00:00:00 2001 From: Alex Boten <223565+codeboten@users.noreply.github.com> Date: Tue, 20 Aug 2024 14:37:58 -0700 Subject: [PATCH] [otelcol] remove deprecated interface ConfmapProvider (#10934) Signed-off-by: Alex Boten <223565+codeboten@users.noreply.github.com> --- .chloggen/codeboten_remove-deprecated.yaml | 25 +++++++++++++++++ otelcol/configprovider.go | 28 ------------------- otelcol/configprovider_test.go | 31 ---------------------- 3 files changed, 25 insertions(+), 59 deletions(-) create mode 100644 .chloggen/codeboten_remove-deprecated.yaml diff --git a/.chloggen/codeboten_remove-deprecated.yaml b/.chloggen/codeboten_remove-deprecated.yaml new file mode 100644 index 00000000000..5cdc50982b0 --- /dev/null +++ b/.chloggen/codeboten_remove-deprecated.yaml @@ -0,0 +1,25 @@ +# Use this changelog template to create an entry for release notes. + +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: breaking + +# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver) +component: otelcol + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Remove deprecated `ConfmapProvider` interface. + +# One or more tracking issues or pull requests related to the change +issues: [10934] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: + +# Optional: The change log or logs in which this entry should be included. +# e.g. '[user]' or '[user, api]' +# Include 'user' if the change is relevant to end users. +# Include 'api' if there is a change to a library API. +# Default: '[user]' +change_logs: [] diff --git a/otelcol/configprovider.go b/otelcol/configprovider.go index 88bc52f7681..440ffad5254 100644 --- a/otelcol/configprovider.go +++ b/otelcol/configprovider.go @@ -44,22 +44,6 @@ type ConfigProvider interface { Shutdown(ctx context.Context) error } -// ConfmapProvider is an optional interface to be implemented by ConfigProviders -// to provide confmap.Conf objects representing a marshaled version of the -// Collector's configuration. -// -// The purpose of this interface is that otelcol.ConfigProvider structs do not -// necessarily need to use confmap.Conf as their underlying config structure. -// -// Deprecated: [v0.105.0] This interface is deprecated. otelcol.Collector will now obtain -// a confmap.Conf object from the unmarshaled config itself. -type ConfmapProvider interface { - // GetConfmap resolves the Collector's configuration and provides it as a confmap.Conf object. - // - // Should never be called concurrently with itself or any ConfigProvider method. - GetConfmap(ctx context.Context) (*confmap.Conf, error) -} - type configProvider struct { mapResolver *confmap.Resolver } @@ -117,15 +101,3 @@ func (cm *configProvider) Watch() <-chan error { func (cm *configProvider) Shutdown(ctx context.Context) error { return cm.mapResolver.Shutdown(ctx) } - -// Deprecated: [v0.105.0] Call `(*confmap.Conf).Marshal(*otelcol.Config)` to get -// the Collector's configuration instead. -func (cm *configProvider) GetConfmap(ctx context.Context) (*confmap.Conf, error) { - conf, err := cm.mapResolver.Resolve(ctx) - - if err != nil { - return nil, fmt.Errorf("cannot resolve the configuration: %w", err) - } - - return conf, nil -} diff --git a/otelcol/configprovider_test.go b/otelcol/configprovider_test.go index 18c97ea1a94..a1ea023b9ab 100644 --- a/otelcol/configprovider_test.go +++ b/otelcol/configprovider_test.go @@ -106,34 +106,3 @@ func TestConfigProviderFile(t *testing.T) { assert.EqualValues(t, configNop, cfg) } - -func TestGetConfmap(t *testing.T) { - uriLocation := "file:" + filepath.Join("testdata", "otelcol-nop.yaml") - fileProvider := newFakeProvider("file", func(_ context.Context, _ string, _ confmap.WatcherFunc) (*confmap.Retrieved, error) { - return confmap.NewRetrieved(newConfFromFile(t, uriLocation[5:])) - }) - set := ConfigProviderSettings{ - ResolverSettings: confmap.ResolverSettings{ - URIs: []string{uriLocation}, - ProviderFactories: []confmap.ProviderFactory{fileProvider}, - }, - } - - configBytes, err := os.ReadFile(filepath.Join("testdata", "otelcol-nop.yaml")) - require.NoError(t, err) - - yamlMap := map[string]any{} - err = yaml.Unmarshal(configBytes, yamlMap) - require.NoError(t, err) - - cp, err := NewConfigProvider(set) - require.NoError(t, err) - - cmp, ok := cp.(ConfmapProvider) - require.True(t, ok) - - cmap, err := cmp.GetConfmap(context.Background()) - require.NoError(t, err) - - assert.EqualValues(t, yamlMap, cmap.ToStringMap()) -}