func (t *PersistentVolumesTable) Generate(ctx context.Context, queryContext table.QueryContext) ([]map[string]string, error) {
	pvs, err := t.client.CoreV1().PersistentVolumes().List(metav1.ListOptions{})
	if err != nil {
		log.Println("could not list pvs from k8s api")
		return nil, err
	}

	rows := make([]map[string]string, len(pvs.Items))
	for i, pv := range pvs.Items {
		currRow := map[string]string{
			"name":              pv.ObjectMeta.Name,
			"status":            string(pv.Status.Phase),
			"storageclass_name": pv.Spec.StorageClassName,
		}

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

		if pv.Spec.Local != nil {
			currRow["path"] = pv.Spec.Local.Path
		}

		// if the volume source is not with zero value
		if pv.Spec.NodeAffinity != nil {
			currRow["nodeaffinity"] = t.getNodeAffinity(pv.Spec.NodeAffinity)
		}

		//pv.Spec.NodeAffinity.Required.NodeSelectorTerms[0].MatchExpressions[0].Values[0],

		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 *PersistentVolumesTable) Generate(ctx context.Context, queryContext table.QueryContext) ([]map[string]string, error) {
	pvs, err := t.client.CoreV1().PersistentVolumes().List(metav1.ListOptions{})
	if err != nil {
		log.Println("could not list pvs from k8s api")
		return nil, err
	}
	rows := make([]map[string]string, len(pvs.Items))
	for i, pv := range pvs.Items {
		currRow := map[string]string{
			"name":              pv.ObjectMeta.Name,
			"status":            string(pv.Status.Phase),
			"storageclass_name": pv.Spec.StorageClassName,
		}
		if _, ok := pv.Spec.Capacity["storage"]; ok {
			quantity := pv.Spec.Capacity["storage"]
			currRow["capacity"] = (&quantity).String()
		}
		if pv.Spec.Local != nil {
			currRow["path"] = pv.Spec.Local.Path
		}
		if pv.Spec.NodeAffinity != nil {
			currRow["nodeaffinity"] = t.getNodeAffinity(pv.Spec.NodeAffinity)
		}
		rows[i] = currRow
	}
	return rows, nil
}
func ( t * PersistentVolumesTable ) Generate ( ctx context . Context , queryContext table . QueryContext ) ( [ ] map [ string ] string , error ) { pvs , err := t . client . CoreV1 ( ) . PersistentVolumes ( ) . List ( metav1 . ListOptions { } ) if err != nil { log . Println ( " " ) return nil , err } rows := make ( [ ] map [ string ] string , len ( pvs . Items ) ) for i , pv := range pvs . Items { currRow := map [ string ] string { " " : pv . ObjectMeta . Name , " " : string ( pv . Status . Phase ) , " " : pv . Spec . StorageClassName , } if _ , ok := pv . Spec . Capacity [ " " ] ; ok { quantity := pv . Spec . Capacity [ " " ] currRow [ " " ] = ( & quantity ) . String ( ) } if pv . Spec . Local != nil { currRow [ " " ] = pv . Spec . Local . Path } if pv . Spec . NodeAffinity != nil { currRow [ " " ] = t . getNodeAffinity ( pv . Spec . NodeAffinity ) } 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
// if the volume source is not with zero value //pv.Spec.NodeAffinity.Required.NodeSelectorTerms[0].MatchExpressions[0].Values[0],