Skip to content

Commit

Permalink
improves ps
Browse files Browse the repository at this point in the history
now shows context only if `all` argument is provided
  • Loading branch information
mhausenblas committed Jan 25, 2018
1 parent 7edefec commit 0e00a0a
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions dproc.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,19 @@ func (dt *DProcTable) DumpDPT(kubecontext string) string {
var b bytes.Buffer
w := bufio.NewWriter(&b)
tw := tabwriter.NewWriter(w, 0, 0, 2, ' ', 0)
fmt.Fprintln(tw, "DPID\tCONTEXT\tSOURCE\tURL")
for _, dproc := range dt.lt {
switch kubecontext {
case "":
// fmt.Fprintln(tw, fmt.Sprintf("%s\t%s\t%s\t", dproc.ID, dproc.KubeContext, dproc.Src))
case dproc.KubeContext:
switch kubecontext {
case "":
fmt.Fprintln(tw, "DPID\tCONTEXT\tSOURCE\tURL")
for _, dproc := range dt.lt {
fmt.Fprintln(tw, fmt.Sprintf("%s\t%s\t%s\t%s\t", dproc.ID, dproc.KubeContext, dproc.Src, dproc.ServiceName))
}
default:
fmt.Fprintln(tw, "DPID\tSOURCE\tURL")
for _, dproc := range dt.lt {
if dproc.KubeContext == kubecontext {
fmt.Fprintln(tw, fmt.Sprintf("%s\t%s\t%s\t", dproc.ID, dproc.Src, dproc.ServiceName))
}
}
}
_ = tw.Flush()
_ = w.Flush()
Expand Down

0 comments on commit 0e00a0a

Please sign in to comment.