Skip to content

Commit 830578b

Browse files
committed
fix: avoid shadowing of 'pluginConfig' in config v3 implementation and tests
Renamed local variables in pkg/config/v3/config.go and config_test.go to avoid shadowing the 'pluginConfig' package identifier and improve clarity. Updated 'pluginConfig' → 'pluginCfg' consistently across both implementation and unit tests. This helps prevent confusion and potential misuses, especially when debugging or working with similarly named types or packages.
1 parent 4d257b4 commit 830578b

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

pkg/config/v3/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,8 @@ func (c Cfg) DecodePluginConfig(key string, configObj interface{}) error {
299299
}
300300

301301
// Get the object blob by key and unmarshal into the object.
302-
if pluginConfig, hasKey := c.Plugins[key]; hasKey {
303-
b, err := yaml.Marshal(pluginConfig)
302+
if pluginCfg, hasKey := c.Plugins[key]; hasKey {
303+
b, err := yaml.Marshal(pluginCfg)
304304
if err != nil {
305305
return fmt.Errorf("failed to convert extra fields object to bytes: %w", err)
306306
}

pkg/config/v3/config_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -393,24 +393,24 @@ var _ = Describe("Cfg", func() {
393393
)
394394

395395
It("DecodePluginConfig should fail for no plugin config object", func() {
396-
var pluginConfig PluginConfig
397-
err := c0.DecodePluginConfig(key, &pluginConfig)
396+
var pluginCfg PluginConfig
397+
err := c0.DecodePluginConfig(key, &pluginCfg)
398398
Expect(err).To(HaveOccurred())
399399
Expect(errors.As(err, &config.PluginKeyNotFoundError{})).To(BeTrue())
400400
})
401401

402402
It("DecodePluginConfig should fail to retrieve data from a non-existent plugin", func() {
403-
var pluginConfig PluginConfig
404-
err := c1.DecodePluginConfig("plugin-y", &pluginConfig)
403+
var pluginCfg PluginConfig
404+
err := c1.DecodePluginConfig("plugin-y", &pluginCfg)
405405
Expect(err).To(HaveOccurred())
406406
Expect(errors.As(err, &config.PluginKeyNotFoundError{})).To(BeTrue())
407407
})
408408

409409
DescribeTable("DecodePluginConfig should retrieve the plugin data correctly",
410410
func(inputConfig Cfg, expectedPluginConfig PluginConfig) {
411-
var pluginConfig PluginConfig
412-
Expect(inputConfig.DecodePluginConfig(key, &pluginConfig)).To(Succeed())
413-
Expect(pluginConfig).To(Equal(expectedPluginConfig))
411+
var pluginCfg PluginConfig
412+
Expect(inputConfig.DecodePluginConfig(key, &pluginCfg)).To(Succeed())
413+
Expect(pluginCfg).To(Equal(expectedPluginConfig))
414414
},
415415
Entry("for an empty plugin config object", c1, PluginConfig{}),
416416
Entry("for a full plugin config object", c2, pluginConfig),

0 commit comments

Comments
 (0)