Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2eff722311 | ||
|
|
6069a261db | ||
|
|
28b13e7a96 | ||
|
|
49739fc9f9 |
No files matched your search
@@ -30,6 +30,7 @@ mypkg/
|
||||
"name": "mytool",
|
||||
"version": "1.4.0",
|
||||
"description": "Does a thing",
|
||||
"documentation": "https://example.com/mytool",
|
||||
"bin": ["bin/mytool"],
|
||||
"depends": { "libfoo": "^2.1.0" }
|
||||
}
|
||||
@@ -39,9 +40,14 @@ In a channel this becomes `<channel url>/mytool:1.4.0`, plus the `latest` tag:
|
||||
|
||||
| Part | Media type |
|
||||
|---|---|
|
||||
| config | `application/vnd.latha.orbit.config.v1+json` (the orbit.json) |
|
||||
| config | `application/vnd.latha.orbit.config.v1+json` (`orbit.json`, with OCI labels for package-page metadata) |
|
||||
| layer `pkg.tar.gz` | `application/vnd.latha.orbit.layer.v1.tar+gzip` |
|
||||
|
||||
The optional `description` and `documentation` fields supply Gitea's **About**
|
||||
text and **Documentation** link. Use a public or otherwise accessible HTTP(S)
|
||||
URL for the link. Gitea does not render a bundled README inline, but you can
|
||||
ship one under `files/share/doc/<name>/README.md`, as the `greet` example does.
|
||||
|
||||
Because these are ordinary OCI artifacts, you can sign them with `cosign` or `notation` and attach SBOMs using the registry's own tooling.
|
||||
|
||||
## Usage
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
# greet
|
||||
|
||||
`greet` is an example Orbit package from the `example` channel. It installs a
|
||||
small greeting command and depends on `hello` from the built-in `main`
|
||||
channel.
|
||||
|
||||
- [Installation and usage](files/share/doc/greet/README.md)
|
||||
- [Package on Gitea](https://git.site.latha.org/nandi/-/packages/container/example%2Fgreet/latest)
|
||||
|
||||
This directory contains the package manifest (`orbit.json`) and the files Orbit
|
||||
installs (`files/`).
|
||||
@@ -0,0 +1,15 @@
|
||||
# greet
|
||||
|
||||
`greet` is a small Orbit package that demonstrates installing from a custom
|
||||
channel. It depends on the `hello` package from Orbit's built-in `main`
|
||||
channel.
|
||||
|
||||
```sh
|
||||
# Add the example channel once.
|
||||
orbit channel add example git.site.latha.org/nandi/example
|
||||
orbit install example::greet
|
||||
eval "$(orbit env)"
|
||||
greet
|
||||
```
|
||||
|
||||
`greet` prints `greetings from the example channel`.
|
||||
@@ -1,7 +1,8 @@
|
||||
{
|
||||
"name": "greet",
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.1",
|
||||
"description": "Example package for the example channel",
|
||||
"documentation": "https://git.site.latha.org/nandi/orbit/src/branch/main/examples/greet/files/share/doc/greet/README.md",
|
||||
"bin": ["bin/greet"],
|
||||
"depends": { "hello": "^1.0.0" }
|
||||
}
|
||||
@@ -12,6 +12,7 @@ struct Manifest {
|
||||
name : String
|
||||
version : String
|
||||
description : String
|
||||
documentation : String
|
||||
depends : Map[String, String]
|
||||
bins : Array[String]
|
||||
}
|
||||
@@ -179,6 +180,7 @@ fn parse_manifest(text : String) -> Manifest raise OrbitError {
|
||||
name: jstr(o, "name", ""),
|
||||
version: jstr(o, "version", ""),
|
||||
description: jstr(o, "description", ""),
|
||||
documentation: jstr(o, "documentation", ""),
|
||||
depends: jmap(o, "depends"),
|
||||
bins: jstrs(o, "bin"),
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ fn manifest_of_installed(p : Installed) -> Manifest {
|
||||
name: p.name,
|
||||
version: p.version,
|
||||
description: "",
|
||||
documentation: "",
|
||||
depends: p.depends,
|
||||
bins: p.bins,
|
||||
}
|
||||
|
||||
+57
-2
@@ -121,7 +121,61 @@ fn fetch_into_store(
|
||||
}
|
||||
|
||||
///|
|
||||
/// Pack `<dir>/files` and push it with `<dir>/orbit.json` as the config blob.
|
||||
/// Gitea reads package-page metadata from OCI image config labels, not
|
||||
/// manifest annotations. Keep the Orbit manifest at the top level for pulls.
|
||||
fn package_config(text : String, m : Manifest) -> String raise OrbitError {
|
||||
if m.description == "" && m.documentation == "" {
|
||||
return text
|
||||
}
|
||||
let config = parse_object(text, "orbit.json")
|
||||
let image = match config.get("config") {
|
||||
Some(Json::Object(image)) => image
|
||||
None => Map([])
|
||||
_ => raise OrbitError("orbit.json: config must be an object")
|
||||
}
|
||||
let labels = match image.get("Labels") {
|
||||
Some(Json::Object(labels)) => labels
|
||||
None => Map([])
|
||||
_ => raise OrbitError("orbit.json: config.Labels must be an object")
|
||||
}
|
||||
if m.description != "" {
|
||||
labels["org.opencontainers.image.description"] = Json::string(m.description)
|
||||
}
|
||||
if m.documentation != "" {
|
||||
labels["org.opencontainers.image.documentation"] = Json::string(
|
||||
m.documentation,
|
||||
)
|
||||
}
|
||||
image["Labels"] = Json::object(labels)
|
||||
config["config"] = Json::object(image)
|
||||
Json::object(config).stringify(indent=2) + "\n"
|
||||
}
|
||||
|
||||
///|
|
||||
test "package config exposes Gitea labels and preserves Orbit metadata" {
|
||||
let text =
|
||||
#|{"name":"greet","version":"1.0.1","description":"A greeting","documentation":"https://example.com/greet","depends":{"hello":"^1"},"config":{"Labels":{"custom":"keep"}}}
|
||||
let published = package_config(text, parse_manifest(text))
|
||||
let m = parse_manifest(published)
|
||||
assert_eq(m.name, "greet")
|
||||
assert_eq(m.depends.get("hello"), Some("^1"))
|
||||
let config = parse_object(published, "orbit.json")
|
||||
guard config.get("config") is Some(Json::Object(image)) else {
|
||||
fail("missing OCI config")
|
||||
}
|
||||
guard image.get("Labels") is Some(Json::Object(labels)) else {
|
||||
fail("missing OCI labels")
|
||||
}
|
||||
assert_eq(jstr(labels, "custom", ""), "keep")
|
||||
assert_eq(jstr(labels, "org.opencontainers.image.description", ""), "A greeting")
|
||||
assert_eq(
|
||||
jstr(labels, "org.opencontainers.image.documentation", ""),
|
||||
"https://example.com/greet",
|
||||
)
|
||||
}
|
||||
|
||||
///|
|
||||
/// Pack `<dir>/files` and push it with the enriched Orbit config blob.
|
||||
fn publish(
|
||||
ch : Channel,
|
||||
dir : String,
|
||||
@@ -132,6 +186,7 @@ fn publish(
|
||||
None => raise OrbitError("\{dir}/orbit.json not found")
|
||||
}
|
||||
let m = parse_manifest(text)
|
||||
let config = package_config(text, m)
|
||||
let files = dir + "/files"
|
||||
if !exists(files) {
|
||||
raise OrbitError("\{files} not found (package contents go in files/)")
|
||||
@@ -149,7 +204,7 @@ fn publish(
|
||||
sq(files) +
|
||||
" .",
|
||||
)
|
||||
sh_ok("cp " + sq(dir + "/orbit.json") + " " + sq(tmp + "/orbit.json"))
|
||||
write_text_atomic(tmp + "/orbit.json", config)
|
||||
let tags = if also_latest { m.version + ",latest" } else { m.version }
|
||||
let push = oras(
|
||||
ch,
|
||||
|
||||
Reference in new issue
Block a user