Fix SubPath printing

pull/564/head
Daisuke Taniwaki 2018-11-17 01:41:44 +09:00
parent 7c4d097faf
commit 49d762d929
No known key found for this signature in database
GPG Key ID: 04F90B23F84F5E6B
2 changed files with 20 additions and 4 deletions

View File

@ -1647,12 +1647,12 @@ func describeContainerVolumes(container corev1.Container, w PrefixWriter) {
sort.Sort(SortableVolumeMounts(container.VolumeMounts)) sort.Sort(SortableVolumeMounts(container.VolumeMounts))
for _, mount := range container.VolumeMounts { for _, mount := range container.VolumeMounts {
flags := []string{} flags := []string{}
switch { if mount.ReadOnly {
case mount.ReadOnly:
flags = append(flags, "ro") flags = append(flags, "ro")
case !mount.ReadOnly: } else {
flags = append(flags, "rw") flags = append(flags, "rw")
case len(mount.SubPath) > 0: }
if len(mount.SubPath) > 0 {
flags = append(flags, fmt.Sprintf("path=%q", mount.SubPath)) flags = append(flags, fmt.Sprintf("path=%q", mount.SubPath))
} }
w.Write(LEVEL_3, "%s from %s (%s)\n", mount.MountPath, mount.Name, strings.Join(flags, ",")) w.Write(LEVEL_3, "%s from %s (%s)\n", mount.MountPath, mount.Name, strings.Join(flags, ","))

View File

@ -718,6 +718,22 @@ func TestDescribeContainers(t *testing.T) {
expectedElements: []string{"Mounts", "mounted-volume", "/opt/", "(ro)"}, expectedElements: []string{"Mounts", "mounted-volume", "/opt/", "(ro)"},
}, },
// volumeMounts subPath
{
container: corev1.Container{
Name: "test",
Image: "image",
VolumeMounts: []corev1.VolumeMount{
{
Name: "mounted-volume",
MountPath: "/opt/",
SubPath: "foo",
},
},
},
expectedElements: []string{"Mounts", "mounted-volume", "/opt/", "(rw,path=\"foo\")"},
},
// volumeDevices // volumeDevices
{ {
container: corev1.Container{ container: corev1.Container{