func getPetSetDetail(petSet *apps.PetSet, heapsterClient client.HeapsterClient,
	events *common.EventList, pods []api.Pod) PetSetDetail {

	matchingPods := common.FilterNamespacedPodsByLabelSelector(pods, petSet.ObjectMeta.Namespace,
		petSet.Spec.Selector)

	podInfo := common.GetPodInfo(int32(petSet.Status.Replicas), int32(petSet.Spec.Replicas),
		matchingPods)

	return PetSetDetail{
		ObjectMeta:      common.NewObjectMeta(petSet.ObjectMeta),
		TypeMeta:        common.NewTypeMeta(common.ResourceKindPetSet),
		ContainerImages: common.GetContainerImages(&petSet.Spec.Template.Spec),
		PodInfo:         podInfo,
		PodList:         pod.CreatePodList(matchingPods, heapsterClient),
		EventList:       *events,
	}
}
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 getDeploymentDetail(deployment *extensions.Deployment,
	oldRs []*extensions.ReplicaSet, newRs *extensions.ReplicaSet,
	pods []api.Pod, events *common.EventList, rawEvents []api.Event) *DeploymentDetail {
	var newReplicaSet replicaset.ReplicaSet

	if newRs != nil {
		newRsPodInfo := common.GetPodInfo(newRs.Status.Replicas, newRs.Spec.Replicas, pods)
		newReplicaSet = replicaset.ToReplicaSet(newRs, &newRsPodInfo)
	}

	oldReplicaSets := make([]extensions.ReplicaSet, len(oldRs))
	for i, replicaSet := range oldRs {
		oldReplicaSets[i] = *replicaSet
	}
	oldReplicaSetList := replicaset.ToReplicaSetList(oldReplicaSets, pods, rawEvents)

	var rollingUpdateStrategy *RollingUpdateStrategy
	if deployment.Spec.Strategy.RollingUpdate != nil {
		rollingUpdateStrategy = &RollingUpdateStrategy{
			MaxSurge:       deployment.Spec.Strategy.RollingUpdate.MaxSurge.IntValue(),
			MaxUnavailable: deployment.Spec.Strategy.RollingUpdate.MaxUnavailable.IntValue(),
		}
	}

	return &DeploymentDetail{
		ObjectMeta:            common.NewObjectMeta(deployment.ObjectMeta),
		TypeMeta:              common.NewTypeMeta(common.ResourceKindDeployment),
		Selector:              deployment.Spec.Selector.MatchLabels,
		StatusInfo:            GetStatusInfo(&deployment.Status),
		Strategy:              deployment.Spec.Strategy.Type,
		MinReadySeconds:       deployment.Spec.MinReadySeconds,
		RollingUpdateStrategy: rollingUpdateStrategy,
		OldReplicaSetList:     *oldReplicaSetList,
		NewReplicaSet:         newReplicaSet,
		RevisionHistoryLimit:  deployment.Spec.RevisionHistoryLimit,
		EventList:             *events,
	}
}
// getReplicationPodInfo returns aggregate information about replication controller pods.
func getReplicationPodInfo(replicationController *api.ReplicationController,
	pods []api.Pod) common.PodInfo {

	return common.GetPodInfo(replicationController.Status.Replicas,
		replicationController.Spec.Replicas, pods)
}
// getPodInfo returns aggregate information about deployment pods.
func getPodInfo(resource *extensions.Deployment, pods []api.Pod) common.PodInfo {
	return common.GetPodInfo(resource.Status.Replicas, resource.Spec.Replicas, pods)
}
// getPodInfo returns aggregate information about job pods.
func getPodInfo(resource *batch.Job, pods []api.Pod) common.PodInfo {
	return common.GetPodInfo(resource.Status.Active, *resource.Spec.Completions, pods)
}