// Returns a list of all Replication Controller model objects in the cluster, based on all Kubernetes // Replication Controller and Service API objects. func getReplicationControllerList(replicationControllers []api.ReplicationController, pods []api.Pod, events []api.Event) *ReplicationControllerList { replicationControllerList := &ReplicationControllerList{ ReplicationControllers: make([]ReplicationController, 0), } for _, replicationController := range replicationControllers { matchingPods := make([]api.Pod, 0) for _, pod := range pods { if pod.ObjectMeta.Namespace == replicationController.ObjectMeta.Namespace && common.IsSelectorMatching(replicationController.Spec.Selector, pod.ObjectMeta.Labels) { matchingPods = append(matchingPods, pod) } } podInfo := getReplicationPodInfo(&replicationController, matchingPods) podErrors := event.GetPodsEventWarnings(events, matchingPods) podInfo.Warnings = podErrors replicationControllerList.ReplicationControllers = append(replicationControllerList.ReplicationControllers, ReplicationController{ ObjectMeta: common.NewObjectMeta(replicationController.ObjectMeta), TypeMeta: common.NewTypeMeta(common.ResourceKindReplicationController), Pods: podInfo, ContainerImages: common.GetContainerImages(&replicationController.Spec.Template.Spec), }) } return replicationControllerList }
// Returns all services that target the same Pods (or subset) as the given Replication Controller. func getMatchingServices(services []api.Service, replicationController *api.ReplicationController) []api.Service { var matchingServices []api.Service for _, service := range services { if service.ObjectMeta.Namespace == replicationController.ObjectMeta.Namespace && common.IsSelectorMatching(service.Spec.Selector, replicationController.Spec.Selector) { matchingServices = append(matchingServices, service) } } return matchingServices }