Skip to content

Commit 90f1d3b

Browse files
committed
pyhl cli: add --tag flag to pin GHCR release version
Signed-off-by: danbugs <danilochiarlone@gmail.com>
1 parent 7bfb820 commit 90f1d3b

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

host/src/bin/pyhl.rs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
use anyhow::{anyhow, bail, Context, Result};
2424
use clap::{Args, Parser, Subcommand};
2525
use hyperlight_unikraft::pyhl::{
26-
copy_replace, discover_source_artifacts, extract_from_ghcr, GHCR_INITRD_IMAGE,
27-
GHCR_KERNEL_IMAGE,
26+
copy_replace, discover_source_artifacts, extract_from_ghcr, ghcr_image_ref, GHCR_INITRD_REPO,
27+
GHCR_KERNEL_REPO,
2828
};
2929
use hyperlight_unikraft::{AllowList, BlockList, ListenPorts, NetworkPolicy, Preopen, Sandbox};
3030
use std::fs;
@@ -157,9 +157,14 @@ struct SetupArgs {
157157
///
158158
/// Without --from, pyhl pulls the pre-published image from GHCR (requires
159159
/// docker or podman on $PATH).
160-
#[arg(long, value_name = "DIR")]
160+
#[arg(long, value_name = "DIR", conflicts_with = "tag")]
161161
from: Option<PathBuf>,
162162

163+
/// Pin a specific GHCR release tag (e.g., "v0.3.1") instead of
164+
/// pulling :latest. Ignored when --from is used.
165+
#[arg(long, value_name = "TAG", conflicts_with = "from")]
166+
tag: Option<String>,
167+
163168
/// Overwrite an existing installed image without prompting.
164169
#[arg(long)]
165170
force: bool,
@@ -373,15 +378,18 @@ fn cmd_setup(args: SetupArgs) -> Result<()> {
373378
// No --from: pull from GHCR. Uses docker or podman under the hood
374379
// because that's the standard OCI client everyone has and avoids
375380
// linking an oci-distribution client into pyhl.
381+
let tag = args.tag.as_deref();
382+
let kernel_image = ghcr_image_ref(GHCR_KERNEL_REPO, tag);
383+
let initrd_image = ghcr_image_ref(GHCR_INITRD_REPO, tag);
376384
eprintln!("pyhl: downloading image from GHCR…");
377385
let tmp = home.join(".pyhl.download");
378386
fs::create_dir_all(&tmp)?;
379387
let kernel_path = tmp.join("kernel");
380388
let initrd_path = tmp.join("initrd.cpio");
381-
extract_from_ghcr(GHCR_KERNEL_IMAGE, "/kernel", &kernel_path)?;
382-
extract_from_ghcr(GHCR_INITRD_IMAGE, "/initrd.cpio", &initrd_path)?;
389+
extract_from_ghcr(&kernel_image, "/kernel", &kernel_path)?;
390+
extract_from_ghcr(&initrd_image, "/initrd.cpio", &initrd_path)?;
383391
(
384-
format!("{GHCR_KERNEL_IMAGE} + {GHCR_INITRD_IMAGE}"),
392+
format!("{kernel_image} + {initrd_image}"),
385393
kernel_path,
386394
initrd_path,
387395
)

0 commit comments

Comments
 (0)