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

Function status_from_object

crates/openshell-driver-kubernetes/src/driver.rs:2125–2164  ·  view source on GitHub ↗
(obj: &DynamicObject)

Source from the content-addressed store, hash-verified

2123}
2124
2125fn status_from_object(obj: &DynamicObject) -> Option<SandboxStatus> {
2126 let status = obj.data.get("status")?;
2127 let status_obj = status.as_object()?;
2128
2129 let conditions = status_obj
2130 .get("conditions")
2131 .and_then(|val| val.as_array())
2132 .map(|items| {
2133 items
2134 .iter()
2135 .filter_map(condition_from_value)
2136 .collect::<Vec<_>>()
2137 })
2138 .unwrap_or_default();
2139
2140 Some(SandboxStatus {
2141 sandbox_name: status_obj
2142 .get("sandboxName")
2143 .and_then(|val| val.as_str())
2144 .unwrap_or_default()
2145 .to_string(),
2146 instance_id: status_obj
2147 .get("agentPod")
2148 .and_then(|val| val.as_str())
2149 .unwrap_or_default()
2150 .to_string(),
2151 agent_fd: status_obj
2152 .get("agentFd")
2153 .and_then(|val| val.as_str())
2154 .unwrap_or_default()
2155 .to_string(),
2156 sandbox_fd: status_obj
2157 .get("sandboxFd")
2158 .and_then(|val| val.as_str())
2159 .unwrap_or_default()
2160 .to_string(),
2161 conditions,
2162 deleting: obj.metadata.deletion_timestamp.is_some(),
2163 })
2164}
2165
2166fn condition_from_value(value: &serde_json::Value) -> Option<SandboxCondition> {
2167 let obj = value.as_object()?;

Callers 1

sandbox_from_objectFunction · 0.85

Calls 2

getMethod · 0.45
as_strMethod · 0.45

Tested by

no test coverage detected