From a74ab69745a8a1e845574c26c91a3c5ce9b1c1af Mon Sep 17 00:00:00 2001 From: Sascha Grunert Date: Tue, 15 Oct 2024 10:00:23 +0200 Subject: [PATCH] crictl ps: output container namespace Signed-off-by: Sascha Grunert --- cmd/crictl/container.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cmd/crictl/container.go b/cmd/crictl/container.go index 503bbca3c0..2290902201 100644 --- a/cmd/crictl/container.go +++ b/cmd/crictl/container.go @@ -1219,7 +1219,7 @@ func OutputContainers(runtimeClient internalapi.RuntimeService, imageClient inte display := newDefaultTableDisplay() if !opts.verbose && !opts.quiet { - display.AddRow([]string{columnContainer, columnImage, columnCreated, columnState, columnName, columnAttempt, columnPodID, columnPodName}) + display.AddRow([]string{columnContainer, columnImage, columnCreated, columnState, columnName, columnAttempt, columnPodID, columnPodName, columnNamespace}) } for _, c := range r { if match, err := matchesImage(imageClient, opts.image, c.GetImage().GetImage()); err != nil { @@ -1234,6 +1234,7 @@ func OutputContainers(runtimeClient internalapi.RuntimeService, imageClient inte createdAt := time.Unix(0, c.CreatedAt) ctm := units.HumanDuration(time.Now().UTC().Sub(createdAt)) + " ago" + podNamespace := getPodNamespaceFromLabels(c.Labels) if !opts.verbose { id := c.Id image := c.Image.Image @@ -1256,13 +1257,14 @@ func OutputContainers(runtimeClient internalapi.RuntimeService, imageClient inte podName := getPodNameFromLabels(c.Labels) display.AddRow([]string{ id, image, ctm, convertContainerState(c.State), c.Metadata.Name, - strconv.FormatUint(uint64(c.Metadata.Attempt), 10), podID, podName, + strconv.FormatUint(uint64(c.Metadata.Attempt), 10), podID, podName, podNamespace, }) continue } fmt.Printf("ID: %s\n", c.Id) fmt.Printf("PodID: %s\n", c.PodSandboxId) + fmt.Printf("Namespace: %s\n", podNamespace) if c.Metadata != nil { if c.Metadata.Name != "" { fmt.Printf("Name: %s\n", c.Metadata.Name)