Skip to content

Commit 8d53d28

Browse files
committed
fix: rename local 'config' variable to avoid collision with imported package
The local variable 'config' was shadowing the imported 'config' package, which could lead to confusion or unexpected behavior. Renamed to 'projectConfig' for clarity and to prevent name collision.
1 parent 06c0575 commit 8d53d28

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

pkg/cli/alpha/internal/generate.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ type Generate struct {
4646

4747
// Generate handles the migration and scaffolding process.
4848
func (opts *Generate) Generate() error {
49-
config, err := loadProjectConfig(opts.InputDir)
49+
projectConfig, err := loadProjectConfig(opts.InputDir)
5050
if err != nil {
5151
return err
5252
}
@@ -82,28 +82,28 @@ func (opts *Generate) Generate() error {
8282
return err
8383
}
8484

85-
if err := kubebuilderInit(config); err != nil {
85+
if err := kubebuilderInit(projectConfig); err != nil {
8686
return err
8787
}
8888

89-
if err := kubebuilderEdit(config); err != nil {
89+
if err := kubebuilderEdit(projectConfig); err != nil {
9090
return err
9191
}
9292

93-
if err := kubebuilderCreate(config); err != nil {
93+
if err := kubebuilderCreate(projectConfig); err != nil {
9494
return err
9595
}
9696

97-
if err := migrateGrafanaPlugin(config, opts.InputDir, opts.OutputDir); err != nil {
97+
if err := migrateGrafanaPlugin(projectConfig, opts.InputDir, opts.OutputDir); err != nil {
9898
return err
9999
}
100100

101-
if hasHelmPlugin(config) {
101+
if hasHelmPlugin(projectConfig) {
102102
if err := kubebuilderHelmEdit(); err != nil {
103103
return err
104104
}
105105
}
106-
return migrateDeployImagePlugin(config)
106+
return migrateDeployImagePlugin(projectConfig)
107107
}
108108

109109
// Validate ensures the options are valid and kubebuilder is installed.
@@ -124,11 +124,11 @@ func (opts *Generate) Validate() error {
124124

125125
// Helper function to load the project configuration.
126126
func loadProjectConfig(inputDir string) (store.Store, error) {
127-
config := yaml.New(machinery.Filesystem{FS: afero.NewOsFs()})
128-
if err := config.LoadFrom(fmt.Sprintf("%s/%s", inputDir, yaml.DefaultPath)); err != nil {
127+
projectConfig := yaml.New(machinery.Filesystem{FS: afero.NewOsFs()})
128+
if err := projectConfig.LoadFrom(fmt.Sprintf("%s/%s", inputDir, yaml.DefaultPath)); err != nil {
129129
return nil, fmt.Errorf("failed to load PROJECT file: %w", err)
130130
}
131-
return config, nil
131+
return projectConfig, nil
132132
}
133133

134134
// Helper function to create the output directory.

0 commit comments

Comments
 (0)