Skip to content

Commit

Permalink
stat: support -ojson option with srv resources (#6959)
Browse files Browse the repository at this point in the history
Policy resources are already supported just like
any other resources. For `srv`, the newly `unauthorized`
field is missed in the json response.

This PR tries to fix that.

Signed-off-by: Tarun Pothulapati <[email protected]>
  • Loading branch information
Pothulapati authored Sep 23, 2021
1 parent 05f7d87 commit 61cd107
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions viz/cmd/stat.go
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,7 @@ type jsonStats struct {
Leaf string `json:"leaf,omitempty"`
Dst string `json:"dst,omitempty"`
Weight string `json:"weight,omitempty"`
Unauthorized *float64 `json:"unauthorized,omitempty"`
}

func printStatJSON(statTables map[string]map[string]*row, w *tabwriter.Writer) {
Expand Down Expand Up @@ -803,6 +804,12 @@ func printStatJSON(statTables map[string]map[string]*row, w *tabwriter.Writer) {
entry.Dst = stats[key].dstStats.dst
entry.Weight = stats[key].dstStats.weight
}

if resourceType == k8s.Server {
if stats[key].srvStats != nil {
entry.Unauthorized = &stats[key].srvStats.unauthorizedRate
}
}
entries = append(entries, entry)
}
}
Expand Down

0 comments on commit 61cd107

Please sign in to comment.