noReportAvailable checks whether we can definitively say that no queries can be answered; if there's an error, just fall back to reporting that the response is empty.
(client *api.Client)
| 155 | // queries can be answered; if there's an error, just fall back to |
| 156 | // reporting that the response is empty. |
| 157 | func (c *OperatorUsageCommand) noReportAvailable(client *api.Client) bool { |
| 158 | if c.flagOutputCurlString || c.flagOutputPolicy { |
| 159 | // Don't mess up the original query string |
| 160 | return false |
| 161 | } |
| 162 | |
| 163 | resp, err := client.Logical().Read("sys/internal/counters/config") |
| 164 | if err != nil || resp == nil || resp.Data == nil { |
| 165 | c.UI.Warn("bad response from config") |
| 166 | return false |
| 167 | } |
| 168 | |
| 169 | qaRaw, ok := resp.Data["queries_available"] |
| 170 | if !ok { |
| 171 | c.UI.Warn("no queries_available key") |
| 172 | return false |
| 173 | } |
| 174 | |
| 175 | qa, ok := qaRaw.(bool) |
| 176 | if !ok { |
| 177 | c.UI.Warn("wrong type") |
| 178 | return false |
| 179 | } |
| 180 | |
| 181 | return !qa |
| 182 | } |
| 183 | |
| 184 | func (c *OperatorUsageCommand) outputTimestamps(data map[string]interface{}) { |
| 185 | c.UI.Output(fmt.Sprintf("Period start: %v\nPeriod end: %v\n", |