Avoid accessing .Items on nil object

When listing fails for whatever reason, the return value is nil, err.
so handle err explicitly.

Signed-off-by: Dirk Müller <dirk@dmllr.de>
pull/31383/head
Dirk Müller 2 months ago
parent 8d70995503
commit 9cd40c612a
No known key found for this signature in database

@ -455,5 +455,8 @@ func getPods(ctx context.Context, client kubernetes.Interface, namespace, select
list, err := client.CoreV1().Pods(namespace).List(ctx, metav1.ListOptions{
LabelSelector: selector,
})
return list.Items, err
if err != nil {
return nil, fmt.Errorf("failed to list pods: %w", err)
}
return list.Items, nil
}

Loading…
Cancel
Save