mirror of https://github.com/k3s-io/k3s
Improved CLI for PVClaims
parent
f620b0d53d
commit
f37113aa25
|
@ -34,6 +34,7 @@ import (
|
|||
"k8s.io/kubernetes/pkg/labels"
|
||||
"k8s.io/kubernetes/pkg/types"
|
||||
"k8s.io/kubernetes/pkg/util"
|
||||
"k8s.io/kubernetes/pkg/volume"
|
||||
)
|
||||
|
||||
// Describer generates output for the named resource or an error
|
||||
|
@ -443,6 +444,8 @@ func (d *PersistentVolumeDescriber) Describe(namespace, name string) (string, er
|
|||
return "", err
|
||||
}
|
||||
|
||||
storage := pv.Spec.Capacity[api.ResourceStorage]
|
||||
|
||||
return tabbedString(func(out io.Writer) error {
|
||||
fmt.Fprintf(out, "Name:\t%s\n", pv.Name)
|
||||
fmt.Fprintf(out, "Labels:\t%s\n", formatLabels(pv.Labels))
|
||||
|
@ -453,6 +456,8 @@ func (d *PersistentVolumeDescriber) Describe(namespace, name string) (string, er
|
|||
fmt.Fprintf(out, "Claim:\t%s\n", "")
|
||||
}
|
||||
fmt.Fprintf(out, "Reclaim Policy:\t%v\n", pv.Spec.PersistentVolumeReclaimPolicy)
|
||||
fmt.Fprintf(out, "Access Modes:\t%s\n", volume.GetAccessModesAsString(pv.Spec.AccessModes))
|
||||
fmt.Fprintf(out, "Capacity:\t%s\n", storage.String())
|
||||
fmt.Fprintf(out, "Message:\t%s\n", pv.Status.Message)
|
||||
return nil
|
||||
})
|
||||
|
@ -470,12 +475,24 @@ func (d *PersistentVolumeClaimDescriber) Describe(namespace, name string) (strin
|
|||
return "", err
|
||||
}
|
||||
|
||||
labels := formatLabels(pvc.Labels)
|
||||
storage := pvc.Spec.Resources.Requests[api.ResourceStorage]
|
||||
capacity := ""
|
||||
accessModes := ""
|
||||
if pvc.Spec.VolumeName != "" {
|
||||
accessModes = volume.GetAccessModesAsString(pvc.Status.AccessModes)
|
||||
storage = pvc.Status.Capacity[api.ResourceStorage]
|
||||
capacity = storage.String()
|
||||
}
|
||||
|
||||
return tabbedString(func(out io.Writer) error {
|
||||
fmt.Fprintf(out, "Name:\t%s\n", pvc.Name)
|
||||
fmt.Fprintf(out, "Namespace:\t%s\n", pvc.Namespace)
|
||||
fmt.Fprintf(out, "Status:\t%v\n", pvc.Status.Phase)
|
||||
fmt.Fprintf(out, "Volume:\t%s\n", pvc.Spec.VolumeName)
|
||||
|
||||
fmt.Fprintf(out, "Labels:\t%s\n", labels)
|
||||
fmt.Fprintf(out, "Capacity:\t%s\n", capacity)
|
||||
fmt.Fprintf(out, "Access Modes:\t%s\n", accessModes)
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
|
|
@ -269,7 +269,7 @@ var namespaceColumns = []string{"NAME", "LABELS", "STATUS", "AGE"}
|
|||
var secretColumns = []string{"NAME", "TYPE", "DATA", "AGE"}
|
||||
var serviceAccountColumns = []string{"NAME", "SECRETS", "AGE"}
|
||||
var persistentVolumeColumns = []string{"NAME", "LABELS", "CAPACITY", "ACCESSMODES", "STATUS", "CLAIM", "REASON", "AGE"}
|
||||
var persistentVolumeClaimColumns = []string{"NAME", "LABELS", "STATUS", "VOLUME", "AGE"}
|
||||
var persistentVolumeClaimColumns = []string{"NAME", "LABELS", "STATUS", "VOLUME", "CAPACITY", "ACCESSMODES", "AGE"}
|
||||
var componentStatusColumns = []string{"NAME", "STATUS", "MESSAGE", "ERROR"}
|
||||
var withNamespacePrefixColumns = []string{"NAMESPACE"} // TODO(erictune): print cluster name too.
|
||||
|
||||
|
@ -779,9 +779,9 @@ func printPersistentVolume(pv *api.PersistentVolume, w io.Writer, withNamespace
|
|||
modesStr := volume.GetAccessModesAsString(pv.Spec.AccessModes)
|
||||
|
||||
aQty := pv.Spec.Capacity[api.ResourceStorage]
|
||||
aSize := aQty.Value()
|
||||
aSize := aQty.String()
|
||||
|
||||
if _, err := fmt.Fprintf(w, "%s\t%s\t%d\t%s\t%s\t%s\t%s\t%s",
|
||||
if _, err := fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s",
|
||||
name,
|
||||
formatLabels(pv.Labels),
|
||||
aSize, modesStr,
|
||||
|
@ -815,13 +815,18 @@ func printPersistentVolumeClaim(pvc *api.PersistentVolumeClaim, w io.Writer, wit
|
|||
}
|
||||
}
|
||||
|
||||
if withNamespace {
|
||||
if _, err := fmt.Fprintf(w, "%s\t", namespace); err != nil {
|
||||
return err
|
||||
}
|
||||
labels := formatLabels(pvc.Labels)
|
||||
phase := pvc.Status.Phase
|
||||
storage := pvc.Spec.Resources.Requests[api.ResourceStorage]
|
||||
capacity := ""
|
||||
accessModes := ""
|
||||
if pvc.Spec.VolumeName != "" {
|
||||
accessModes = volume.GetAccessModesAsString(pvc.Status.AccessModes)
|
||||
storage = pvc.Status.Capacity[api.ResourceStorage]
|
||||
capacity = storage.String()
|
||||
}
|
||||
|
||||
if _, err := fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s", name, pvc.Labels, pvc.Status.Phase, pvc.Spec.VolumeName, translateTimestamp(pvc.CreationTimestamp)); err != nil {
|
||||
if _, err := fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\t%s\t%s", name, labels, phase, pvc.Spec.VolumeName, capacity, accessModes, translateTimestamp(pvc.CreationTimestamp)); err != nil {
|
||||
return err
|
||||
}
|
||||
_, err := fmt.Fprint(w, appendLabels(pvc.Labels, columnLabels))
|
||||
|
|
Loading…
Reference in New Issue