Skip to content

Commit

Permalink
[chore] remove use of component.UnmarshalConfig (#33407)
Browse files Browse the repository at this point in the history
Description:
Remove use of component.UnmarshalConfig

this change only affects test code.

Follow up to #33404

---------

Co-authored-by: Andrzej Stencel <[email protected]>
  • Loading branch information
atoulme and andrzej-stencel authored Jun 6, 2024
1 parent 9ac428d commit 4dda8b9
Show file tree
Hide file tree
Showing 163 changed files with 232 additions and 243 deletions.
2 changes: 1 addition & 1 deletion connector/countconnector/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ func TestLoadConfig(t *testing.T) {

sub, err := cm.Sub(component.NewIDWithName(metadata.Type, tc.name).String())
require.NoError(t, err)
require.NoError(t, component.UnmarshalConfig(sub, cfg))
require.NoError(t, sub.Unmarshal(cfg))

assert.Equal(t, tc.expect, cfg)
})
Expand Down
2 changes: 1 addition & 1 deletion exporter/awsxrayexporter/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func TestLoadConfig(t *testing.T) {

sub, err := cm.Sub(tt.id.String())
require.NoError(t, err)
require.NoError(t, component.UnmarshalConfig(sub, cfg))
require.NoError(t, sub.Unmarshal(cfg))

assert.NoError(t, component.ValidateConfig(cfg))
assert.Equal(t, tt.expected, cfg)
Expand Down
2 changes: 1 addition & 1 deletion exporter/azuredataexplorerexporter/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func TestLoadConfig(t *testing.T) {

sub, err := cm.Sub(tt.id.String())
require.NoError(t, err)
require.NoError(t, component.UnmarshalConfig(sub, cfg))
require.NoError(t, sub.Unmarshal(cfg))

if tt.expected == nil {
assert.EqualError(t, component.ValidateConfig(cfg), tt.errorMessage)
Expand Down
2 changes: 1 addition & 1 deletion exporter/datasetexporter/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func TestLoadConfig(t *testing.T) {

sub, err := cm.Sub(tt.id.String())
require.NoError(t, err)
require.Nil(t, component.UnmarshalConfig(sub, cfg))
require.Nil(t, sub.Unmarshal(cfg))
if assert.Nil(t, component.ValidateConfig(cfg)) {
assert.Equal(t, tt.expected, cfg)
}
Expand Down
2 changes: 1 addition & 1 deletion exporter/elasticsearchexporter/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func TestConfig(t *testing.T) {

sub, err := cm.Sub(tt.id.String())
require.NoError(t, err)
require.NoError(t, component.UnmarshalConfig(sub, cfg))
require.NoError(t, sub.Unmarshal(cfg))

assert.NoError(t, component.ValidateConfig(cfg))
assert.Equal(t, tt.expected, cfg)
Expand Down
2 changes: 1 addition & 1 deletion exporter/fileexporter/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ func TestLoadConfig(t *testing.T) {

sub, err := cm.Sub(tt.id.String())
require.NoError(t, err)
require.NoError(t, component.UnmarshalConfig(sub, cfg))
require.NoError(t, sub.Unmarshal(cfg))

if tt.expected == nil {
assert.EqualError(t, component.ValidateConfig(cfg), tt.errorMessage)
Expand Down
4 changes: 2 additions & 2 deletions exporter/googlecloudexporter/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ func TestLoadConfig(t *testing.T) {

sub, err := cm.Sub(component.NewIDWithName(metadata.Type, "").String())
require.NoError(t, err)
require.NoError(t, component.UnmarshalConfig(sub, cfg))
require.NoError(t, sub.Unmarshal(cfg))

assert.Equal(t, sanitize(cfg.(*Config)), sanitize(factory.CreateDefaultConfig().(*Config)))

sub, err = cm.Sub(component.NewIDWithName(metadata.Type, "customname").String())
require.NoError(t, err)
require.NoError(t, component.UnmarshalConfig(sub, cfg))
require.NoError(t, sub.Unmarshal(cfg))

assert.Equal(t,
&Config{
Expand Down
4 changes: 2 additions & 2 deletions exporter/googlecloudpubsubexporter/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ func TestLoadConfig(t *testing.T) {

sub, err := cm.Sub(component.NewIDWithName(metadata.Type, "").String())
require.NoError(t, err)
require.NoError(t, component.UnmarshalConfig(sub, cfg))
require.NoError(t, sub.Unmarshal(cfg))

defaultConfig := factory.CreateDefaultConfig().(*Config)
assert.Equal(t, cfg, defaultConfig)

sub, err = cm.Sub(component.NewIDWithName(metadata.Type, "customname").String())
require.NoError(t, err)
require.NoError(t, component.UnmarshalConfig(sub, cfg))
require.NoError(t, sub.Unmarshal(cfg))

customConfig := factory.CreateDefaultConfig().(*Config)

Expand Down
2 changes: 1 addition & 1 deletion exporter/honeycombmarkerexporter/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func TestLoadConfig(t *testing.T) {

sub, err := cm.Sub(tt.id.String())
require.NoError(t, err)
require.NoError(t, component.UnmarshalConfig(sub, cfg))
require.NoError(t, sub.Unmarshal(cfg))

if tt.expected == nil {
err = component.ValidateConfig(cfg)
Expand Down
2 changes: 1 addition & 1 deletion exporter/influxdbexporter/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func TestLoadConfig(t *testing.T) {

sub, err := cm.Sub(tt.id.String())
require.NoError(t, err)
require.NoError(t, component.UnmarshalConfig(sub, cfg))
require.NoError(t, sub.Unmarshal(cfg))

assert.NoError(t, component.ValidateConfig(cfg))
assert.Equal(t, tt.expected, cfg)
Expand Down
12 changes: 6 additions & 6 deletions exporter/instanaexporter/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func TestLoadConfig(t *testing.T) {
cfg := factory.CreateDefaultConfig()
sub, err := cm.Sub(component.NewIDWithName(metadata.Type, "valid").String())
require.NoError(t, err)
require.NoError(t, component.UnmarshalConfig(sub, cfg))
require.NoError(t, sub.Unmarshal(cfg))

err = component.ValidateConfig(cfg)

Expand All @@ -68,7 +68,7 @@ func TestLoadConfig(t *testing.T) {
cfg := factory.CreateDefaultConfig()
sub, err := cm.Sub(component.NewIDWithName(metadata.Type, "valid_with_ca_file").String())
require.NoError(t, err)
require.NoError(t, component.UnmarshalConfig(sub, cfg))
require.NoError(t, sub.Unmarshal(cfg))

err = component.ValidateConfig(cfg)

Expand All @@ -94,7 +94,7 @@ func TestLoadConfig(t *testing.T) {
cfg := factory.CreateDefaultConfig()
sub, err := cm.Sub(component.NewIDWithName(metadata.Type, "valid_no_ca_file").String())
require.NoError(t, err)
require.NoError(t, component.UnmarshalConfig(sub, cfg))
require.NoError(t, sub.Unmarshal(cfg))

err = component.ValidateConfig(cfg)

Expand All @@ -115,7 +115,7 @@ func TestLoadConfig(t *testing.T) {
cfg := factory.CreateDefaultConfig()
sub, err := cm.Sub(component.NewIDWithName(metadata.Type, "bad_endpoint").String())
require.NoError(t, err)
require.NoError(t, component.UnmarshalConfig(sub, cfg))
require.NoError(t, sub.Unmarshal(cfg))

err = component.ValidateConfig(cfg)
require.Error(t, err)
Expand All @@ -126,7 +126,7 @@ func TestLoadConfig(t *testing.T) {
sub, err := cm.Sub(component.NewIDWithName(metadata.Type, "non_https_endpoint").String())

require.NoError(t, err)
require.NoError(t, component.UnmarshalConfig(sub, cfg))
require.NoError(t, sub.Unmarshal(cfg))

err = component.ValidateConfig(cfg)
require.Error(t, err)
Expand All @@ -136,7 +136,7 @@ func TestLoadConfig(t *testing.T) {
cfg := factory.CreateDefaultConfig()
sub, err := cm.Sub(component.NewIDWithName(metadata.Type, "missing_agent_key").String())
require.NoError(t, err)
require.NoError(t, component.UnmarshalConfig(sub, cfg))
require.NoError(t, sub.Unmarshal(cfg))

err = component.ValidateConfig(cfg)
require.Error(t, err)
Expand Down
2 changes: 1 addition & 1 deletion exporter/kafkaexporter/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ func TestLoadConfig(t *testing.T) {

sub, err := cm.Sub(tt.id.String())
require.NoError(t, err)
require.NoError(t, component.UnmarshalConfig(sub, cfg))
require.NoError(t, sub.Unmarshal(cfg))

assert.NoError(t, component.ValidateConfig(cfg))
assert.Equal(t, tt.expected, cfg)
Expand Down
2 changes: 1 addition & 1 deletion exporter/kineticaexporter/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func TestLoadConfig(t *testing.T) {

sub, err := cm.Sub(tt.id.String())
require.NoError(t, err)
require.NoError(t, component.UnmarshalConfig(sub, cfg))
require.NoError(t, sub.Unmarshal(cfg))

assert.NoError(t, component.ValidateConfig(cfg))
assert.Equal(t, tt.expected, cfg)
Expand Down
2 changes: 1 addition & 1 deletion exporter/loadbalancingexporter/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ func TestLoadConfig(t *testing.T) {

sub, err := cm.Sub(component.NewIDWithName(metadata.Type, "").String())
require.NoError(t, err)
require.NoError(t, component.UnmarshalConfig(sub, cfg))
require.NoError(t, sub.Unmarshal(cfg))
require.NotNil(t, cfg)
}
4 changes: 2 additions & 2 deletions exporter/logicmonitorexporter/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ func TestLoadConfig(t *testing.T) {

sub, err := cm.Sub(tt.id.String())
require.NoError(t, err)
require.NoError(t, component.UnmarshalConfig(sub, cfg))
require.NoError(t, sub.Unmarshal(cfg))

assert.NoError(t, component.ValidateConfig(cfg))
assert.Equal(t, tt.expected, cfg)
Expand Down Expand Up @@ -181,7 +181,7 @@ func TestUnmarshal(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
cfg := f.CreateDefaultConfig().(*Config)
err := component.UnmarshalConfig(tt.configMap, cfg)
err := tt.configMap.Unmarshal(cfg)
if err != nil || tt.err != "" {
assert.EqualError(t, err, tt.err)
} else {
Expand Down
4 changes: 2 additions & 2 deletions exporter/logzioexporter/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func TestLoadConfig(t *testing.T) {

sub, err := cm.Sub(component.NewIDWithName(metadata.Type, "2").String())
require.NoError(t, err)
require.NoError(t, component.UnmarshalConfig(sub, cfg))
require.NoError(t, sub.Unmarshal(cfg))

expected := &Config{
Token: "token",
Expand Down Expand Up @@ -60,7 +60,7 @@ func TestDefaultLoadConfig(t *testing.T) {

sub, err := cm.Sub(component.NewIDWithName(metadata.Type, "2").String())
require.NoError(t, err)
require.NoError(t, component.UnmarshalConfig(sub, cfg))
require.NoError(t, sub.Unmarshal(cfg))

expected := &Config{
Token: "logzioTESTtoken",
Expand Down
2 changes: 1 addition & 1 deletion exporter/logzioexporter/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestCreateTracesExporter(t *testing.T) {

sub, err := cm.Sub(component.NewIDWithName(metadata.Type, "2").String())
require.NoError(t, err)
require.NoError(t, component.UnmarshalConfig(sub, cfg))
require.NoError(t, sub.Unmarshal(cfg))

params := exportertest.NewNopCreateSettings()
exporter, err := factory.CreateTracesExporter(context.Background(), params, cfg)
Expand Down
2 changes: 1 addition & 1 deletion exporter/lokiexporter/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func TestLoadConfigNewExporter(t *testing.T) {

sub, err := cm.Sub(tt.id.String())
require.NoError(t, err)
require.NoError(t, component.UnmarshalConfig(sub, cfg))
require.NoError(t, sub.Unmarshal(cfg))

assert.NoError(t, component.ValidateConfig(cfg))
assert.Equal(t, tt.expected, cfg)
Expand Down
2 changes: 1 addition & 1 deletion exporter/mezmoexporter/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func TestLoadConfig(t *testing.T) {

sub, err := cm.Sub(tt.id.String())
require.NoError(t, err)
require.NoError(t, component.UnmarshalConfig(sub, cfg))
require.NoError(t, sub.Unmarshal(cfg))

assert.NoError(t, component.ValidateConfig(cfg))
assert.Equal(t, tt.expected, cfg)
Expand Down
2 changes: 1 addition & 1 deletion exporter/opencensusexporter/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func TestLoadConfig(t *testing.T) {

sub, err := cm.Sub(tt.id.String())
require.NoError(t, err)
require.NoError(t, component.UnmarshalConfig(sub, cfg))
require.NoError(t, sub.Unmarshal(cfg))

assert.NoError(t, component.ValidateConfig(cfg))
assert.Equal(t, tt.expected, cfg)
Expand Down
2 changes: 1 addition & 1 deletion exporter/opensearchexporter/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func TestLoadConfig(t *testing.T) {

sub, err := cm.Sub(tt.id.String())
require.NoError(t, err)
require.NoError(t, component.UnmarshalConfig(sub, cfg))
require.NoError(t, sub.Unmarshal(cfg))

vv := component.ValidateConfig(cfg)
tt.configValidateAssert(t, vv)
Expand Down
4 changes: 2 additions & 2 deletions exporter/otelarrowexporter/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func TestUnmarshalDefaultConfig(t *testing.T) {
require.NoError(t, err)
factory := NewFactory()
cfg := factory.CreateDefaultConfig()
assert.NoError(t, component.UnmarshalConfig(cm, cfg))
assert.NoError(t, cm.Unmarshal(cfg))
assert.Equal(t, factory.CreateDefaultConfig(), cfg)
assert.Equal(t, "round_robin", cfg.(*Config).ClientConfig.BalancerName)
assert.Equal(t, arrow.DefaultPrioritizer, cfg.(*Config).Arrow.Prioritizer)
Expand All @@ -42,7 +42,7 @@ func TestUnmarshalConfig(t *testing.T) {
require.NoError(t, err)
factory := NewFactory()
cfg := factory.CreateDefaultConfig()
assert.NoError(t, component.UnmarshalConfig(cm, cfg))
assert.NoError(t, cm.Unmarshal(cfg))
assert.Equal(t,
&Config{
TimeoutSettings: exporterhelper.TimeoutSettings{
Expand Down
2 changes: 1 addition & 1 deletion exporter/prometheusexporter/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func TestLoadConfig(t *testing.T) {

sub, err := cm.Sub(tt.id.String())
require.NoError(t, err)
require.NoError(t, component.UnmarshalConfig(sub, cfg))
require.NoError(t, sub.Unmarshal(cfg))

assert.NoError(t, component.ValidateConfig(cfg))
assert.Equal(t, tt.expected, cfg)
Expand Down
6 changes: 3 additions & 3 deletions exporter/prometheusremotewriteexporter/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func TestLoadConfig(t *testing.T) {

sub, err := cm.Sub(tt.id.String())
require.NoError(t, err)
require.NoError(t, component.UnmarshalConfig(sub, cfg))
require.NoError(t, sub.Unmarshal(cfg))

if tt.expected == nil {
assert.EqualError(t, component.ValidateConfig(cfg), tt.errorMessage)
Expand All @@ -118,7 +118,7 @@ func TestDisabledQueue(t *testing.T) {

sub, err := cm.Sub(component.NewIDWithName(metadata.Type, "disabled_queue").String())
require.NoError(t, err)
require.NoError(t, component.UnmarshalConfig(sub, cfg))
require.NoError(t, sub.Unmarshal(cfg))

assert.False(t, cfg.(*Config).RemoteWriteQueue.Enabled)
}
Expand All @@ -131,7 +131,7 @@ func TestDisabledTargetInfo(t *testing.T) {

sub, err := cm.Sub(component.NewIDWithName(metadata.Type, "disabled_target_info").String())
require.NoError(t, err)
require.NoError(t, component.UnmarshalConfig(sub, cfg))
require.NoError(t, sub.Unmarshal(cfg))

assert.False(t, cfg.(*Config).TargetInfo.Enabled)
}
4 changes: 2 additions & 2 deletions exporter/pulsarexporter/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func TestLoadConfig(t *testing.T) {

sub, err := cm.Sub(tt.id.String())
require.NoError(t, err)
require.NoError(t, component.UnmarshalConfig(sub, cfg))
require.NoError(t, sub.Unmarshal(cfg))

assert.NoError(t, component.ValidateConfig(cfg))
assert.Equal(t, tt.expected, cfg)
Expand All @@ -98,7 +98,7 @@ func TestClientOptions(t *testing.T) {

sub, err := cm.Sub(component.NewIDWithName(metadata.Type, "").String())
require.NoError(t, err)
require.NoError(t, component.UnmarshalConfig(sub, cfg))
require.NoError(t, sub.Unmarshal(cfg))

options := cfg.(*Config).clientOptions()

Expand Down
2 changes: 1 addition & 1 deletion exporter/rabbitmqexporter/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func TestLoadConfig(t *testing.T) {

sub, err := cm.Sub(tt.id.String())
require.NoError(t, err)
require.NoError(t, component.UnmarshalConfig(sub, cfg))
require.NoError(t, sub.Unmarshal(cfg))

if tt.expected == nil {
err = errors.Join(err, component.ValidateConfig(cfg))
Expand Down
2 changes: 1 addition & 1 deletion exporter/sapmexporter/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func TestLoadConfig(t *testing.T) {

sub, err := cm.Sub(tt.id.String())
require.NoError(t, err)
require.NoError(t, component.UnmarshalConfig(sub, cfg))
require.NoError(t, sub.Unmarshal(cfg))

assert.NoError(t, component.ValidateConfig(cfg))
assert.Equal(t, tt.expected, cfg)
Expand Down
2 changes: 1 addition & 1 deletion exporter/sentryexporter/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func TestLoadConfig(t *testing.T) {

sub, err := cm.Sub(tt.id.String())
require.NoError(t, err)
require.NoError(t, component.UnmarshalConfig(sub, cfg))
require.NoError(t, sub.Unmarshal(cfg))

assert.NoError(t, component.ValidateConfig(cfg))
assert.Equal(t, tt.expected, cfg)
Expand Down
2 changes: 1 addition & 1 deletion exporter/skywalkingexporter/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func TestLoadConfig(t *testing.T) {

sub, err := cm.Sub(tt.id.String())
require.NoError(t, err)
require.NoError(t, component.UnmarshalConfig(sub, cfg))
require.NoError(t, sub.Unmarshal(cfg))

assert.NoError(t, component.ValidateConfig(cfg))
assert.Equal(t, tt.expected, cfg)
Expand Down
2 changes: 1 addition & 1 deletion exporter/splunkhecexporter/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func TestLoadConfig(t *testing.T) {

sub, err := cm.Sub(tt.id.String())
require.NoError(t, err)
require.NoError(t, component.UnmarshalConfig(sub, cfg))
require.NoError(t, sub.Unmarshal(cfg))

assert.NoError(t, component.ValidateConfig(cfg))
assert.Equal(t, tt.expected, cfg)
Expand Down
2 changes: 1 addition & 1 deletion exporter/tencentcloudlogserviceexporter/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func TestLoadConfig(t *testing.T) {

sub, err := cm.Sub(tt.id.String())
require.NoError(t, err)
require.NoError(t, component.UnmarshalConfig(sub, cfg))
require.NoError(t, sub.Unmarshal(cfg))

assert.NoError(t, component.ValidateConfig(cfg))
assert.Equal(t, tt.expected, cfg)
Expand Down
Loading

0 comments on commit 4dda8b9

Please sign in to comment.