// Returns a list of all Daemon Set model objects in the cluster, based on all Kubernetes // Daemon Set and Service API objects. // The function processes all Daemon Set API objects and finds matching Services for them. func getDaemonSetList(daemonSets []extensions.DaemonSet, pods []api.Pod, events []api.Event) *DaemonSetList { daemonSetList := &DaemonSetList{DaemonSets: make([]DaemonSet, 0)} for _, daemonSet := range daemonSets { matchingPods := make([]api.Pod, 0) for _, pod := range pods { if pod.ObjectMeta.Namespace == daemonSet.ObjectMeta.Namespace && common.IsLabelSelectorMatching(pod.ObjectMeta.Labels, daemonSet.Spec.Selector) { matchingPods = append(matchingPods, pod) } } podInfo := getDaemonSetPodInfo(&daemonSet, matchingPods) podErrors := event.GetPodsEventWarnings(events, matchingPods) podInfo.Warnings = podErrors daemonSetList.DaemonSets = append(daemonSetList.DaemonSets, DaemonSet{ ObjectMeta: common.NewObjectMeta(daemonSet.ObjectMeta), TypeMeta: common.NewTypeMeta(common.ResourceKindDaemonSet), Pods: podInfo, ContainerImages: common.GetContainerImages(&daemonSet.Spec.Template.Spec), }) } return daemonSetList }
// 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 }
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 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 }