From 7ba1e59d84b6f548fb0b844f33a11de9746a1bc2 Mon Sep 17 00:00:00 2001 From: Michal Fojtik Date: Mon, 27 Jun 2016 13:13:23 +0200 Subject: [PATCH] Describe container volume mounts --- pkg/kubectl/describe.go | 21 +++++++++++++++++++++ pkg/kubectl/sorted_resource_name_list.go | 14 ++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/pkg/kubectl/describe.go b/pkg/kubectl/describe.go index adf7593f3af..af9e893b0cb 100644 --- a/pkg/kubectl/describe.go +++ b/pkg/kubectl/describe.go @@ -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" + } + + 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" } diff --git a/pkg/kubectl/sorted_resource_name_list.go b/pkg/kubectl/sorted_resource_name_list.go index bf25b1cebac..41a7ae9a4c7 100644 --- a/pkg/kubectl/sorted_resource_name_list.go +++ b/pkg/kubectl/sorted_resource_name_list.go @@ -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))