Merge pull request #76463 from j-griffith/add_datasource_to_pvc_describe

Add DataSource to PVC describe
This commit is contained in:
Kubernetes Prow Robot 2019-08-13 14:15:38 -07:00 committed by GitHub
commit 9dad928e6b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 51 additions and 0 deletions

View File

@ -1534,6 +1534,11 @@ func describePersistentVolumeClaim(pvc *corev1.PersistentVolumeClaim, events *co
if pvc.Spec.VolumeMode != nil {
w.Write(LEVEL_0, "VolumeMode:\t%v\n", *pvc.Spec.VolumeMode)
}
if pvc.Spec.DataSource != nil {
w.Write(LEVEL_0, "DataSource:\n")
w.Write(LEVEL_1, "Name:\t%v\n", pvc.Spec.DataSource.Name)
w.Write(LEVEL_1, "Kind:\t%v\n", pvc.Spec.DataSource.Kind)
}
printPodsMultiline(w, "Mounted By", mountPods)
if len(pvc.Status.Conditions) > 0 {

View File

@ -1306,6 +1306,7 @@ func TestPersistentVolumeClaimDescriber(t *testing.T) {
goldClassName := "gold"
now := time.Now()
deletionTimestamp := metav1.Time{Time: time.Now().UTC().AddDate(-10, 0, 0)}
snapshotAPIGroup := "snapshot.storage.k8s.io"
testCases := []struct {
name string
pvc *corev1.PersistentVolumeClaim
@ -1469,6 +1470,45 @@ func TestPersistentVolumeClaimDescriber(t *testing.T) {
},
expectedElements: []string{"Terminating (lasts 10y)"},
},
{
name: "pvc-datasource",
pvc: &corev1.PersistentVolumeClaim{
ObjectMeta: metav1.ObjectMeta{
Namespace: "foo",
Name: "bar",
},
Spec: corev1.PersistentVolumeClaimSpec{
VolumeName: "volume10",
StorageClassName: &goldClassName,
DataSource: &corev1.TypedLocalObjectReference{
Name: "srcpvc",
Kind: "PersistentVolumeClaim",
},
},
Status: corev1.PersistentVolumeClaimStatus{},
},
expectedElements: []string{"\nDataSource:\n Name: srcpvc\n Kind: PersistentVolumeClaim"},
},
{
name: "snapshot-datasource",
pvc: &corev1.PersistentVolumeClaim{
ObjectMeta: metav1.ObjectMeta{
Namespace: "foo",
Name: "bar",
},
Spec: corev1.PersistentVolumeClaimSpec{
VolumeName: "volume10",
StorageClassName: &goldClassName,
DataSource: &corev1.TypedLocalObjectReference{
Name: "src-snapshot",
Kind: "VolumeSnapshot",
APIGroup: &snapshotAPIGroup,
},
},
Status: corev1.PersistentVolumeClaimStatus{},
},
expectedElements: []string{"DataSource:\n Name: src-snapshot\n Kind: VolumeSnapshot\n"},
},
}
for _, test := range testCases {
@ -3090,6 +3130,12 @@ func TestDescribeStatefulSet(t *testing.T) {
}
}
// boolPtr returns a pointer to a bool
func boolPtr(b bool) *bool {
o := b
return &o
}
func TestControllerRef(t *testing.T) {
var replicas int32 = 1
f := fake.NewSimpleClientset(