Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display PodInfo in table format #178

Merged
merged 1 commit into from
Sep 12, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 25 additions & 3 deletions summary/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ func DisplaySummaryOutput(resp *opb.Response, revDNSLookup bool, requestType str
return
}

podInfo := resp.PodName + "/" + resp.Namespace + "/" + resp.ClusterName + "/" + resp.Label + "/" + resp.ContainerName

fmt.Printf("\nPodInfo : [%s]\n", podInfo)
writePodInfoToTable(resp.PodName, resp.Namespace, resp.ClusterName, resp.ContainerName, resp.Label)

if strings.Contains(requestType, "process") {
if len(resp.ProcessData) > 0 {
Expand Down Expand Up @@ -136,3 +134,27 @@ func WriteTable(header []string, data [][]string) {
}
table.Render()
}

func writePodInfoToTable(podname, namespace, clustername, containername, labels string) {

fmt.Printf("\n")

podinfo := [][]string{
{"Pod Name", podname},
{"Namespace Name", namespace},
{"Cluster Name", clustername},
{"Container Name", containername},
{"Labels", labels},
}
table := tablewriter.NewWriter(os.Stdout)
table.SetBorder(false)
table.SetTablePadding("\t")
table.SetCenterSeparator("")
table.SetColumnSeparator("")
table.SetRowSeparator("")
table.SetAlignment(tablewriter.ALIGN_LEFT)
for _, v := range podinfo {
table.Append(v)
}
table.Render()
}