code: func ListPods(deployment *apps.Deployment, rsList []*apps.ReplicaSet, getPodList podListFunc) (*v1.PodList, error) {
  	namespace := deployment.Namespace
  	selector, err := metav1.LabelSelectorAsSelector(deployment.Spec.Selector)
  	if err != nil {
  		return nil, err
  	}
  	options := metav1.ListOptions{LabelSelector: selector.String()}
  	all, err := getPodList(namespace, options)
  	if err != nil {
  		return all, err
  	}
  	// Only include those whose ControllerRef points to a ReplicaSet that is in
  	// turn owned by this Deployment.
  	rsMap := make(map[types.UID]bool, len(rsList))
  	for _, rs := range rsList {
  		rsMap[rs.UID] = true
  	}
  	owned := &v1.PodList{Items: make([]v1.Pod, 0, len(all.Items))}
  	for i := range all.Items {
  		pod := &all.Items[i]
  		controllerRef := metav1.GetControllerOf(pod)
  		if controllerRef != nil && rsMap[controllerRef.UID] {
  			owned.Items = append(owned.Items, *pod)
  		}
  	}
  	return owned, nil
  }
docs: // ListPods returns a list of pods the given deployment targets.
  // This needs a list of ReplicaSets for the Deployment,
  // which can be found with ListReplicaSets().
  // Note that this does NOT attempt to reconcile ControllerRef (adopt/orphan),
  // because only the controller itself should do that.
  // However, it does filter out anything whose ControllerRef doesn't match.