// GetOldRCs returns the old RCs targeted by the given Deployment; get PodList and RCList from client interface. func GetOldRCs(deployment extensions.Deployment, c client.Interface) ([]*api.ReplicationController, error) { return GetOldRCsFromLists(deployment, c, func(namespace string, options api.ListOptions) (*api.PodList, error) { return c.Pods(namespace).List(options) }, func(namespace string, options api.ListOptions) ([]api.ReplicationController, error) { rcList, err := c.ReplicationControllers(namespace).List(options) return rcList.Items, err }) }
func getPodsForRCs(c client.Interface, replicationControllers []*api.ReplicationController) ([]api.Pod, error) { allPods := []api.Pod{} for _, rc := range replicationControllers { selector := labels.SelectorFromSet(rc.Spec.Selector) options := api.ListOptions{LabelSelector: selector} podList, err := c.Pods(rc.ObjectMeta.Namespace).List(options) if err != nil { return allPods, fmt.Errorf("error listing pods: %v", err) } allPods = append(allPods, podList.Items...) } return allPods, nil }