Skip to content

Commit 778ad02

Browse files
committed
refactor(cli)!: remove community image resolution
Remove DEFAULT_COMMUNITY_REGISTRY, resolve_community_image, and the OPENSHELL_COMMUNITY_REGISTRY override. Bare --from values are no longer expanded into the OpenShell Community registry; the CLI and TUI now pass explicit OCI image references through to the gateway unchanged. The openshell-core image module is reduced to default_sandbox_image(). BREAKING CHANGE: community sandbox shorthand names and OPENSHELL_COMMUNITY_REGISTRY are no longer supported; pass a full OCI image reference to --from. Part of #3116. Signed-off-by: Akram <akram.benaissi@gmail.com>
1 parent bfb6987 commit 778ad02

4 files changed

Lines changed: 10 additions & 125 deletions

File tree

‎crates/openshell-cli/src/main.rs‎

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1275,13 +1275,9 @@ enum SandboxCommands {
12751275
#[arg(long, conflicts_with_all = ["from", "gpu", "cpu", "memory", "driver_config_json", "envs"])]
12761276
template: Option<String>,
12771277

1278-
/// Sandbox source: a community sandbox name (e.g., `ollama`), a rootfs
1279-
/// tar archive (`.tar`, `.tar.gz`, or `.tgz`), or a full container
1280-
/// image reference (e.g., `myregistry.com/img:tag`).
1281-
///
1282-
/// Community names are resolved to
1283-
/// `ghcr.io/nvidia/openshell-community/sandboxes/<name>:latest`
1284-
/// (override the prefix with `OPENSHELL_COMMUNITY_REGISTRY`).
1278+
/// Sandbox source: a full container image reference (e.g.,
1279+
/// `ghcr.io/owner/image:tag`, `myregistry.com/img:tag`) or a
1280+
/// rootfs tar archive (`.tar`, `.tar.gz`, or `.tgz`).
12851281
///
12861282
/// To use a local Dockerfile, build and tag it with the container
12871283
/// engine used by your local gateway, then pass the resulting image

‎crates/openshell-cli/src/run.rs‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1234,11 +1234,8 @@ fn resolve_from(value: &str) -> Result<ResolvedSource> {
12341234
));
12351235
}
12361236

1237-
// Full image reference or community sandbox name — delegate to shared
1238-
// resolution in openshell-core.
1239-
Ok(ResolvedSource::Image(
1240-
openshell_core::image::resolve_community_image(value),
1241-
))
1237+
// Explicit OCI image reference — passed through to the gateway unchanged.
1238+
Ok(ResolvedSource::Image(value.to_string()))
12421239
}
12431240

12441241
#[allow(clippy::case_sensitive_file_extension_comparisons)] // already lowercased

‎crates/openshell-core/src/image.rs‎

Lines changed: 4 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
11
// SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22
// SPDX-License-Identifier: Apache-2.0
33

4-
//! Shared image-name resolution for community sandbox images.
4+
//! Default sandbox image.
55
//!
6-
//! Both the CLI and TUI need to expand bare sandbox names (e.g. `"base"`) into
7-
//! fully-qualified container image references. This module centralises that
8-
//! logic so every client resolves names identically.
9-
10-
/// Default registry prefix for community sandbox images.
11-
///
12-
/// Bare sandbox names are expanded to `{prefix}/{name}:latest`.
13-
/// Override at runtime with the `OPENSHELL_COMMUNITY_REGISTRY` env var.
14-
pub const DEFAULT_COMMUNITY_REGISTRY: &str = "ghcr.io/nvidia/openshell-community/sandboxes";
6+
//! Provides the fallback image used by all compute drivers when a sandbox spec
7+
//! does not specify one. User-supplied `--from` values are explicit OCI image
8+
//! references passed through unchanged by the CLI and TUI.
159
1610
/// Default sandbox base image reference.
1711
///
@@ -27,104 +21,3 @@ pub const DEFAULT_SANDBOX_BASE_IMAGE: &str = "docker.io/library/alpine:3.22";
2721
pub fn default_sandbox_image() -> String {
2822
DEFAULT_SANDBOX_BASE_IMAGE.to_string()
2923
}
30-
31-
/// Resolve a user-supplied image string into a fully-qualified reference.
32-
///
33-
/// Resolution rules (applied in order):
34-
/// 1. If the value contains `/`, `:`, or `.` it is treated as a complete image
35-
/// reference and returned as-is.
36-
/// 2. Otherwise it is treated as a community sandbox name and expanded to
37-
/// `{registry}/{value}:latest` where `{registry}` defaults to
38-
/// [`DEFAULT_COMMUNITY_REGISTRY`] but can be overridden via the
39-
/// `OPENSHELL_COMMUNITY_REGISTRY` environment variable.
40-
///
41-
/// This function only handles image-name resolution. Dockerfile detection is
42-
/// the responsibility of the caller (e.g. the CLI's `resolve_from()`).
43-
pub fn resolve_community_image(value: &str) -> String {
44-
// Already a fully-qualified reference.
45-
if value.contains('/') || value.contains(':') || value.contains('.') {
46-
return value.to_string();
47-
}
48-
49-
// Community sandbox shorthand → expand with registry prefix.
50-
let prefix = std::env::var("OPENSHELL_COMMUNITY_REGISTRY")
51-
.unwrap_or_else(|_| DEFAULT_COMMUNITY_REGISTRY.to_string());
52-
let prefix = prefix.trim_end_matches('/');
53-
format!("{prefix}/{value}:latest")
54-
}
55-
56-
#[cfg(test)]
57-
#[allow(unsafe_code)]
58-
mod tests {
59-
use super::*;
60-
use std::sync::{Mutex, OnceLock};
61-
62-
fn env_lock() -> &'static Mutex<()> {
63-
static ENV_LOCK: OnceLock<Mutex<()>> = OnceLock::new();
64-
ENV_LOCK.get_or_init(|| Mutex::new(()))
65-
}
66-
67-
#[test]
68-
fn bare_name_expands_to_community_registry() {
69-
let _guard = env_lock().lock().unwrap();
70-
let result = resolve_community_image("base");
71-
assert_eq!(
72-
result,
73-
"ghcr.io/nvidia/openshell-community/sandboxes/base:latest"
74-
);
75-
}
76-
77-
#[test]
78-
fn bare_name_with_env_override() {
79-
let _guard = env_lock().lock().unwrap();
80-
// Use a temp env override. Safety: test-only, and these env-var tests
81-
// are not run concurrently with other tests reading the same var.
82-
let key = "OPENSHELL_COMMUNITY_REGISTRY";
83-
let prev = std::env::var(key).ok();
84-
// SAFETY: single-threaded test context; no other thread reads this var.
85-
unsafe { std::env::set_var(key, "my-registry.example.com/sandboxes") };
86-
let result = resolve_community_image("python");
87-
assert_eq!(result, "my-registry.example.com/sandboxes/python:latest");
88-
// Restore.
89-
match prev {
90-
Some(v) => unsafe { std::env::set_var(key, v) },
91-
None => unsafe { std::env::remove_var(key) },
92-
}
93-
}
94-
95-
#[test]
96-
fn full_reference_with_slash_passes_through() {
97-
let _guard = env_lock().lock().unwrap();
98-
let input = "ghcr.io/myorg/myimage:v1";
99-
assert_eq!(resolve_community_image(input), input);
100-
}
101-
102-
#[test]
103-
fn reference_with_colon_passes_through() {
104-
let _guard = env_lock().lock().unwrap();
105-
let input = "myimage:latest";
106-
assert_eq!(resolve_community_image(input), input);
107-
}
108-
109-
#[test]
110-
fn reference_with_dot_passes_through() {
111-
let _guard = env_lock().lock().unwrap();
112-
let input = "registry.example.com";
113-
assert_eq!(resolve_community_image(input), input);
114-
}
115-
116-
#[test]
117-
fn trailing_slash_in_env_is_trimmed() {
118-
let _guard = env_lock().lock().unwrap();
119-
let key = "OPENSHELL_COMMUNITY_REGISTRY";
120-
let prev = std::env::var(key).ok();
121-
// SAFETY: single-threaded test context; no other thread reads this var.
122-
unsafe { std::env::set_var(key, "my-registry.example.com/sandboxes/") };
123-
let result = resolve_community_image("base");
124-
assert_eq!(result, "my-registry.example.com/sandboxes/base:latest");
125-
match prev {
126-
Some(v) => unsafe { std::env::set_var(key, v) },
127-
None => unsafe { std::env::remove_var(key) },
128-
}
129-
}
130-
}

‎crates/openshell-tui/src/lib.rs‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1444,9 +1444,8 @@ fn spawn_create_sandbox(app: &mut App, tx: mpsc::UnboundedSender<Event>) {
14441444
tokio::spawn(async move {
14451445
let has_custom_image = !image.is_empty();
14461446
let template = if has_custom_image {
1447-
let resolved = openshell_core::image::resolve_community_image(&image);
14481447
Some(openshell_core::proto::SandboxTemplate {
1449-
image: resolved,
1448+
image,
14501449
..Default::default()
14511450
})
14521451
} else {

0 commit comments

Comments
 (0)