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

+5 -4
View File
@@ -47,8 +47,7 @@ Because these are ordinary OCI artifacts, you can sign them with `cosign` or `no
## Usage ## Usage
```sh ```sh
oras login git.site.latha.org # once, with a Gitea token oras login git.site.latha.org # once, with a Gitea token (needed to publish)
orbit init git.site.latha.org/<owner> # Gitea: registry is <host>/<owner>
eval "$(orbit env)" eval "$(orbit env)"
orbit publish examples/hello orbit publish examples/hello
@@ -59,6 +58,8 @@ orbit rollback hello
orbit remove 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=<host>/<owner>`, or save another one with `orbit init <registry>`. 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: Use `--plain-http` (or `ORBIT_PLAIN_HTTP=1`) for a local `registry:2` without TLS:
```sh ```sh
@@ -88,8 +89,8 @@ package_dir=$(sh scripts/package-orbit.sh) &&
_build/native/release/build/main/main.exe publish "$package_dir" _build/native/release/build/main/main.exe publish "$package_dir"
``` ```
This publishes to the configured registry, so run `orbit init <registry>` (or This publishes to the active registry (set `ORBIT_REGISTRY` to override the
set `ORBIT_REGISTRY`) first and log in with `oras login <host>` if needed. The default), so log in with `oras login <host>` first if needed. The
package contains a native Linux binary for the build machine's architecture. 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 Use the same architecture on the install machine. `oras` and `tar` are still
system prerequisites; the package does not bundle them. system prerequisites; the package does not bundle them.
+2 -1
View File
@@ -5,7 +5,7 @@ let usage : String =
#|orbit - packages as OCI artifacts (via oras) #|orbit - packages as OCI artifacts (via oras)
#| #|
#|usage: #|usage:
#| orbit init <registry> [--plain-http] set registry, e.g. git.example.org/owner #| orbit init <registry> [--plain-http] save a different default registry
#| orbit publish <dir> [--no-latest] push <dir>/orbit.json + <dir>/files/ #| orbit publish <dir> [--no-latest] push <dir>/orbit.json + <dir>/files/
#| orbit install <name>[@constraint]... install with dependencies #| orbit install <name>[@constraint]... install with dependencies
#| orbit remove <name>... [--force] remove, then drop unused dependencies #| orbit remove <name>... [--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 * #|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 #|environment: ORBIT_ROOT (default ~/.orbit), ORBIT_REGISTRY, ORBIT_PLAIN_HTTP=1
#|default registry: git.site.latha.org/nandi
#|authentication: run `oras login <registry-host>` once. #|authentication: run `oras login <registry-host>` once.
///| ///|
+23 -11
View File
@@ -3,6 +3,9 @@
///| ///|
const CONFIG_MEDIA_TYPE : String = "application/vnd.latha.orbit.config.v1+json" 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" 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. /// Load config and state. ORBIT_REGISTRY / ORBIT_PLAIN_HTTP override the file.
fn load_ctx() -> Ctx raise OrbitError { fn load_ctx() -> Ctx raise OrbitError {
@@ -332,20 +347,10 @@ fn load_ctx() -> Ctx raise OrbitError {
Some(t) => config_from_text(t) Some(t) => config_from_text(t)
None => Config::{ registry: "", plain_http: false, } None => Config::{ registry: "", plain_http: false, }
} }
let env_reg = getenv("ORBIT_REGISTRY")
let cfg = Config::{ let cfg = Config::{
registry: if env_reg != "" { registry: pick_registry(getenv("ORBIT_REGISTRY"), file_cfg.registry),
env_reg
} else {
file_cfg.registry
},
plain_http: file_cfg.plain_http || getenv("ORBIT_PLAIN_HTTP") == "1", 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") { let state = match read_text(root + "/state.json") {
Some(t) => state_from_text(t) Some(t) => state_from_text(t)
None => Map([]) None => Map([])
@@ -388,3 +393,10 @@ test "manifest roundtrip" {
assert_true(!(valid_rel_path("/bin/sh"))) assert_true(!(valid_rel_path("/bin/sh")))
assert_eq(store_id("sha256:0123456789abcdef0123"), "0123456789abcdef") 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)
}