code: func (dc *DeploymentController) getPodMapForDeployment(d *apps.Deployment, rsList []*apps.ReplicaSet) (map[types.UID]*v1.PodList, error) {
  	// Get all Pods that potentially belong to this Deployment.
  	selector, err := metav1.LabelSelectorAsSelector(d.Spec.Selector)
  	if err != nil {
  		return nil, err
  	}
  	pods, err := dc.podLister.Pods(d.Namespace).List(selector)
  	if err != nil {
  		return nil, err
  	}
  	// Group Pods by their controller (if it's in rsList).
  	podMap := make(map[types.UID]*v1.PodList, len(rsList))
  	for _, rs := range rsList {
  		podMap[rs.UID] = &v1.PodList{}
  	}
  	for _, pod := range pods {
  		// Do not ignore inactive Pods because Recreate Deployments need to verify that no
  		// Pods from older versions are running before spinning up new Pods.
  		controllerRef := metav1.GetControllerOf(pod)
  		if controllerRef == nil {
  			continue
  		}
  		// Only append if we care about this UID.
  		if podList, ok := podMap[controllerRef.UID]; ok {
  			podList.Items = append(podList.Items, *pod)
  		}
  	}
  	return podMap, nil
  }
docs: // getPodMapForDeployment returns the Pods managed by a Deployment.
  //
  // It returns a map from ReplicaSet UID to a list of Pods controlled by that RS,
  // according to the Pod's ControllerRef.