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

Function sandbox_settings_get

crates/openshell-cli/src/run.rs:6333–6400  ·  view source on GitHub ↗
(
    server: &str,
    name: &str,
    json: bool,
    tls: &TlsOptions,
)

Source from the content-addressed store, hash-verified

6331}
6332
6333pub async fn sandbox_settings_get(
6334 server: &str,
6335 name: &str,
6336 json: bool,
6337 tls: &TlsOptions,
6338) -> Result<()> {
6339 let mut client = grpc_client(server, tls).await?;
6340 let sandbox = client
6341 .get_sandbox(GetSandboxRequest {
6342 name: name.to_string(),
6343 })
6344 .await
6345 .into_diagnostic()?
6346 .into_inner()
6347 .sandbox
6348 .ok_or_else(|| miette::miette!("sandbox not found"))?;
6349
6350 let response = client
6351 .get_sandbox_config(GetSandboxConfigRequest {
6352 sandbox_id: sandbox.object_id().to_string(),
6353 })
6354 .await
6355 .into_diagnostic()?
6356 .into_inner();
6357
6358 if json {
6359 let obj = settings_to_json_sandbox(name, &response);
6360 println!("{}", serde_json::to_string_pretty(&obj).into_diagnostic()?);
6361 return Ok(());
6362 }
6363
6364 let policy_source = if response.policy_source == PolicySource::Global as i32 {
6365 "global"
6366 } else {
6367 "sandbox"
6368 };
6369
6370 println!("Sandbox: {name}");
6371 println!("Config Rev: {}", response.config_revision);
6372 println!("Policy Source: {policy_source}");
6373 println!("Policy Hash: {}", response.policy_hash);
6374
6375 if response.settings.is_empty() {
6376 println!("Settings: No settings available.");
6377 return Ok(());
6378 }
6379
6380 println!("Settings:");
6381 let mut keys: Vec<_> = response.settings.keys().cloned().collect();
6382 keys.sort();
6383 for key in keys {
6384 if let Some(setting) = response.settings.get(&key) {
6385 let scope = match SettingScope::try_from(setting.scope) {
6386 Ok(SettingScope::Global) => "global",
6387 Ok(SettingScope::Sandbox) => "sandbox",
6388 _ => "unset",
6389 };
6390 println!(

Callers 1

mainFunction · 0.85

Calls 7

grpc_clientFunction · 0.85
settings_to_json_sandboxFunction · 0.85
object_idMethod · 0.80
get_sandboxMethod · 0.45
get_sandbox_configMethod · 0.45
is_emptyMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected