github-vet / github-vet/rangeloop-pointer-findings
integr8ly/grafana-operator: pkg/controller/grafanadashboard/dashboard_controller.go; 69 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [integr8ly/grafana-operator](https://www.github.com/integr8ly/grafana-operator) at [pkg/controller/grafanadashboard/dashboard_controller.go](https://github.com/integr8ly/grafana-operator/blob/c49aa0f05eb42c496ebef6798bd1d10740264d83/pkg/controller/grafanadashboard/dashboard_controller.go#L237-L305)
Below is the message reported by the analyzer for this snippet of code. Beware that the analyzer only reports the first issue it finds, so please do not limit your consideration to the contents of the below message.
>
[Click here to see the code in its original context.](https://github.com/integr8ly/grafana-operator/blob/c49aa0f05eb42c496ebef6798bd1d10740264d83/pkg/controller/grafanadashboard/dashboard_controller.go#L237-L305)
Click here to show the 69 line(s) of Go which triggered the analyzer.
```go
for _, dashboard := range namespaceDashboards.Items {
// Is this a dashboard we care about (matches the label selectors)?
if !r.isMatch(&dashboard) {
log.V(1).Info(fmt.Sprintf("dashboard %v/%v found but selectors do not match",
dashboard.Namespace, dashboard.Name))
continue
}
folderName := dashboard.Namespace
if dashboard.Spec.CustomFolderName != "" {
folderName = dashboard.Spec.CustomFolderName
}
folder, err := grafanaClient.CreateOrUpdateFolder(folderName)
if err != nil {
log.Error(err, fmt.Sprintf("failed to get or create namespace folder %v for dashboard %v", folderName, request.Name))
r.manageError(&dashboard, err)
continue
}
var folderId int64
if folder.ID == nil {
folderId = 0
} else {
folderId = *folder.ID
}
// Process the dashboard. Use the known hash of an existing dashboard
// to determine if an update is required
knownHash := findHash(&dashboard)
pipeline := NewDashboardPipeline(r.client, &dashboard, r.context)
processed, err := pipeline.ProcessDashboard(knownHash, &folderId, folderName)
if err != nil {
log.Error(err, fmt.Sprintf("cannot process dashboard %v/%v", dashboard.Namespace, dashboard.Name))
r.manageError(&dashboard, err)
continue
}
if processed == nil {
r.config.SetPluginsFor(&dashboard)
continue
}
// Check labels only when DashboardNamespaceSelector isnt empty
if r.state.DashboardNamespaceSelector != nil {
matchesNamespaceLabels, err := r.checkNamespaceLabels(&dashboard)
if err != nil {
r.manageError(&dashboard, err)
continue
}
if matchesNamespaceLabels == false {
log.V(1).Info(fmt.Sprintf("dashboard %v skipped because the namespace labels do not match", dashboard.Name))
continue
}
}
_, err = grafanaClient.CreateOrUpdateDashboard(processed, folderId, folderName)
if err != nil {
log.Error(err, fmt.Sprintf("cannot submit dashboard %v/%v", dashboard.Namespace, dashboard.Name))
r.manageError(&dashboard, err)
continue
}
r.manageSuccess(&dashboard, &folderId, folderName)
}
```
Click here to show extra information the analyzer produced.
```
No path was found through the callgraph that could lead to a function which writes a pointer argument.
No path was found through the callgraph that could lead to a function which passes a pointer to third-party code.
root signature {manageError 2} was not found in the callgraph; reference was passed directly to third-party code
```
Leave a reaction on this issue to contribute to the project by classifying this instance as a **Bug** :-1:, **Mitigated** :+1:, or **Desirable Behavior** :rocket:
See the descriptions of the classifications [here](https://github.com/github-vet/rangeclosure-findings#how-can-i-help) for more information.
commit ID: c49aa0f05eb42c496ebef6798bd1d10740264d83
Contributor guide
No contributing guide indexed for this repository
Research direction
Read pkg/controller/grafanadashboard/dashboard_controller.go at lines 237-305 and inspect how the range variable is referenced by the calls shown there, especially manageError and the dashboard pipeline. Determine whether the analyzer finding is a real bug, mitigated, or desirable behavior, then record that classification with the issue reaction.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, kubernetes
- Domain
- devops, infrastructure
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100