func (t *PersistentVolumeClaimsTable) Generate(ctx context.Context, queryContext table.QueryContext) ([]map[string]string, error) {

	pvcs, err := t.client.CoreV1().PersistentVolumeClaims(metav1.NamespaceAll).List(metav1.ListOptions{})
	if err != nil {
		log.Println("could not list pvcs from k8s api")
		return nil, err
	}

	rows := make([]map[string]string, len(pvcs.Items))

	for i, pvc := range pvcs.Items {
		currRow := map[string]string{
			"name":       pvc.ObjectMeta.Name,
			"status":     string(pvc.Status.Phase),
			"volumename": pvc.Spec.VolumeName,
		}
		if pvc.Spec.VolumeMode != nil {
			currRow["volumemode"] = string(*pvc.Spec.VolumeMode)
		}

		if pvc.Spec.StorageClassName != nil {
			currRow["storageclass_name"] = string(*pvc.Spec.StorageClassName)
		}

		if _, ok := pvc.Status.Capacity["storage"]; ok {
			quantity := pvc.Status.Capacity["storage"]
			currRow["capacity"] = (&quantity).String()
		}

		if _, ok := pvc.Spec.Resources.Requests["storage"]; ok {
			quantity := pvc.Spec.Resources.Requests["storage"]
			currRow["requested"] = (&quantity).String()
		}

		rows[i] = currRow
	}

	return rows, nil
}
// Generate uses the api to retrieve information on all pods
Generate uses the api to retrieve information on all pods
// Generate uses the api to retrieve information on all pods
func (t *PersistentVolumeClaimsTable) Generate(ctx context.Context, queryContext table.QueryContext) ([]map[string]string, error) {
	pvcs, err := t.client.CoreV1().PersistentVolumeClaims(metav1.NamespaceAll).List(metav1.ListOptions{})
	if err != nil {
		log.Println("could not list pvcs from k8s api")
		return nil, err
	}
	rows := make([]map[string]string, len(pvcs.Items))
	for i, pvc := range pvcs.Items {
		currRow := map[string]string{
			"name":       pvc.ObjectMeta.Name,
			"status":     string(pvc.Status.Phase),
			"volumename": pvc.Spec.VolumeName,
		}
		if pvc.Spec.VolumeMode != nil {
			currRow["volumemode"] = string(*pvc.Spec.VolumeMode)
		}
		if pvc.Spec.StorageClassName != nil {
			currRow["storageclass_name"] = string(*pvc.Spec.StorageClassName)
		}
		if _, ok := pvc.Status.Capacity["storage"]; ok {
			quantity := pvc.Status.Capacity["storage"]
			currRow["capacity"] = (&quantity).String()
		}
		if _, ok := pvc.Spec.Resources.Requests["storage"]; ok {
			quantity := pvc.Spec.Resources.Requests["storage"]
			currRow["requested"] = (&quantity).String()
		}
		rows[i] = currRow
	}
	return rows, nil
}
func ( t * PersistentVolumeClaimsTable ) Generate ( ctx context . Context , queryContext table . QueryContext ) ( [ ] map [ string ] string , error ) { pvcs , err := t . client . CoreV1 ( ) . PersistentVolumeClaims ( metav1 . NamespaceAll ) . List ( metav1 . ListOptions { } ) if err != nil { log . Println ( " " ) return nil , err } rows := make ( [ ] map [ string ] string , len ( pvcs . Items ) ) for i , pvc := range pvcs . Items { currRow := map [ string ] string { " " : pvc . ObjectMeta . Name , " " : string ( pvc . Status . Phase ) , " " : pvc . Spec . VolumeName , } if pvc . Spec . VolumeMode != nil { currRow [ " " ] = string ( * pvc . Spec . VolumeMode ) } if pvc . Spec . StorageClassName != nil { currRow [ " " ] = string ( * pvc . Spec . StorageClassName ) } if _ , ok := pvc . Status . Capacity [ " " ] ; ok { quantity := pvc . Status . Capacity [ " " ] currRow [ " " ] = ( & quantity ) . String ( ) } if _ , ok := pvc . Spec . Resources . Requests [ " " ] ; ok { quantity := pvc . Spec . Resources . Requests [ " " ] currRow [ " " ] = ( & quantity ) . String ( ) } rows [ i ] = currRow } return rows , nil }
Generate uses the api to retrieve information on all pods
Generate uses the api to retrieve information on all pods