From 96928b9f8b6df751815fe49007cfc73272cc1cdb Mon Sep 17 00:00:00 2001 From: zouyee Date: Sun, 18 Aug 2019 11:37:26 +0800 Subject: [PATCH] convert EndpointNamespace showing string rather than pointer Signed-off-by: Zou Nengren --- .../kubectl/pkg/describe/versioned/describe.go | 6 +++++- .../pkg/describe/versioned/describe_test.go | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/staging/src/k8s.io/kubectl/pkg/describe/versioned/describe.go b/staging/src/k8s.io/kubectl/pkg/describe/versioned/describe.go index 4adbaa157a3..d74a63fcf0a 100644 --- a/staging/src/k8s.io/kubectl/pkg/describe/versioned/describe.go +++ b/staging/src/k8s.io/kubectl/pkg/describe/versioned/describe.go @@ -997,12 +997,16 @@ func printGlusterfsVolumeSource(glusterfs *corev1.GlusterfsVolumeSource, w Prefi } func printGlusterfsPersistentVolumeSource(glusterfs *corev1.GlusterfsPersistentVolumeSource, w PrefixWriter) { + endpointsNamespace := "" + if glusterfs.EndpointsNamespace != nil { + endpointsNamespace = *glusterfs.EndpointsNamespace + } w.Write(LEVEL_2, "Type:\tGlusterfs (a Glusterfs mount on the host that shares a pod's lifetime)\n"+ " EndpointsName:\t%v\n"+ " EndpointsNamespace:\t%v\n"+ " Path:\t%v\n"+ " ReadOnly:\t%v\n", - glusterfs.EndpointsName, glusterfs.EndpointsNamespace, glusterfs.Path, glusterfs.ReadOnly) + glusterfs.EndpointsName, endpointsNamespace, glusterfs.Path, glusterfs.ReadOnly) } func printPersistentVolumeClaimVolumeSource(claim *corev1.PersistentVolumeClaimVolumeSource, w PrefixWriter) { diff --git a/staging/src/k8s.io/kubectl/pkg/describe/versioned/describe_test.go b/staging/src/k8s.io/kubectl/pkg/describe/versioned/describe_test.go index a36cdbebe5f..1893f2373b5 100644 --- a/staging/src/k8s.io/kubectl/pkg/describe/versioned/describe_test.go +++ b/staging/src/k8s.io/kubectl/pkg/describe/versioned/describe_test.go @@ -937,6 +937,7 @@ func TestGetPodsTotalRequests(t *testing.T) { func TestPersistentVolumeDescriber(t *testing.T) { block := corev1.PersistentVolumeBlock file := corev1.PersistentVolumeFilesystem + foo := "glusterfsendpointname" deletionTimestamp := metav1.Time{Time: time.Now().UTC().AddDate(-10, 0, 0)} testCases := []struct { name string @@ -1023,6 +1024,7 @@ func TestPersistentVolumeDescriber(t *testing.T) { }, }, }, + expectedElements: []string{"EndpointsNamespace", ""}, unexpectedElements: []string{"VolumeMode", "Filesystem"}, }, { @@ -1273,6 +1275,22 @@ func TestPersistentVolumeDescriber(t *testing.T) { }, expectedElements: []string{"Driver", "VolumeHandle", "ReadOnly", "VolumeAttributes"}, }, + { + name: "test19", + plugin: "gluster", + pv: &corev1.PersistentVolume{ + ObjectMeta: metav1.ObjectMeta{Name: "bar"}, + Spec: corev1.PersistentVolumeSpec{ + PersistentVolumeSource: corev1.PersistentVolumeSource{ + Glusterfs: &corev1.GlusterfsPersistentVolumeSource{ + EndpointsNamespace: &foo, + }, + }, + }, + }, + expectedElements: []string{"EndpointsNamespace", "glusterfsendpointname"}, + unexpectedElements: []string{"VolumeMode", "Filesystem"}, + }, } for _, test := range testCases {