convert EndpointNamespace showing string rather than pointer

Signed-off-by: Zou Nengren <zouyee1989@gmail.com>
This commit is contained in:
zouyee 2019-08-18 11:37:26 +08:00
parent 47e78f3de5
commit 96928b9f8b
2 changed files with 23 additions and 1 deletions

View File

@ -997,12 +997,16 @@ func printGlusterfsVolumeSource(glusterfs *corev1.GlusterfsVolumeSource, w Prefi
}
func printGlusterfsPersistentVolumeSource(glusterfs *corev1.GlusterfsPersistentVolumeSource, w PrefixWriter) {
endpointsNamespace := "<unset>"
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) {

View File

@ -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", "<unset>"},
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 {