Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[chore] reuse struct when parsing to avoid recursive parsing #31727

Merged
merged 3 commits into from Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions exporter/datadogexporter/config_warnings_test.go
Expand Up @@ -7,6 +7,7 @@ import (
"testing"

"github.com/stretchr/testify/assert"
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/confmap"
)

Expand Down Expand Up @@ -79,7 +80,7 @@ func TestSendAggregations(t *testing.T) {
t.Run(testInstance.name, func(t *testing.T) {
f := NewFactory()
cfg := f.CreateDefaultConfig().(*Config)
err := cfg.Unmarshal(testInstance.cfgMap)
err := component.UnmarshalConfig(testInstance.cfgMap, cfg)
if err != nil || testInstance.err != "" {
assert.EqualError(t, err, testInstance.err)
} else {
Expand Down Expand Up @@ -156,7 +157,7 @@ func TestPeerTags(t *testing.T) {
t.Run(testInstance.name, func(t *testing.T) {
f := NewFactory()
cfg := f.CreateDefaultConfig().(*Config)
err := cfg.Unmarshal(testInstance.cfgMap)
err := component.UnmarshalConfig(testInstance.cfgMap, cfg)
if err != nil || testInstance.err != "" {
assert.EqualError(t, err, testInstance.err)
} else {
Expand Down
3 changes: 2 additions & 1 deletion exporter/datasetexporter/config_test.go
Expand Up @@ -9,6 +9,7 @@ import (
"time"

"github.com/stretchr/testify/assert"
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/config/configretry"
"go.opentelemetry.io/collector/confmap"
"go.opentelemetry.io/collector/exporter/exporterhelper"
Expand All @@ -22,7 +23,7 @@ func TestConfigUnmarshalUnknownAttributes(t *testing.T) {
"api_key": "secret",
"unknown_attribute": "some value",
})
err := config.Unmarshal(configMap)
err := component.UnmarshalConfig(configMap, config)

unmarshalErr := fmt.Errorf("1 error(s) decoding:\n\n* '' has invalid keys: unknown_attribute")
expectedError := fmt.Errorf("cannot unmarshal config: %w", unmarshalErr)
Expand Down
2 changes: 1 addition & 1 deletion exporter/signalfxexporter/config_test.go
Expand Up @@ -552,7 +552,7 @@ func TestUnmarshalExcludeMetrics(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
require.NoError(t, tt.cfg.Unmarshal(confmap.NewFromStringMap(map[string]any{})))
require.NoError(t, component.UnmarshalConfig(confmap.NewFromStringMap(map[string]any{}), tt.cfg))
assert.Len(t, tt.cfg.ExcludeMetrics, tt.excludeMetricsLen)
})
}
Expand Down