From 4b8d3e0d2c24a51e23bdd6b7d98e1d7c4ec1dc1e Mon Sep 17 00:00:00 2001 From: Yashodhan Mohan Bhatnagar Date: Wed, 1 Mar 2023 19:36:58 +0530 Subject: [PATCH 1/2] add location of image in the cluster --- cmd/community_images/cli/header.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/cmd/community_images/cli/header.go b/cmd/community_images/cli/header.go index ad672a5..22063fe 100644 --- a/cmd/community_images/cli/header.go +++ b/cmd/community_images/cli/header.go @@ -2,6 +2,7 @@ package cli import ( "fmt" + "github.com/dims/community-images/pkg/community_images" ) @@ -15,8 +16,22 @@ func imageWithTag(image community_images.RunningImage) string { return "" } + location := "" + location = fmt.Sprintf("\u001B[36m(Location: \u001B[33m%s > %s", image.Namespace, image.Pod) + if image.InitContainer != nil { + location = fmt.Sprintf("%s > \u001B[33m%s", location, *image.InitContainer) + } + if image.Container != nil { + marker := ">" + if image.InitContainer != nil { + marker = "," + } + location = fmt.Sprintf("%s %s \u001B[33m%s", location, marker, *image.Container) + } + location = fmt.Sprintf("%s\u001B[36m)", location) + imageName := fmt.Sprintf("%s/%s", repo, img) truncatedImageName := imageName truncatedTagName := tag - return fmt.Sprintf("%s:%s", truncatedImageName, truncatedTagName) + return fmt.Sprintf("%s:%s %s", truncatedImageName, truncatedTagName, location) } From ea690d0f4946df4bfe34a26ccab6283efff158bd Mon Sep 17 00:00:00 2001 From: Yashodhan Mohan Bhatnagar Date: Wed, 1 Mar 2023 19:41:08 +0530 Subject: [PATCH 2/2] redundant assignment removed --- cmd/community_images/cli/header.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cmd/community_images/cli/header.go b/cmd/community_images/cli/header.go index 22063fe..b8854db 100644 --- a/cmd/community_images/cli/header.go +++ b/cmd/community_images/cli/header.go @@ -16,8 +16,7 @@ func imageWithTag(image community_images.RunningImage) string { return "" } - location := "" - location = fmt.Sprintf("\u001B[36m(Location: \u001B[33m%s > %s", image.Namespace, image.Pod) + location := fmt.Sprintf("\u001B[36m(Location: \u001B[33m%s > %s", image.Namespace, image.Pod) if image.InitContainer != nil { location = fmt.Sprintf("%s > \u001B[33m%s", location, *image.InitContainer) }