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)
| 35 | /// This function only handles image-name resolution. Dockerfile detection is |
| 36 | /// the responsibility of the caller (e.g. the CLI's `resolve_from()`). |
| 37 | pub 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)] |
no outgoing calls