mirror of https://github.com/k3s-io/k3s
Fix SubPath printing
parent
7c4d097faf
commit
49d762d929
|
@ -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, ","))
|
||||||
|
|
|
@ -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{
|
||||||
|
|
Loading…
Reference in New Issue