From 64fd782b0db2a3e097f61ee1c35865df9155f9e0 Mon Sep 17 00:00:00 2001 From: nandithebull Date: Thu, 26 Nov 2026 18:30:06 -0800 Subject: [PATCH] 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 --- README.md | 9 +++++---- src/main/main.mbt | 3 ++- src/main/model.mbt | 34 +++++++++++++++++++++++----------- 3 files changed, 30 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 3a9bb52..a6bcfe7 100644 --- a/README.md +++ b/README.md @@ -47,8 +47,7 @@ Because these are ordinary OCI artifacts, you can sign them with `cosign` or `no ## Usage ```sh -oras login git.site.latha.org # once, with a Gitea token -orbit init git.site.latha.org/ # Gitea: registry is / +oras login git.site.latha.org # once, with a Gitea token (needed to publish) eval "$(orbit env)" orbit publish examples/hello @@ -59,6 +58,8 @@ orbit rollback hello orbit remove hello ``` +The default registry is `git.site.latha.org/nandi`, so no setup is needed. Override it for one command or shell with `ORBIT_REGISTRY=/`, or save another one with `orbit init `. The order is `ORBIT_REGISTRY`, then the saved config, then the default. Orbit doesn't record which registry a package came from, so `upgrade` looks in whichever one is active. + Use `--plain-http` (or `ORBIT_PLAIN_HTTP=1`) for a local `registry:2` without TLS: ```sh @@ -88,8 +89,8 @@ package_dir=$(sh scripts/package-orbit.sh) && _build/native/release/build/main/main.exe publish "$package_dir" ``` -This publishes to the configured registry, so run `orbit init ` (or -set `ORBIT_REGISTRY`) first and log in with `oras login ` if needed. The +This publishes to the active registry (set `ORBIT_REGISTRY` to override the +default), so log in with `oras login ` first if needed. The package contains a native Linux binary for the build machine's architecture. Use the same architecture on the install machine. `oras` and `tar` are still system prerequisites; the package does not bundle them. diff --git a/src/main/main.mbt b/src/main/main.mbt index c7d2294..9f0b88a 100644 --- a/src/main/main.mbt +++ b/src/main/main.mbt @@ -5,7 +5,7 @@ let usage : String = #|orbit - packages as OCI artifacts (via oras) #| #|usage: - #| orbit init [--plain-http] set registry, e.g. git.example.org/owner + #| orbit init [--plain-http] save a different default registry #| orbit publish [--no-latest] push /orbit.json + /files/ #| orbit install [@constraint]... install with dependencies #| orbit remove ... [--force] remove, then drop unused dependencies @@ -20,6 +20,7 @@ let usage : String = #| #|constraints: 1.2.3 =1.2.3 1.2 ^1.2.0 ~1.2.0 >=1.2 * #|environment: ORBIT_ROOT (default ~/.orbit), ORBIT_REGISTRY, ORBIT_PLAIN_HTTP=1 + #|default registry: git.site.latha.org/nandi #|authentication: run `oras login ` once. ///| diff --git a/src/main/model.mbt b/src/main/model.mbt index 10044c9..68e018a 100644 --- a/src/main/model.mbt +++ b/src/main/model.mbt @@ -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 ` 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) +}