func getDeploymentList(deployments []extensions.Deployment, pods []api.Pod, events []api.Event) *DeploymentList { deploymentList := &DeploymentList{ Deployments: make([]Deployment, 0), } for _, deployment := range deployments { matchingPods := common.FilterNamespacedPodsBySelector(pods, deployment.ObjectMeta.Namespace, deployment.Spec.Selector.MatchLabels) podInfo := getPodInfo(&deployment, matchingPods) podInfo.Warnings = event.GetPodsEventWarnings(events, matchingPods) deploymentList.Deployments = append(deploymentList.Deployments, Deployment{ ObjectMeta: common.NewObjectMeta(deployment.ObjectMeta), TypeMeta: common.NewTypeMeta(common.ResourceKindDeployment), ContainerImages: common.GetContainerImages(&deployment.Spec.Template.Spec), Pods: podInfo, }) } return deploymentList }
func ToJobList(jobs []batch.Job, pods []api.Pod, events []api.Event) *JobList { jobList := &JobList{ Jobs: make([]Job, 0), } for _, job := range jobs { matchingPods := common.FilterNamespacedPodsBySelector(pods, job.ObjectMeta.Namespace, job.Spec.Selector.MatchLabels) podInfo := getPodInfo(&job, matchingPods) jobList.Jobs = append(jobList.Jobs, ToJob(&job, &podInfo)) } return jobList }
// GetServicePods gets list of pods targeted by given label selector in given namespace. func GetServicePods(client k8sClient.Interface, heapsterClient client.HeapsterClient, namespace string, serviceSelector map[string]string) (*pod.PodList, error) { channels := &common.ResourceChannels{ PodList: common.GetPodListChannel(client, common.NewSameNamespaceQuery(namespace), 1), } apiPodList := <-channels.PodList.List if err := <-channels.PodList.Error; err != nil { return nil, err } apiPods := common.FilterNamespacedPodsBySelector(apiPodList.Items, namespace, serviceSelector) podList := pod.CreatePodList(apiPods, heapsterClient) return &podList, nil }
func ToReplicaSetList(replicaSets []extensions.ReplicaSet, pods []api.Pod, events []api.Event) *ReplicaSetList { replicaSetList := &ReplicaSetList{ ReplicaSets: make([]ReplicaSet, 0), } for _, replicaSet := range replicaSets { matchingPods := common.FilterNamespacedPodsBySelector(pods, replicaSet.ObjectMeta.Namespace, replicaSet.Spec.Selector.MatchLabels) podInfo := getPodInfo(&replicaSet, matchingPods) podInfo.Warnings = event.GetPodsEventWarnings(events, matchingPods) replicaSetList.ReplicaSets = append(replicaSetList.ReplicaSets, ToReplicaSet(&replicaSet, &podInfo)) } return replicaSetList }
func ToPetSetList(petSets []apps.PetSet, pods []api.Pod, events []api.Event) *PetSetList { petSetList := &PetSetList{ PetSets: make([]PetSet, 0), } for _, petSet := range petSets { matchingPods := common.FilterNamespacedPodsBySelector(pods, petSet.ObjectMeta.Namespace, petSet.Spec.Selector.MatchLabels) // TODO(floreks): Conversion should be omitted when client type will be updated podInfo := common.GetPodInfo(int32(petSet.Status.Replicas), int32(petSet.Spec.Replicas), matchingPods) podInfo.Warnings = event.GetPodsEventWarnings(events, matchingPods) petSetList.PetSets = append(petSetList.PetSets, ToPetSet(&petSet, &podInfo)) } return petSetList }
func getJobDetail(job *batch.Job, heapsterClient client.HeapsterClient, events *common.EventList, pods []api.Pod) JobDetail { matchingPods := common.FilterNamespacedPodsBySelector(pods, job.ObjectMeta.Namespace, job.Spec.Selector.MatchLabels) podInfo := getPodInfo(job, matchingPods) return JobDetail{ ObjectMeta: common.NewObjectMeta(job.ObjectMeta), TypeMeta: common.NewTypeMeta(common.ResourceKindJob), ContainerImages: common.GetContainerImages(&job.Spec.Template.Spec), PodInfo: podInfo, PodList: pod.CreatePodList(matchingPods, heapsterClient), EventList: *events, Parallelism: job.Spec.Parallelism, Completions: job.Spec.Completions, } }