MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / sandbox_policy_get_to_writer

Function sandbox_policy_get_to_writer

crates/openshell-cli/src/run.rs:6974–7060  ·  view source on GitHub ↗
(
    server: &str,
    name: &str,
    version: u32,
    view: PolicyGetView,
    output: &str,
    tls: &TlsOptions,
    writers: (&mut W, &mut E),
)

Source from the content-addressed store, hash-verified

6972
6973#[doc(hidden)]
6974pub async fn sandbox_policy_get_to_writer<W, E>(
6975 server: &str,
6976 name: &str,
6977 version: u32,
6978 view: PolicyGetView,
6979 output: &str,
6980 tls: &TlsOptions,
6981 writers: (&mut W, &mut E),
6982) -> Result<()>
6983where
6984 W: Write + Send,
6985 E: Write + Send,
6986{
6987 if version == 0 {
6988 return sandbox_policy_get_effective_to_writer(server, name, view, output, tls, writers)
6989 .await;
6990 }
6991
6992 let (stdout, stderr) = writers;
6993 let mut client = grpc_client(server, tls).await?;
6994
6995 let status_resp = client
6996 .get_sandbox_policy_status(GetSandboxPolicyStatusRequest {
6997 name: name.to_string(),
6998 version,
6999 global: false,
7000 })
7001 .await
7002 .into_diagnostic()?;
7003
7004 let inner = status_resp.into_inner();
7005 if let Some(rev) = inner.revision {
7006 let status = PolicyStatus::try_from(rev.status).unwrap_or(PolicyStatus::Unspecified);
7007 match output {
7008 "json" => {
7009 let obj = policy_revision_to_json(
7010 "sandbox",
7011 Some(name),
7012 Some(inner.active_version),
7013 &rev,
7014 status,
7015 view,
7016 )?;
7017 writeln!(
7018 stdout,
7019 "{}",
7020 serde_json::to_string_pretty(&obj).into_diagnostic()?
7021 )
7022 .into_diagnostic()?;
7023 return Ok(());
7024 }
7025 "table" => {}
7026 _ => return Err(miette!("unsupported output format: {output}")),
7027 }
7028
7029 writeln!(stdout, "Version: {}", rev.version).into_diagnostic()?;
7030 writeln!(stdout, "Hash: {}", rev.policy_hash).into_diagnostic()?;
7031 writeln!(stdout, "Status: {status:?}").into_diagnostic()?;

Calls 8

grpc_clientFunction · 0.85
policy_revision_to_jsonFunction · 0.85
policy_for_viewFunction · 0.85
serialize_sandbox_policyFunction · 0.85
includes_policyMethod · 0.80
is_emptyMethod · 0.45