Skip to content

Commit e3c5965

Browse files
authored
Avoid using variable name that collides with imported package (#2811)
Signed-off-by: Bogdan Drutu <[email protected]>
1 parent d8e9970 commit e3c5965

File tree

2 files changed

+23
-23
lines changed

2 files changed

+23
-23
lines changed

config/configparser/config.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ const typeAndNameSeparator = "/"
9797
// After loading the config, need to check if it is valid by calling `ValidateConfig`.
9898
func Load(v *config.Parser, factories component.Factories) (*configmodels.Config, error) {
9999

100-
var config configmodels.Config
100+
var cfg configmodels.Config
101101

102102
// Load the config.
103103

@@ -120,36 +120,36 @@ func Load(v *config.Parser, factories component.Factories) (*configmodels.Config
120120
if err != nil {
121121
return nil, err
122122
}
123-
config.Extensions = extensions
123+
cfg.Extensions = extensions
124124

125125
// Load data components (receivers, exporters, and processors).
126126

127127
receivers, err := loadReceivers(cast.ToStringMap(v.Get(receiversKeyName)), factories.Receivers)
128128
if err != nil {
129129
return nil, err
130130
}
131-
config.Receivers = receivers
131+
cfg.Receivers = receivers
132132

133133
exporters, err := loadExporters(cast.ToStringMap(v.Get(exportersKeyName)), factories.Exporters)
134134
if err != nil {
135135
return nil, err
136136
}
137-
config.Exporters = exporters
137+
cfg.Exporters = exporters
138138

139139
processors, err := loadProcessors(cast.ToStringMap(v.Get(processorsKeyName)), factories.Processors)
140140
if err != nil {
141141
return nil, err
142142
}
143-
config.Processors = processors
143+
cfg.Processors = processors
144144

145145
// Load the service and its data pipelines.
146146
service, err := loadService(rawCfg.Service)
147147
if err != nil {
148148
return nil, err
149149
}
150-
config.Service = service
150+
cfg.Service = service
151151

152-
return &config, nil
152+
return &cfg, nil
153153
}
154154

155155
// DecodeTypeAndName decodes a key in type[/name] format into type and fullName.

config/configparser/config_test.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,20 @@ func TestDecodeConfig(t *testing.T) {
3434
assert.NoError(t, err)
3535

3636
// Load the config
37-
config, err := loadConfigFile(t, path.Join(".", "testdata", "valid-config.yaml"), factories)
37+
cfg, err := loadConfigFile(t, path.Join(".", "testdata", "valid-config.yaml"), factories)
3838
require.NoError(t, err, "Unable to load config")
3939

4040
// Verify extensions.
41-
assert.Equal(t, 3, len(config.Extensions))
42-
assert.Equal(t, "some string", config.Extensions["exampleextension/1"].(*testcomponents.ExampleExtensionCfg).ExtraSetting)
41+
assert.Equal(t, 3, len(cfg.Extensions))
42+
assert.Equal(t, "some string", cfg.Extensions["exampleextension/1"].(*testcomponents.ExampleExtensionCfg).ExtraSetting)
4343

4444
// Verify service.
45-
assert.Equal(t, 2, len(config.Service.Extensions))
46-
assert.Equal(t, "exampleextension/0", config.Service.Extensions[0])
47-
assert.Equal(t, "exampleextension/1", config.Service.Extensions[1])
45+
assert.Equal(t, 2, len(cfg.Service.Extensions))
46+
assert.Equal(t, "exampleextension/0", cfg.Service.Extensions[0])
47+
assert.Equal(t, "exampleextension/1", cfg.Service.Extensions[1])
4848

4949
// Verify receivers
50-
assert.Equal(t, 2, len(config.Receivers), "Incorrect receivers count")
50+
assert.Equal(t, 2, len(cfg.Receivers), "Incorrect receivers count")
5151

5252
assert.Equal(t,
5353
&testcomponents.ExampleReceiver{
@@ -60,7 +60,7 @@ func TestDecodeConfig(t *testing.T) {
6060
},
6161
ExtraSetting: "some string",
6262
},
63-
config.Receivers["examplereceiver"],
63+
cfg.Receivers["examplereceiver"],
6464
"Did not load receiver config correctly")
6565

6666
assert.Equal(t,
@@ -74,11 +74,11 @@ func TestDecodeConfig(t *testing.T) {
7474
},
7575
ExtraSetting: "some string",
7676
},
77-
config.Receivers["examplereceiver/myreceiver"],
77+
cfg.Receivers["examplereceiver/myreceiver"],
7878
"Did not load receiver config correctly")
7979

8080
// Verify exporters
81-
assert.Equal(t, 2, len(config.Exporters), "Incorrect exporters count")
81+
assert.Equal(t, 2, len(cfg.Exporters), "Incorrect exporters count")
8282

8383
assert.Equal(t,
8484
&testcomponents.ExampleExporter{
@@ -88,7 +88,7 @@ func TestDecodeConfig(t *testing.T) {
8888
},
8989
ExtraSetting: "some export string",
9090
},
91-
config.Exporters["exampleexporter"],
91+
cfg.Exporters["exampleexporter"],
9292
"Did not load exporter config correctly")
9393

9494
assert.Equal(t,
@@ -99,11 +99,11 @@ func TestDecodeConfig(t *testing.T) {
9999
},
100100
ExtraSetting: "some export string 2",
101101
},
102-
config.Exporters["exampleexporter/myexporter"],
102+
cfg.Exporters["exampleexporter/myexporter"],
103103
"Did not load exporter config correctly")
104104

105105
// Verify Processors
106-
assert.Equal(t, 1, len(config.Processors), "Incorrect processors count")
106+
assert.Equal(t, 1, len(cfg.Processors), "Incorrect processors count")
107107

108108
assert.Equal(t,
109109
&testcomponents.ExampleProcessorCfg{
@@ -113,11 +113,11 @@ func TestDecodeConfig(t *testing.T) {
113113
},
114114
ExtraSetting: "some export string",
115115
},
116-
config.Processors["exampleprocessor"],
116+
cfg.Processors["exampleprocessor"],
117117
"Did not load processor config correctly")
118118

119119
// Verify Pipelines
120-
assert.Equal(t, 1, len(config.Service.Pipelines), "Incorrect pipelines count")
120+
assert.Equal(t, 1, len(cfg.Service.Pipelines), "Incorrect pipelines count")
121121

122122
assert.Equal(t,
123123
&configmodels.Pipeline{
@@ -127,7 +127,7 @@ func TestDecodeConfig(t *testing.T) {
127127
Processors: []string{"exampleprocessor"},
128128
Exporters: []string{"exampleexporter"},
129129
},
130-
config.Service.Pipelines["traces"],
130+
cfg.Service.Pipelines["traces"],
131131
"Did not load pipeline config correctly")
132132
}
133133

0 commit comments

Comments
 (0)