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

Function settings_to_json_sandbox

crates/openshell-cli/src/run.rs:6435–6472  ·  view source on GitHub ↗
(
    name: &str,
    response: &openshell_core::proto::GetSandboxConfigResponse,
)

Source from the content-addressed store, hash-verified

6433}
6434
6435fn settings_to_json_sandbox(
6436 name: &str,
6437 response: &openshell_core::proto::GetSandboxConfigResponse,
6438) -> serde_json::Value {
6439 let policy_source = if response.policy_source == PolicySource::Global as i32 {
6440 "global"
6441 } else {
6442 "sandbox"
6443 };
6444
6445 let mut settings = serde_json::Map::new();
6446 let mut keys: Vec<_> = response.settings.keys().cloned().collect();
6447 keys.sort();
6448 for key in keys {
6449 if let Some(setting) = response.settings.get(&key) {
6450 let scope = match SettingScope::try_from(setting.scope) {
6451 Ok(SettingScope::Global) => "global",
6452 Ok(SettingScope::Sandbox) => "sandbox",
6453 _ => "unset",
6454 };
6455 settings.insert(
6456 key,
6457 serde_json::json!({
6458 "value": format_setting_value(setting.value.as_ref()),
6459 "scope": scope,
6460 }),
6461 );
6462 }
6463 }
6464
6465 serde_json::json!({
6466 "sandbox": name,
6467 "config_revision": response.config_revision,
6468 "policy_source": policy_source,
6469 "policy_hash": response.policy_hash,
6470 "settings": settings,
6471 })
6472}
6473
6474fn settings_to_json_global(
6475 response: &openshell_core::proto::GetGatewayConfigResponse,

Callers 1

sandbox_settings_getFunction · 0.85

Calls 1

getMethod · 0.45

Tested by

no test coverage detected