Default to git.site.latha.org/nandi registry

ORBIT_REGISTRY overrides it, as does a registry saved by orbit init.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
nandiandClaude Sonnet 5.5 committed 2026-11-26 18:30:06 -08:00
1 parent f938945901
commit 64fd782b0d
3 files changed
+30 -16

No files matched your search

+23 -11
View File
@@ -3,6 +3,9 @@
///|
const CONFIG_MEDIA_TYPE : String = "application/vnd.latha.orbit.config.v1+json"
///|
const DEFAULT_REGISTRY : String = "git.site.latha.org/nandi"
///|
const LAYER_MEDIA_TYPE : String = "application/vnd.latha.orbit.layer.v1.tar+gzip"
@@ -324,6 +327,18 @@ fn orbit_root() -> String {
}
}
///|
/// ORBIT_REGISTRY wins, then config.json, then the built-in default.
fn pick_registry(env : String, file : String) -> String {
if env != "" {
env
} else if file != "" {
file
} else {
DEFAULT_REGISTRY
}
}
///|
/// Load config and state. ORBIT_REGISTRY / ORBIT_PLAIN_HTTP override the file.
fn load_ctx() -> Ctx raise OrbitError {
@@ -332,20 +347,10 @@ fn load_ctx() -> Ctx raise OrbitError {
Some(t) => config_from_text(t)
None => Config::{ registry: "", plain_http: false, }
}
let env_reg = getenv("ORBIT_REGISTRY")
let cfg = Config::{
registry: if env_reg != "" {
env_reg
} else {
file_cfg.registry
},
registry: pick_registry(getenv("ORBIT_REGISTRY"), file_cfg.registry),
plain_http: file_cfg.plain_http || getenv("ORBIT_PLAIN_HTTP") == "1",
}
if cfg.registry == "" {
raise OrbitError(
"no registry configured; run `orbit init <registry>` or set ORBIT_REGISTRY",
)
}
let state = match read_text(root + "/state.json") {
Some(t) => state_from_text(t)
None => Map([])
@@ -388,3 +393,10 @@ test "manifest roundtrip" {
assert_true(!(valid_rel_path("/bin/sh")))
assert_eq(store_id("sha256:0123456789abcdef0123"), "0123456789abcdef")
}
///|
test "registry precedence" {
assert_eq(pick_registry("env/r", "file/r"), "env/r")
assert_eq(pick_registry("", "file/r"), "file/r")
assert_eq(pick_registry("", ""), DEFAULT_REGISTRY)
}