MCPcopy Create free account
hub / github.com/hashicorp/vault / noReportAvailable

Method noReportAvailable

command/operator_usage.go:157–182  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

155// queries can be answered; if there's an error, just fall back to
156// reporting that the response is empty.
157func (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
184func (c *OperatorUsageCommand) outputTimestamps(data map[string]interface{}) {
185 c.UI.Output(fmt.Sprintf("Period start: %v\nPeriod end: %v\n",

Callers 1

RunMethod · 0.95

Calls 3

LogicalMethod · 0.80
WarnMethod · 0.65
ReadMethod · 0.45

Tested by

no test coverage detected