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

Function resolve_community_image

crates/openshell-core/src/image.rs:37–48  ·  view source on GitHub ↗

Resolve a user-supplied image string into a fully-qualified reference. Resolution rules (applied in order): 1. If the value contains `/`, `:`, or `.` it is treated as a complete image reference and returned as-is. 2. Otherwise it is treated as a community sandbox name and expanded to `{registry}/{value}:latest` where `{registry}` defaults to [`DEFAULT_COMMUNITY_REGISTRY`] but can be overridden vi

(value: &str)

Source from the content-addressed store, hash-verified

35/// This function only handles image-name resolution. Dockerfile detection is
36/// the responsibility of the caller (e.g. the CLI's `resolve_from()`).
37pub fn resolve_community_image(value: &str) -> String {
38 // Already a fully-qualified reference.
39 if value.contains('/') || value.contains(':') || value.contains('.') {
40 return value.to_string();
41 }
42
43 // Community sandbox shorthand → expand with registry prefix.
44 let prefix = std::env::var("OPENSHELL_COMMUNITY_REGISTRY")
45 .unwrap_or_else(|_| DEFAULT_COMMUNITY_REGISTRY.to_string());
46 let prefix = prefix.trim_end_matches('/');
47 format!("{prefix}/{value}:latest")
48}
49
50#[cfg(test)]
51#[allow(unsafe_code)]

Callers 5

spawn_create_sandboxFunction · 0.85
resolve_fromFunction · 0.85

Calls

no outgoing calls