Skip to content

Commit 35a4960

Browse files
committed
Fix staticcheck SA4004: remove unconditionally terminated loop
Use direct index access for the single Grafana pod instead of iterating with a for-range that always returns on first iteration.
1 parent 1729424 commit 35a4960

1 file changed

Lines changed: 7 additions & 10 deletions

File tree

test/benchmark/grafana.go

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,19 +73,16 @@ func DeployGrafana(ctx context.Context, k8sClient *kubernetes.Clientset, monitor
7373
if listErr != nil || len(pods.Items) == 0 {
7474
return false, nil
7575
}
76-
for _, pod := range pods.Items {
77-
if len(pod.Status.ContainerStatuses) == 0 {
76+
pod := pods.Items[0]
77+
if len(pod.Status.ContainerStatuses) == 0 {
78+
return false, nil
79+
}
80+
for _, cs := range pod.Status.ContainerStatuses {
81+
if !cs.Ready {
7882
return false, nil
7983
}
80-
for _, cs := range pod.Status.ContainerStatuses {
81-
if !cs.Ready {
82-
return false, nil
83-
}
84-
}
85-
// Single container, and it's ready
86-
return true, nil
8784
}
88-
return false, nil
85+
return true, nil
8986
})
9087
if err != nil {
9188
dumpGrafanaDiagnostics(ctx, k8sClient, monitoringNS)

0 commit comments

Comments
 (0)