Fetch sandbox policy using an existing client connection.
(
client: &mut OpenShellClient<AuthedChannel>,
sandbox_id: &str,
)
| 575 | |
| 576 | /// Fetch sandbox policy using an existing client connection. |
| 577 | async fn fetch_policy_with_client( |
| 578 | client: &mut OpenShellClient<AuthedChannel>, |
| 579 | sandbox_id: &str, |
| 580 | ) -> Result<Option<ProtoSandboxPolicy>> { |
| 581 | let response = client |
| 582 | .get_sandbox_config(GetSandboxConfigRequest { |
| 583 | sandbox_id: sandbox_id.to_string(), |
| 584 | }) |
| 585 | .await |
| 586 | .into_diagnostic()?; |
| 587 | |
| 588 | let inner = response.into_inner(); |
| 589 | |
| 590 | // version 0 with no policy means the sandbox was created without one. |
| 591 | if inner.version == 0 && inner.policy.is_none() { |
| 592 | return Ok(None); |
| 593 | } |
| 594 | |
| 595 | Ok(Some(inner.policy.ok_or_else(|| { |
| 596 | miette::miette!("Server returned non-zero version but empty policy") |
| 597 | })?)) |
| 598 | } |
| 599 | |
| 600 | /// Sync a locally-discovered policy using an existing client connection. |
| 601 | async fn sync_policy_with_client( |
no test coverage detected