Skip to content

Commit c96d386

Browse files
committed
fix: avoid shadowing of 'err' in grafana/v1alpha scaffolds
Split the error handling for config reading and file closing in pkg/plugins/optional/grafana/v1alpha/scaffolds/edit.go to avoid shadowing the outer 'err' variable. This improves error visibility and follows best practices for clarity in error handling and variable reuse.
1 parent 4d257b4 commit c96d386

File tree

1 file changed

+4
-1
lines changed
  • pkg/plugins/optional/grafana/v1alpha/scaffolds

1 file changed

+4
-1
lines changed

pkg/plugins/optional/grafana/v1alpha/scaffolds/edit.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,11 @@ func loadConfig(configPath string) ([]templates.CustomMetricItem, error) {
6969
}
7070

7171
items, err := configReader(f)
72+
if err != nil {
73+
return nil, fmt.Errorf("error reading config.yaml: %w", err)
74+
}
7275

73-
if err := f.Close(); err != nil {
76+
if err = f.Close(); err != nil {
7477
return nil, fmt.Errorf("could not close config.yaml: %w", err)
7578
}
7679

0 commit comments

Comments
 (0)