add apigroup to the data source when using kubectl describe pvc

This commit is contained in:
caiweidong 2019-09-08 15:03:26 +08:00
parent 90f41951cd
commit 9157df47e8
2 changed files with 6 additions and 3 deletions

View File

@ -1549,8 +1549,11 @@ func describePersistentVolumeClaim(pvc *corev1.PersistentVolumeClaim, events *co
} }
if pvc.Spec.DataSource != nil { if pvc.Spec.DataSource != nil {
w.Write(LEVEL_0, "DataSource:\n") w.Write(LEVEL_0, "DataSource:\n")
w.Write(LEVEL_1, "Name:\t%v\n", pvc.Spec.DataSource.Name) if pvc.Spec.DataSource.APIGroup != nil {
w.Write(LEVEL_1, "APIGroup:\t%v\n", *pvc.Spec.DataSource.APIGroup)
}
w.Write(LEVEL_1, "Kind:\t%v\n", pvc.Spec.DataSource.Kind) w.Write(LEVEL_1, "Kind:\t%v\n", pvc.Spec.DataSource.Kind)
w.Write(LEVEL_1, "Name:\t%v\n", pvc.Spec.DataSource.Name)
} }
printPodsMultiline(w, "Mounted By", mountPods) printPodsMultiline(w, "Mounted By", mountPods)

View File

@ -1595,7 +1595,7 @@ func TestPersistentVolumeClaimDescriber(t *testing.T) {
}, },
Status: corev1.PersistentVolumeClaimStatus{}, Status: corev1.PersistentVolumeClaimStatus{},
}, },
expectedElements: []string{"\nDataSource:\n Name: srcpvc\n Kind: PersistentVolumeClaim"}, expectedElements: []string{"\nDataSource:\n Kind: PersistentVolumeClaim\n Name: srcpvc"},
}, },
{ {
name: "snapshot-datasource", name: "snapshot-datasource",
@ -1615,7 +1615,7 @@ func TestPersistentVolumeClaimDescriber(t *testing.T) {
}, },
Status: corev1.PersistentVolumeClaimStatus{}, Status: corev1.PersistentVolumeClaimStatus{},
}, },
expectedElements: []string{"DataSource:\n Name: src-snapshot\n Kind: VolumeSnapshot\n"}, expectedElements: []string{"DataSource:\n APIGroup: snapshot.storage.k8s.io\n Kind: VolumeSnapshot\n Name: src-snapshot\n"},
}, },
} }