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

Function build_labels

crates/openshell-driver-podman/src/container.rs:433–449  ·  view source on GitHub ↗

Merge labels from the sandbox template with required managed labels. User-supplied labels are inserted first so that the managed labels always win -- preventing template overrides of internal tracking labels.

(sandbox: &DriverSandbox)

Source from the content-addressed store, hash-verified

431/// User-supplied labels are inserted first so that the managed labels
432/// always win -- preventing template overrides of internal tracking labels.
433fn build_labels(sandbox: &DriverSandbox) -> BTreeMap<String, String> {
434 let template = sandbox.spec.as_ref().and_then(|s| s.template.as_ref());
435
436 let mut labels: BTreeMap<String, String> = BTreeMap::new();
437 if let Some(t) = template {
438 for (k, v) in &t.labels {
439 labels.insert(k.clone(), v.clone());
440 }
441 }
442 // Managed labels (highest priority -- always overwrite).
443 labels.insert(LABEL_SANDBOX_ID.into(), sandbox.id.clone());
444 labels.insert(LABEL_SANDBOX_NAME.into(), sandbox.name.clone());
445 labels.insert(LABEL_SANDBOX_NAMESPACE.into(), sandbox.namespace.clone());
446 labels.insert(LABEL_MANAGED.into(), "true".into());
447
448 labels
449}
450
451/// Parse resource limits from the sandbox template, falling back to defaults.
452fn build_resource_limits(sandbox: &DriverSandbox, config: &PodmanComputeConfig) -> ResourceLimits {

Calls

no outgoing calls

Tested by

no test coverage detected