diff --git a/internal/configconverter/k8s_tagger.go b/internal/configconverter/k8s_tagger.go deleted file mode 100644 index f4377389ac..0000000000 --- a/internal/configconverter/k8s_tagger.go +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright The OpenTelemetry Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package configconverter - -import ( - "context" - "fmt" - "log" - "reflect" - "regexp" - - "go.opentelemetry.io/collector/confmap" -) - -// RenameK8sTagger will replace k8s_tagger processor items with k8sattributes ones. -func RenameK8sTagger(_ context.Context, in *confmap.Conf) error { - if in == nil { - return fmt.Errorf("cannot RenameK8sTagger on nil *confmap.Conf") - } - - tagger := "k8s_tagger(/\\w+:{0,2})?" - taggerRe := regexp.MustCompile(tagger) - keyExpr := fmt.Sprintf("processors::%s(.+)?", tagger) - k8sTaggerKeyRe := regexp.MustCompile(keyExpr) - - const serviceExpr = "service(.+)processors" - serviceEntryRe := regexp.MustCompile(serviceExpr) - - found := false - out := map[string]any{} - for _, k := range in.AllKeys() { - v := in.Get(k) - if match := k8sTaggerKeyRe.FindStringSubmatch(k); match != nil { - k8sAttributesKey := fmt.Sprintf("processors::k8sattributes%s%s", match[1], match[2]) - out[k8sAttributesKey] = v - if !found { - log.Println("[WARNING] `k8s_tagger` processor was renamed to `k8sattributes`. Please update your config accordingly.") - } - found = true - } else { - if serviceEntryRe.MatchString(k) { - t := reflect.TypeOf(v) - if t != nil && t.Kind() == reflect.Slice { - if sliceOfInterfaces, ok := v.([]any); ok { - for i, val := range sliceOfInterfaces { - if strVal, ok := val.(string); ok { - if match = taggerRe.FindStringSubmatch(strVal); match != nil { - k8sAttributeEntry := fmt.Sprintf("k8sattributes%s", match[1]) - sliceOfInterfaces[i] = k8sAttributeEntry - } - } - } - v = sliceOfInterfaces - } - } - } - out[k] = v - } - } - *in = *confmap.NewFromStringMap(out) - return nil -} diff --git a/internal/configconverter/k8s_tagger_test.go b/internal/configconverter/k8s_tagger_test.go deleted file mode 100644 index 9871752bab..0000000000 --- a/internal/configconverter/k8s_tagger_test.go +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright The OpenTelemetry Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Copyright The OpenTelemetry Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package configconverter - -import ( - "context" - "testing" - - "github.com/stretchr/testify/require" - "go.opentelemetry.io/collector/confmap/confmaptest" -) - -func TestRenameK8sTaggerTestRenameK8sTagger(t *testing.T) { - actual, err := confmaptest.LoadConf("testdata/k8s-tagger.yaml") - require.NoError(t, err) - require.NotNil(t, actual) - - expected, err := confmaptest.LoadConf("testdata/k8sattributes.yaml") - require.NoError(t, err) - - err = RenameK8sTagger(context.Background(), actual) - require.NoError(t, err) - - require.Equal(t, expected.ToStringMap(), actual.ToStringMap()) -} diff --git a/internal/configconverter/loglevel_to_verbosity.go b/internal/configconverter/loglevel_to_verbosity.go deleted file mode 100644 index a8a4409bc4..0000000000 --- a/internal/configconverter/loglevel_to_verbosity.go +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright The OpenTelemetry Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package configconverter - -import ( - "context" - "fmt" - "log" - "regexp" - - "go.opentelemetry.io/collector/config/configtelemetry" - "go.opentelemetry.io/collector/confmap" - "go.uber.org/zap/zapcore" -) - -func LogLevelToVerbosity(_ context.Context, in *confmap.Conf) error { - if in == nil { - return fmt.Errorf("cannot LogLevelToVerbosity on nil *confmap.Conf") - } - - const expression = "exporters::logging(/.+)?::loglevel" - re := regexp.MustCompile(expression) - out := map[string]any{} - unsupportedKeyFound := false - for _, k := range in.AllKeys() { - v := in.Get(k) - match := re.FindStringSubmatch(k) - if match == nil { - out[k] = v - } else { - // check if verbosity is also set: - verbosityKey := fmt.Sprintf("exporters::logging%s::verbosity", match[1]) - if in.Get(verbosityKey) == nil { - log.Printf("Deprecated key found: %s. Translating to %s\n", k, verbosityKey) - var l zapcore.Level - if err := l.UnmarshalText([]byte(v.(string))); err != nil { - log.Printf("Could not read loglevel: %v", err) - out[k] = v - } else { - var verbosityLevel configtelemetry.Level - if verbosityLevel, err = mapLevel(l); err != nil { - log.Printf("Could not map loglevel to verbosity: %v", err) - out[k] = v - } else { - out[verbosityKey] = verbosityLevel.String() - } - } - } else { - log.Printf("Deprecated key found: %s. Found new key %s", k, verbosityKey) - } - unsupportedKeyFound = true - } - } - if unsupportedKeyFound { - log.Println( - "[WARNING] `exporters` -> `logging` -> `loglevel` " + - "is deprecated and moved to verbosity. Please update your config. " + - "https://github.com/open-telemetry/opentelemetry-collector/pull/6334", - ) - } - - *in = *confmap.NewFromStringMap(out) - return nil -} - -func mapLevel(level zapcore.Level) (configtelemetry.Level, error) { - switch level { - case zapcore.DebugLevel: - return configtelemetry.LevelDetailed, nil - case zapcore.InfoLevel: - return configtelemetry.LevelNormal, nil - case zapcore.WarnLevel, zapcore.ErrorLevel, - zapcore.DPanicLevel, zapcore.PanicLevel, zapcore.FatalLevel: - // Anything above info is mapped to 'basic' level. - return configtelemetry.LevelBasic, nil - default: - return configtelemetry.LevelNone, fmt.Errorf("log level %q is not supported", level) - } -} diff --git a/internal/configconverter/loglevel_to_verbosity_test.go b/internal/configconverter/loglevel_to_verbosity_test.go deleted file mode 100644 index ce86ad2c0d..0000000000 --- a/internal/configconverter/loglevel_to_verbosity_test.go +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright The OpenTelemetry Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package configconverter - -import ( - "context" - "testing" - - "github.com/stretchr/testify/require" - "go.opentelemetry.io/collector/confmap/confmaptest" -) - -func TestLogLevelToVerbosity(t *testing.T) { - cfgMap, err := confmaptest.LoadConf("testdata/logging_loglevel.yaml") - require.NoError(t, err) - require.NotNil(t, cfgMap) - - expectedCfgMap, err := confmaptest.LoadConf("testdata/logging_loglevel-after.yaml") - require.NoError(t, err) - require.NotNil(t, expectedCfgMap) - - err = LogLevelToVerbosity(context.Background(), cfgMap) - require.NoError(t, err) - - require.Equal(t, expectedCfgMap, cfgMap) -} diff --git a/internal/configconverter/move_hec_tls.go b/internal/configconverter/move_hec_tls.go deleted file mode 100644 index d113c700a9..0000000000 --- a/internal/configconverter/move_hec_tls.go +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright The OpenTelemetry Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package configconverter - -import ( - "context" - "fmt" - "log" - "regexp" - - "go.opentelemetry.io/collector/confmap" -) - -func MoveHecTLS(_ context.Context, in *confmap.Conf) error { - if in == nil { - return fmt.Errorf("cannot MoveHecTLS on nil *confmap.Conf") - } - - const expression = "exporters::splunk_hec(/\\w+)?::(insecure_skip_verify|ca_file|cert_file|key_file)" - re := regexp.MustCompile(expression) - out := map[string]any{} - unsupportedKeyFound := false - for _, k := range in.AllKeys() { - v := in.Get(k) - match := re.FindStringSubmatch(k) - if match == nil { - out[k] = v - } else { - tlsKey := fmt.Sprintf("exporters::splunk_hec%s::tls::%s", match[1], match[2]) - log.Printf("Unsupported key found: %s. Moving to %s\n", k, tlsKey) - out[tlsKey] = v - unsupportedKeyFound = true - } - } - if unsupportedKeyFound { - log.Println( - "[WARNING] `exporters` -> `splunk_hec` -> `insecure_skip_verify|ca_file|cert_file|key_file` " + - "parameters have moved under `tls`. Please update your config. " + - "https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/5433", - ) - } - - *in = *confmap.NewFromStringMap(out) - return nil -} diff --git a/internal/configconverter/move_hec_tls_test.go b/internal/configconverter/move_hec_tls_test.go deleted file mode 100644 index 49d4b89ced..0000000000 --- a/internal/configconverter/move_hec_tls_test.go +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright The OpenTelemetry Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package configconverter - -import ( - "context" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - "go.opentelemetry.io/collector/confmap/confmaptest" -) - -func TestMoveHecTLS(t *testing.T) { - cfgMap, err := confmaptest.LoadConf("testdata/hec-tls.yaml") - require.NoError(t, err) - require.NotNil(t, cfgMap) - - err = MoveHecTLS(context.Background(), cfgMap) - require.NoError(t, err) - - assert.False(t, cfgMap.IsSet("exporters::splunk_hec::ca_file")) - assert.True(t, true, cfgMap.Get("exporters::splunk_hec::tls::insecure_skip_verify")) - assert.Equal(t, "my-ca-file-1", cfgMap.Get("exporters::splunk_hec::tls::ca_file")) - assert.Equal(t, "my-cert-file-1", cfgMap.Get("exporters::splunk_hec::tls::cert_file")) - assert.Equal(t, "my-key-file-1", cfgMap.Get("exporters::splunk_hec::tls::key_file")) - - assert.False(t, cfgMap.IsSet("exporters::splunk_hec/allsettings::ca_file")) - assert.True(t, true, cfgMap.Get("exporters::splunk_hec/allsettings::tls::insecure_skip_verify")) - assert.Equal(t, "my-ca-file-2", cfgMap.Get("exporters::splunk_hec/allsettings::tls::ca_file")) - assert.Equal(t, "my-cert-file-2", cfgMap.Get("exporters::splunk_hec/allsettings::tls::cert_file")) - assert.Equal(t, "my-key-file-2", cfgMap.Get("exporters::splunk_hec/allsettings::tls::key_file")) -} diff --git a/internal/configconverter/move_otlp_insecure.go b/internal/configconverter/move_otlp_insecure.go deleted file mode 100644 index 20b090222d..0000000000 --- a/internal/configconverter/move_otlp_insecure.go +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright The OpenTelemetry Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package configconverter - -import ( - "context" - "fmt" - "log" - "regexp" - - "go.opentelemetry.io/collector/confmap" -) - -func MoveOTLPInsecureKey(_ context.Context, in *confmap.Conf) error { - if in == nil { - return fmt.Errorf("cannot MoveOTLPInsecureKey on nil *confmap.Conf") - } - - const expr = "exporters::otlp(/\\w+)?::insecure" - insecureRE := regexp.MustCompile(expr) - out := map[string]any{} - var deprecatedOTLPConfigFound bool - for _, k := range in.AllKeys() { - v := in.Get(k) - match := insecureRE.FindStringSubmatch(k) - if match == nil { - out[k] = v - } else { - tlsKey := fmt.Sprintf("exporters::otlp%s::tls::insecure", match[1]) - log.Printf("Unsupported key found: %s. Moving to %s\n", k, tlsKey) - out[tlsKey] = v - deprecatedOTLPConfigFound = true - } - } - if deprecatedOTLPConfigFound { - log.Println("[WARNING] `exporters` -> `otlp` -> `insecure` parameter is " + - "deprecated. Please update the config according to the guideline: " + - "https://github.com/signalfx/splunk-otel-collector#from-0350-to-0360.") - } - - *in = *confmap.NewFromStringMap(out) - return nil -} diff --git a/internal/configconverter/move_otlp_insecure_test.go b/internal/configconverter/move_otlp_insecure_test.go deleted file mode 100644 index 857cc7a344..0000000000 --- a/internal/configconverter/move_otlp_insecure_test.go +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright The OpenTelemetry Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Copyright The OpenTelemetry Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package configconverter - -import ( - "context" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - "go.opentelemetry.io/collector/confmap/confmaptest" -) - -func TestMoveOTLPInsecureKey(t *testing.T) { - cfgMap, err := confmaptest.LoadConf("testdata/otlp-insecure.yaml") - require.NoError(t, err) - require.NotNil(t, cfgMap) - - err = MoveOTLPInsecureKey(context.Background(), cfgMap) - require.NoError(t, err) - - assert.False(t, cfgMap.IsSet("exporters::otlp::insecure")) - assert.Equal(t, true, cfgMap.Get("exporters::otlp::tls::insecure")) -} - -func TestMoveOTLPInsecureKey_Custom(t *testing.T) { - cfgMap, err := confmaptest.LoadConf("testdata/otlp-insecure-custom.yaml") - require.NoError(t, err) - require.NotNil(t, cfgMap) - - err = MoveOTLPInsecureKey(context.Background(), cfgMap) - require.NoError(t, err) - - assert.False(t, cfgMap.IsSet("exporters::otlp/foo::insecure")) - assert.Equal(t, true, cfgMap.Get("exporters::otlp/foo::tls::insecure")) - assert.Equal(t, true, cfgMap.Get("exporters::otlp/foo::tls::insecure_skip_verify")) -} diff --git a/internal/configconverter/remove_ballast_key.go b/internal/configconverter/remove_ballast_key.go deleted file mode 100644 index 5a7591622e..0000000000 --- a/internal/configconverter/remove_ballast_key.go +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright The OpenTelemetry Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package configconverter - -import ( - "context" - "fmt" - "log" - "regexp" - - "go.opentelemetry.io/collector/confmap" -) - -// RemoveBallastKey removes a ballast_size_mib on a -// memory_limiter processor config if it exists. This config key will go away at -// some point (or already has) at which point its presence in a config will -// prevent the Collector from starting. -func RemoveBallastKey(_ context.Context, cfgMap *confmap.Conf) error { - if cfgMap == nil { - return fmt.Errorf("cannot RemoveBallastKey on nil *confmap.Conf") - } - - const expr = "processors::memory_limiter(/\\w+)?::ballast_size_mib" - ballastKeyRegexp := regexp.MustCompile(expr) - - out := map[string]any{} - for _, k := range cfgMap.AllKeys() { - if ballastKeyRegexp.MatchString(k) { - log.Println("[WARNING] `ballast_size_mib` parameter in `memory_limiter` processor is " + - "deprecated. Please update the config according to the guideline: " + - "https://github.com/signalfx/splunk-otel-collector#from-0340-to-0350.") - } else { - out[k] = cfgMap.Get(k) - } - } - *cfgMap = *confmap.NewFromStringMap(out) - return nil -} diff --git a/internal/configconverter/remove_memory_ballast_key.go b/internal/configconverter/remove_memory_ballast_key.go deleted file mode 100644 index 38f62bd523..0000000000 --- a/internal/configconverter/remove_memory_ballast_key.go +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright The OpenTelemetry Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package configconverter - -import ( - "context" - "fmt" - "log" - "regexp" - - "go.opentelemetry.io/collector/confmap" -) - -func removeMemoryBallastStrElementFromSlice(strList []interface{}) []interface{} { - ret := make([]interface{}, 0) - for i, v := range strList { - if v == "memory_ballast" { - ret = append(ret, strList[:i]...) - return append(ret, strList[i+1:]...) - } - } - return strList -} - -// RemoveMemoryBallastKey removes a memory_ballast on a extension config if it exists. -func RemoveMemoryBallastKey(_ context.Context, cfgMap *confmap.Conf) error { - if cfgMap == nil { - return fmt.Errorf("cannot RemoveMemoryBallastKey on nil *confmap.Conf") - } - - const firstExp = "extensions::memory_ballast.*" - firstRegExp := regexp.MustCompile(firstExp) - const secondExp = "service::extensions" - secondRegExp := regexp.MustCompile(secondExp) - - out := map[string]any{} - for _, k := range cfgMap.AllKeys() { - if firstRegExp.MatchString(k) { - log.Println("[WARNING] `memory_ballast` extension is deprecated. Please remove it from your configuration. " + - "See https://github.com/signalfx/splunk-otel-collector#from-0961-to-0970 for more details") - continue - } - if secondRegExp.MatchString(k) { - out[k] = cfgMap.Get(k) - if extSlice, ok := out[k].([]any); ok { - ret := removeMemoryBallastStrElementFromSlice(extSlice) - out[k] = ret - } - continue - } - out[k] = cfgMap.Get(k) - } - *cfgMap = *confmap.NewFromStringMap(out) - return nil -} diff --git a/internal/configconverter/remove_memory_ballast_key_test.go b/internal/configconverter/remove_memory_ballast_key_test.go deleted file mode 100644 index 3925692d84..0000000000 --- a/internal/configconverter/remove_memory_ballast_key_test.go +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright The OpenTelemetry Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Taken from https://github.com/open-telemetry/opentelemetry-collector/blob/v0.66.0/confmap/converter/overwritepropertiesconverter/properties_test.go -// to prevent breaking changes. -package configconverter - -import ( - "context" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - "go.opentelemetry.io/collector/confmap" - "go.opentelemetry.io/collector/confmap/confmaptest" -) - -func TestRemoveMemoryBallastConverter_Empty(t *testing.T) { - conf := confmap.NewFromStringMap(map[string]interface{}{"foo": "bar"}) - assert.NoError(t, RemoveMemoryBallastKey(context.Background(), conf)) - assert.Equal(t, map[string]interface{}{"foo": "bar"}, conf.ToStringMap()) -} - -func TestRemoveMemoryBallastConverter_With_Memory_Ballast(t *testing.T) { - cfgMap, err := confmaptest.LoadConf("testdata/with_memory_ballast.yaml") - require.NoError(t, err) - require.NotNil(t, cfgMap) - assert.NoError(t, RemoveMemoryBallastKey(context.Background(), cfgMap)) - cfgMapExpected, err := confmaptest.LoadConf("testdata/with_memory_ballast_config_expected.yaml") - require.NoError(t, err) - assert.Equal(t, cfgMapExpected.ToStringMap(), cfgMap.ToStringMap()) -} - -func TestMemoryBallastConverter_Without_Memory_Ballast(t *testing.T) { - cfgMap, err := confmaptest.LoadConf("testdata/without_memory_ballast_config.yaml") - require.NoError(t, err) - require.NotNil(t, cfgMap) - assert.NoError(t, RemoveMemoryBallastKey(context.Background(), cfgMap)) - assert.Equal(t, cfgMap.ToStringMap(), cfgMap.ToStringMap()) -} - -func TestRemoveMemoryBallastStrElementFromSlice(t *testing.T) { - originalSlice := []interface{}{"foo", "bar", "memory_ballast", "item2"} - actual := removeMemoryBallastStrElementFromSlice(originalSlice) - expected := []interface{}{"foo", "bar", "item2"} - assert.Equal(t, actual, expected) - - originalSlice1 := []interface{}{"foo", "bar", "foobar", "foobar1"} - actual = removeMemoryBallastStrElementFromSlice(originalSlice1) - assert.Equal(t, actual, originalSlice1) -} - -func TestRemoveMemoryBallastConverter_With_Only_MemoryBallast_Value(t *testing.T) { - cfgMap, err := confmaptest.LoadConf("testdata/with_memory_ballast_only.yaml") - require.NoError(t, err) - require.NotNil(t, cfgMap) - assert.NoError(t, RemoveMemoryBallastKey(context.Background(), cfgMap)) - cfgMapExpected, err := confmaptest.LoadConf("testdata/with_memory_ballast_only_expected.yaml") - require.NoError(t, err) - assert.Equal(t, cfgMapExpected.ToStringMap(), cfgMap.ToStringMap()) -} diff --git a/internal/configsource/source.go b/internal/configsource/source.go index 25c28cc3eb..f4885ca074 100644 --- a/internal/configsource/source.go +++ b/internal/configsource/source.go @@ -472,6 +472,9 @@ func retrieveConfigSourceData(ctx context.Context, configSources map[string]Conf var provider confmap.Provider var providerFound bool if !ok { + if confmapProviders == nil { + return fmt.Sprintf("${%s}", cfgSrcInvocation), nil, nil + } if provider, providerFound = confmapProviders[cfgSrcName]; !providerFound { return nil, nil, newErrUnknownConfigSource(cfgSrcName) } diff --git a/internal/confmapprovider/configsource/provider.go b/internal/confmapprovider/configsource/provider.go index a47a3a810d..43d2a04b25 100644 --- a/internal/confmapprovider/configsource/provider.go +++ b/internal/confmapprovider/configsource/provider.go @@ -174,7 +174,7 @@ func (pw *ProviderWrapper) ResolveForWrapped(ctx context.Context, uri string, on return nil, fmt.Errorf("failed resolving latestConf: %w", err) } - resolved, closeFunc, err := configsource.ResolveWithConfigSources(ctx, configSources, providers, confToResolve, onChange) + resolved, closeFunc, err := configsource.ResolveWithConfigSources(ctx, configSources, nil, confToResolve, onChange) if err != nil { return nil, fmt.Errorf("failed resolving with config sources: %w", err) } diff --git a/internal/settings/settings.go b/internal/settings/settings.go index d402ac8103..2ba2d154a5 100644 --- a/internal/settings/settings.go +++ b/internal/settings/settings.go @@ -206,13 +206,7 @@ func (s *Settings) ConfMapConverterFactories() []confmap.ConverterFactory { if !s.noConvertConfig { confMapConverterFactories = append( confMapConverterFactories, - configconverter.ConverterFactoryFromFunc(configconverter.RemoveBallastKey), - configconverter.ConverterFactoryFromFunc(configconverter.RemoveMemoryBallastKey), - configconverter.ConverterFactoryFromFunc(configconverter.MoveOTLPInsecureKey), - configconverter.ConverterFactoryFromFunc(configconverter.MoveHecTLS), - configconverter.ConverterFactoryFromFunc(configconverter.RenameK8sTagger), configconverter.ConverterFactoryFromFunc(configconverter.NormalizeGcp), - configconverter.ConverterFactoryFromFunc(configconverter.LogLevelToVerbosity), configconverter.ConverterFactoryFromFunc(configconverter.DisableKubeletUtilizationMetrics), configconverter.ConverterFactoryFromFunc(configconverter.DisableExcessiveInternalMetrics), configconverter.ConverterFactoryFromFunc(configconverter.AddOTLPHistogramAttr), diff --git a/internal/settings/settings_test.go b/internal/settings/settings_test.go index 74e0ef6793..a571a215fc 100644 --- a/internal/settings/settings_test.go +++ b/internal/settings/settings_test.go @@ -156,7 +156,7 @@ func TestNewSettingsConvertConfig(t *testing.T) { require.Equal(t, []string(nil), settings.discoveryProperties) require.Equal(t, []string{configPath, anotherConfigPath}, settings.ResolverURIs()) - require.Equal(t, 12, len(settings.ConfMapConverterFactories())) + require.Equal(t, 6, len(settings.ConfMapConverterFactories())) require.Equal(t, []string{"--feature-gates", "foo", "--feature-gates", "-bar"}, settings.ColCoreArgs()) }