(app: &mut App)
| 2267 | } |
| 2268 | |
| 2269 | async fn refresh_sandboxes(app: &mut App) { |
| 2270 | let req = openshell_core::proto::ListSandboxesRequest { |
| 2271 | limit: 100, |
| 2272 | offset: 0, |
| 2273 | label_selector: String::new(), |
| 2274 | }; |
| 2275 | let result = tokio::time::timeout(Duration::from_secs(5), app.client.list_sandboxes(req)).await; |
| 2276 | match result { |
| 2277 | Ok(Err(e)) => { |
| 2278 | tracing::warn!("failed to list sandboxes: {}", e.message()); |
| 2279 | } |
| 2280 | Err(_) => { |
| 2281 | tracing::warn!("list sandboxes timed out"); |
| 2282 | } |
| 2283 | Ok(Ok(resp)) => { |
| 2284 | let sandboxes = resp.into_inner().sandboxes; |
| 2285 | app.sandbox_count = sandboxes.len(); |
| 2286 | app.sandbox_ids = sandboxes |
| 2287 | .iter() |
| 2288 | .map(|s| s.object_id().to_string()) |
| 2289 | .collect(); |
| 2290 | app.sandbox_names = sandboxes |
| 2291 | .iter() |
| 2292 | .map(|s| s.object_name().to_string()) |
| 2293 | .collect(); |
| 2294 | app.sandbox_phases = sandboxes.iter().map(|s| phase_label(s.phase())).collect(); |
| 2295 | app.sandbox_images = sandboxes |
| 2296 | .iter() |
| 2297 | .map(|s| { |
| 2298 | s.spec |
| 2299 | .as_ref() |
| 2300 | .and_then(|spec| spec.template.as_ref()) |
| 2301 | .map(|t| t.image.as_str()) |
| 2302 | .filter(|img| !img.is_empty()) |
| 2303 | .unwrap_or("-") |
| 2304 | .to_string() |
| 2305 | }) |
| 2306 | .collect(); |
| 2307 | app.sandbox_ages = sandboxes |
| 2308 | .iter() |
| 2309 | .map(|s| { |
| 2310 | s.metadata |
| 2311 | .as_ref() |
| 2312 | .map_or_else(|| "?".to_string(), |m| format_age(m.created_at_ms)) |
| 2313 | }) |
| 2314 | .collect(); |
| 2315 | app.sandbox_created = sandboxes |
| 2316 | .iter() |
| 2317 | .map(|s| { |
| 2318 | s.metadata |
| 2319 | .as_ref() |
| 2320 | .map_or_else(|| "?".to_string(), |m| format_timestamp(m.created_at_ms)) |
| 2321 | }) |
| 2322 | .collect(); |
| 2323 | |
| 2324 | app.sandbox_policy_versions = sandboxes |
| 2325 | .iter() |
| 2326 | .map(openshell_core::proto::Sandbox::current_policy_version) |
no test coverage detected