Describe container volume mounts

This commit is contained in:
Michal Fojtik 2016-06-27 13:13:23 +02:00
parent 2baf9b0f27
commit 7ba1e59d84
2 changed files with 35 additions and 0 deletions

View File

@ -887,7 +887,28 @@ func describeContainers(label string, containers []api.Container, containerStatu
probe := DescribeProbe(container.ReadinessProbe)
fmt.Fprintf(out, " Readiness:\t%s\n", probe)
}
none := ""
if len(container.VolumeMounts) == 0 {
none = "\t<none>"
}
fmt.Fprintf(out, " Volume Mounts:%s\n", none)
sort.Sort(SortableVolumeMounts(container.VolumeMounts))
for _, mount := range container.VolumeMounts {
flags := []string{}
switch {
case mount.ReadOnly:
flags = append(flags, "ro")
case !mount.ReadOnly:
flags = append(flags, "rw")
case len(mount.SubPath) > 0:
flags = append(flags, fmt.Sprintf("path=%q", mount.SubPath))
}
fmt.Fprintf(out, " %s from %s (%s)\n", mount.MountPath, mount.Name, strings.Join(flags, ","))
}
none = ""
if len(container.Env) == 0 {
none = "\t<none>"
}

View File

@ -61,6 +61,20 @@ func (list SortableResourceQuotas) Less(i, j int) bool {
return list[i].Name < list[j].Name
}
type SortableVolumeMounts []api.VolumeMount
func (list SortableVolumeMounts) Len() int {
return len(list)
}
func (list SortableVolumeMounts) Swap(i, j int) {
list[i], list[j] = list[j], list[i]
}
func (list SortableVolumeMounts) Less(i, j int) bool {
return list[i].MountPath < list[j].MountPath
}
// SortedQoSResourceNames returns the sorted resource names of a QoS list.
func SortedQoSResourceNames(list qos.QoSList) []api.ResourceName {
resources := make([]api.ResourceName, 0, len(list))