Listing pods only once when getting pods for RS in deployment

This commit is contained in:
Janet Kuo
2016-06-07 16:58:18 -07:00
parent c88c9584a9
commit 764df2e096
7 changed files with 113 additions and 54 deletions

View File

@@ -87,3 +87,14 @@ func UpdatePodWithRetries(podClient unversionedcore.PodInterface, pod *api.Pod,
// if the error is nil and podUpdated is true, the returned pod contains the applied update.
return pod, podUpdated, err
}
// Filter uses the input function f to filter the given pod list, and return the filtered pods
func Filter(podList *api.PodList, f func(api.Pod) bool) []api.Pod {
pods := make([]api.Pod, 0)
for _, p := range podList.Items {
if f(p) {
pods = append(pods, p)
}
}
return pods
}