(record SessionInspectRecord)
| 1272 | } |
| 1273 | |
| 1274 | func sessionInspectBundle(record SessionInspectRecord) outputBundle { |
| 1275 | return outputBundle{ |
| 1276 | jsonValue: record, |
| 1277 | human: func() (string, error) { |
| 1278 | blocks := []string{ |
| 1279 | sessionHealthSection("Session Health", record.Health), |
| 1280 | renderHumanSection("Policy Correlation", []keyValue{ |
| 1281 | {Label: "Policy Digest", Value: stringOrDash(record.PolicyDigest)}, |
| 1282 | {Label: authoredContextConfigDigestValue, Value: stringOrDash(record.ConfigDigest)}, |
| 1283 | }), |
| 1284 | diagnosticsTable(record.Diagnostics), |
| 1285 | } |
| 1286 | if record.WakeState != nil { |
| 1287 | blocks = append(blocks, wakeStateSection("Wake State", *record.WakeState)) |
| 1288 | } |
| 1289 | if len(record.WakeEvents) > 0 { |
| 1290 | blocks = append(blocks, wakeEventsTable(record.WakeEvents)) |
| 1291 | } |
| 1292 | return renderHumanBlocks(blocks...), nil |
| 1293 | }, |
| 1294 | toon: func() (string, error) { |
| 1295 | return renderToonObject("session_inspect", []string{ |
| 1296 | sessionSessionKey, "policy_digest", authoredContextConfigDigestKey, "wake_events", |
| 1297 | }, []string{ |
| 1298 | record.SessionID, |
| 1299 | record.PolicyDigest, |
| 1300 | record.ConfigDigest, |
| 1301 | strconv.Itoa(len(record.WakeEvents)), |
| 1302 | }), nil |
| 1303 | }, |
| 1304 | } |
| 1305 | } |
| 1306 | |
| 1307 | func sessionHealthSection(title string, record SessionHealthRecord) string { |
| 1308 | return renderHumanSection(title, []keyValue{ |
no test coverage detected