Skip to content

Commit

Permalink
chore: Make checks more idiomatic
Browse files Browse the repository at this point in the history
  • Loading branch information
Baarsgaard committed Jan 4, 2025
1 parent 54040ec commit 7d1bdbf
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions controllers/controller_shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,14 @@ func GetScopedMatchingInstances(log logr.Logger, ctx context.Context, k8sClient

var list v1beta1.GrafanaList
err := k8sClient.List(ctx, &list, opts...)
if err != nil || len(list.Items) == 0 {
if err != nil {
return []v1beta1.Grafana{}, err
}

if len(list.Items) == 0 {
return []v1beta1.Grafana{}, nil
}

selectedList := []v1beta1.Grafana{}
var unready_instances []string
for _, instance := range list.Items {
Expand Down Expand Up @@ -124,10 +128,14 @@ func GetAllMatchingInstances(ctx context.Context, k8sClient client.Client, cr v1

var list v1beta1.GrafanaList
err := k8sClient.List(ctx, &list, client.MatchingLabels(instanceSelector.MatchLabels))
if err != nil || len(list.Items) == 0 {
if err != nil {
return []v1beta1.Grafana{}, err
}

if len(list.Items) == 0 {
return []v1beta1.Grafana{}, nil
}

selectedList := []v1beta1.Grafana{}
for _, instance := range list.Items {
// Matches all instances when MatchExpressions is undefined
Expand Down

0 comments on commit 7d1bdbf

Please sign in to comment.