func getPersistentVolumeList(persistentVolumes []api.PersistentVolume, dsQuery *dataselect.DataSelectQuery) *PersistentVolumeList {
	result := &PersistentVolumeList{
		Items:    make([]PersistentVolume, 0),
		ListMeta: common.ListMeta{TotalItems: len(persistentVolumes)},
	}

	persistentVolumes = fromCells(dataselect.GenericDataSelect(toCells(persistentVolumes), dsQuery))

	for _, item := range persistentVolumes {

		var claim string
		if item.Spec.ClaimRef != nil {
			claim = item.Spec.ClaimRef.Name
		}

		result.Items = append(result.Items,
			PersistentVolume{
				ObjectMeta:  common.NewObjectMeta(item.ObjectMeta),
				TypeMeta:    common.NewTypeMeta(common.ResourceKindPersistentVolume),
				Capacity:    item.Spec.Capacity,
				AccessModes: item.Spec.AccessModes,
				Status:      item.Status.Phase,
				Claim:       claim,
				Reason:      item.Status.Reason,
			})
	}

	return result
}
Example #2
0
// NewIngressList - creates a new instance of IngressList struct based on K8s Ingress array.
func NewIngressList(ingresses []extensions.Ingress, dsQuery *dataselect.DataSelectQuery) *IngressList {
	newIngressList := &IngressList{
		ListMeta: common.ListMeta{TotalItems: len(ingresses)},
		Items:    make([]Ingress, 0),
	}

	ingresses = fromCells(dataselect.GenericDataSelect(toCells(ingresses), dsQuery))

	for _, ingress := range ingresses {
		newIngressList.Items = append(newIngressList.Items, *NewIngress(&ingress))
	}

	return newIngressList
}
func toNamespaceList(namespaces []api.Namespace, dsQuery *dataselect.DataSelectQuery) *NamespaceList {
	namespaceList := &NamespaceList{
		Namespaces: make([]Namespace, 0),
		ListMeta:   common.ListMeta{TotalItems: len(namespaces)},
	}

	namespaces = fromCells(dataselect.GenericDataSelect(toCells(namespaces), dsQuery))

	for _, namespace := range namespaces {
		namespaceList.Namespaces = append(namespaceList.Namespaces, toNamespace(namespace))
	}

	return namespaceList
}
// CreateServiceList returns paginated service list based on given service array
// and pagination query.
func CreateServiceList(services []api.Service, dsQuery *dataselect.DataSelectQuery) *ServiceList {
	serviceList := &ServiceList{
		Services: make([]Service, 0),
		ListMeta: common.ListMeta{TotalItems: len(services)},
	}

	services = fromCells(dataselect.GenericDataSelect(toCells(services), dsQuery))

	for _, service := range services {
		serviceList.Services = append(serviceList.Services, ToService(&service))
	}

	return serviceList
}
Example #5
0
// NewSecret - creates a new instance of SecretList struct based on K8s Secrets array.
func NewSecretList(secrets []api.Secret, dsQuery *dataselect.DataSelectQuery) *SecretList {
	newSecretList := &SecretList{
		ListMeta: common.ListMeta{TotalItems: len(secrets)},
		Secrets:  make([]Secret, 0),
	}

	secrets = fromCells(dataselect.GenericDataSelect(toCells(secrets), dsQuery))

	for _, secret := range secrets {
		newSecretList.Secrets = append(newSecretList.Secrets, *NewSecret(&secret))
	}

	return newSecretList
}
Example #6
0
// CreateEventList converts array of api events to common EventList structure
func CreateEventList(events []api.Event, dsQuery *dataselect.DataSelectQuery) common.EventList {

	eventList := common.EventList{
		Events:   make([]common.Event, 0),
		ListMeta: common.ListMeta{TotalItems: len(events)},
	}

	events = fromCells(dataselect.GenericDataSelect(toCells(events), dsQuery))

	for _, event := range events {
		eventDetail := ToEvent(event)
		eventList.Events = append(eventList.Events, eventDetail)
	}

	return eventList
}
func getConfigMapList(configMaps []api.ConfigMap, dsQuery *dataselect.DataSelectQuery) *ConfigMapList {

	result := &ConfigMapList{
		Items:    make([]ConfigMap, 0),
		ListMeta: common.ListMeta{TotalItems: len(configMaps)},
	}

	configMaps = fromCells(dataselect.GenericDataSelect(toCells(configMaps), dsQuery))

	for _, item := range configMaps {
		result.Items = append(result.Items,
			ConfigMap{
				ObjectMeta: common.NewObjectMeta(item.ObjectMeta),
				TypeMeta:   common.NewTypeMeta(common.ResourceKindConfigMap),
			})
	}

	return result
}
func getLimitRangeList(limitRanges []api.LimitRange, dsQuery *dataselect.DataSelectQuery) *LimitRangeList {

	result := &LimitRangeList{
		Items:    make([]LimitRange, 0),
		ListMeta: common.ListMeta{TotalItems: len(limitRanges)},
	}

	limitRanges = fromCells(dataselect.GenericDataSelect(toCells(limitRanges), dsQuery))

	for _, item := range limitRanges {
		result.Items = append(result.Items,
			LimitRange{
				ObjectMeta: common.NewObjectMeta(item.ObjectMeta),
				TypeMeta:   common.NewTypeMeta(common.ResourceKindLimitRange),
			})
	}

	return result
}
func getPersistentVolumeClaimList(persistentVolumeClaims []api.PersistentVolumeClaim, dsQuery *dataselect.DataSelectQuery) *PersistentVolumeClaimList {

	result := &PersistentVolumeClaimList{
		Items:    make([]PersistentVolumeClaim, 0),
		ListMeta: common.ListMeta{TotalItems: len(persistentVolumeClaims)},
	}

	persistentVolumeClaims = fromCells(dataselect.GenericDataSelect(toCells(persistentVolumeClaims), dsQuery))

	for _, item := range persistentVolumeClaims {
		result.Items = append(result.Items,
			PersistentVolumeClaim{
				ObjectMeta: common.NewObjectMeta(item.ObjectMeta),
				TypeMeta:   common.NewTypeMeta(common.ResourceKindPersistentVolumeClaim),
				Status:     string(item.Status.Phase),
				Volume:     item.Spec.VolumeName,
			})
		fmt.Println(item.Status.Capacity)
	}

	return result
}