Skip to content

Commit

Permalink
Use listOpts as a struct instead of pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasrod16 committed Apr 10, 2024
1 parent 8609e62 commit d3be1b8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/pkg/cluster/injector.go
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ func (c *Cluster) getImagesAndNodesForInjection(timeoutDuration time.Duration) (

// After delay, try running
default:
pods, err := c.GetPods(corev1.NamespaceAll, &metav1.ListOptions{
pods, err := c.GetPods(corev1.NamespaceAll, metav1.ListOptions{
FieldSelector: fmt.Sprintf("status.phase=%s", corev1.PodRunning),
})
if err != nil {
Expand Down
9 changes: 3 additions & 6 deletions src/pkg/k8s/pods.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,12 @@ func (k *K8s) CreatePod(pod *corev1.Pod) (*corev1.Pod, error) {

// GetAllPods returns a list of pods from the cluster for all namespaces.
func (k *K8s) GetAllPods() (*corev1.PodList, error) {
return k.GetPods(corev1.NamespaceAll, nil)
return k.GetPods(corev1.NamespaceAll, metav1.ListOptions{})
}

// GetPods returns a list of pods from the cluster by namespace.
func (k *K8s) GetPods(namespace string, listOpts *metav1.ListOptions) (*corev1.PodList, error) {
if listOpts == nil {
listOpts = &metav1.ListOptions{}
}
return k.Clientset.CoreV1().Pods(namespace).List(context.TODO(), *listOpts)
func (k *K8s) GetPods(namespace string, listOpts metav1.ListOptions) (*corev1.PodList, error) {
return k.Clientset.CoreV1().Pods(namespace).List(context.TODO(), listOpts)
}

// WaitForPodsAndContainers attempts to find pods matching the given selector and optional inclusion filter
Expand Down

0 comments on commit d3be1b8

Please sign in to comment.