diff --git a/cmd/main.go b/cmd/main.go index 0c84b8d..08b1f40 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -9,7 +9,7 @@ import ( "github.com/spf13/cobra" ) -const version = "0.6.2" +const version = "0.6.3" var rootCmd *cobra.Command diff --git a/kubectl_images.go b/kubectl_images.go index 5e5227d..087ceb6 100644 --- a/kubectl_images.go +++ b/kubectl_images.go @@ -336,13 +336,27 @@ func (ki *KubeImage) tableRender() { table.SetAutoMergeCells(true) table.SetRowLine(true) - entities := ki.groupBy() + entities := ki.getGroupByEntities() for _, entity := range entities { - table.Append(entity.selectBy(ki.columns)) + table.Append(entity) } table.Render() } +func (ki *KubeImage) getGroupByEntities() [][]string { + set := make(map[string]struct{}) + dst := make([][]string, 0) + for _, entity := range ki.groupBy() { + line := strings.Join(entity.selectBy(ki.columns), "||") + _, ok := set[line] + if !ok { + set[line] = struct{}{} + dst = append(dst, strings.Split(line, "||")) + } + } + return dst +} + func (ki *KubeImage) jsonRender() { entities := ki.groupBy() records := make([]ImageEntity, 0, len(entities))