mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-28 14:07:14 +00:00
Merge pull request #12733 from markturansky/pv_describer
Added PersistentVolumeSource to describer output
This commit is contained in:
commit
d7752e0c5f
@ -595,6 +595,25 @@ func (d *PersistentVolumeDescriber) Describe(namespace, name string) (string, er
|
|||||||
fmt.Fprintf(out, "Access Modes:\t%s\n", volume.GetAccessModesAsString(pv.Spec.AccessModes))
|
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, "Capacity:\t%s\n", storage.String())
|
||||||
fmt.Fprintf(out, "Message:\t%s\n", pv.Status.Message)
|
fmt.Fprintf(out, "Message:\t%s\n", pv.Status.Message)
|
||||||
|
fmt.Fprintf(out, "Source:\n")
|
||||||
|
|
||||||
|
switch {
|
||||||
|
case pv.Spec.HostPath != nil:
|
||||||
|
printHostPathVolumeSource(pv.Spec.HostPath, out)
|
||||||
|
case pv.Spec.GCEPersistentDisk != nil:
|
||||||
|
printGCEPersistentDiskVolumeSource(pv.Spec.GCEPersistentDisk, out)
|
||||||
|
case pv.Spec.AWSElasticBlockStore != nil:
|
||||||
|
printAWSElasticBlockStoreVolumeSource(pv.Spec.AWSElasticBlockStore, out)
|
||||||
|
case pv.Spec.NFS != nil:
|
||||||
|
printNFSVolumeSource(pv.Spec.NFS, out)
|
||||||
|
case pv.Spec.ISCSI != nil:
|
||||||
|
printISCSIVolumeSource(pv.Spec.ISCSI, out)
|
||||||
|
case pv.Spec.Glusterfs != nil:
|
||||||
|
printGlusterfsVolumeSource(pv.Spec.Glusterfs, out)
|
||||||
|
case pv.Spec.RBD != nil:
|
||||||
|
printRBDVolumeSource(pv.Spec.RBD, out)
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -411,3 +411,71 @@ func TestGetPodsTotalRequests(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestPersistentVolumeDescriber(t *testing.T) {
|
||||||
|
tests := map[string]*api.PersistentVolume{
|
||||||
|
|
||||||
|
"hostpath": {
|
||||||
|
Spec: api.PersistentVolumeSpec{
|
||||||
|
PersistentVolumeSource: api.PersistentVolumeSource{
|
||||||
|
HostPath: &api.HostPathVolumeSource{},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"gce": {
|
||||||
|
Spec: api.PersistentVolumeSpec{
|
||||||
|
PersistentVolumeSource: api.PersistentVolumeSource{
|
||||||
|
GCEPersistentDisk: &api.GCEPersistentDiskVolumeSource{},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"ebs": {
|
||||||
|
Spec: api.PersistentVolumeSpec{
|
||||||
|
PersistentVolumeSource: api.PersistentVolumeSource{
|
||||||
|
AWSElasticBlockStore: &api.AWSElasticBlockStoreVolumeSource{},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"nfs": {
|
||||||
|
Spec: api.PersistentVolumeSpec{
|
||||||
|
PersistentVolumeSource: api.PersistentVolumeSource{
|
||||||
|
NFS: &api.NFSVolumeSource{},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"iscsi": {
|
||||||
|
Spec: api.PersistentVolumeSpec{
|
||||||
|
PersistentVolumeSource: api.PersistentVolumeSource{
|
||||||
|
ISCSI: &api.ISCSIVolumeSource{},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"gluster": {
|
||||||
|
Spec: api.PersistentVolumeSpec{
|
||||||
|
PersistentVolumeSource: api.PersistentVolumeSource{
|
||||||
|
Glusterfs: &api.GlusterfsVolumeSource{},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"rbd": {
|
||||||
|
Spec: api.PersistentVolumeSpec{
|
||||||
|
PersistentVolumeSource: api.PersistentVolumeSource{
|
||||||
|
RBD: &api.RBDVolumeSource{},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for name, pv := range tests {
|
||||||
|
fake := testclient.NewSimpleFake(pv)
|
||||||
|
c := PersistentVolumeDescriber{fake}
|
||||||
|
str, err := c.Describe("foo", "bar")
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("Unexpected error for test %s: %v", name, err)
|
||||||
|
}
|
||||||
|
if str == "" {
|
||||||
|
t.Errorf("Unexpected empty string for test %s. Expected PV Describer output", name)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user