From f3ce12f6f4ce6f9fb13f652d27df00ffea8e25d5 Mon Sep 17 00:00:00 2001 From: Artemis Everfree Date: Tue, 3 Mar 2026 05:41:12 +0000 Subject: [PATCH] Add FALCON_ASSET_BASE Environment Variable This environment variable allows the user to override the host falcon fetches assets from, away from the default S3 bucket. This may be helpful for CI machines that have a more local mirror available, or for testing new assets. This environment variable is implemented the same as `FALCON_DATASET`. --- lib/src/lib.rs | 14 +++++++++++--- lib/src/ovmf.rs | 15 +++++++++------ 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/lib/src/lib.rs b/lib/src/lib.rs index 2328548..dfbd22b 100644 --- a/lib/src/lib.rs +++ b/lib/src/lib.rs @@ -1269,9 +1269,8 @@ impl Node { info!(log, "image already downloaded: {path}"); return Ok(()); } - let url = format!( - "https://oxide-falcon-assets.s3.us-west-2.amazonaws.com/{iname}" - ); + let asset_base = asset_base(); + let url = format!("{asset_base}/{iname}"); info!(log, "trying to download {url}"); download_large_file(url.as_str(), path, log).await?; @@ -1821,6 +1820,15 @@ pub(crate) fn dataset() -> String { } } +pub(crate) fn asset_base() -> String { + match std::env::var("FALCON_ASSET_BASE") { + Ok(s) if !s.is_empty() => s, + _ => { + "https://oxide-falcon-assets.s3.us-west-2.amazonaws.com".to_string() + } + } +} + fn libnet_retry(f: F) -> Result<(), Error> where F: Fn() -> Result<(), libnet::Error>, diff --git a/lib/src/ovmf.rs b/lib/src/ovmf.rs index a04c568..9a7862f 100644 --- a/lib/src/ovmf.rs +++ b/lib/src/ovmf.rs @@ -5,10 +5,13 @@ use std::fs; use std::io; use std::time::Duration; -const OVMF_URL: &str = - "https://oxide-falcon-assets.s3.us-west-2.amazonaws.com/OVMF_CODE.fd"; -const OVMF_DIGEST_URL: &str = - "https://oxide-falcon-assets.s3.us-west-2.amazonaws.com/OVMF_CODE.fd.sha256.txt"; +fn ovmf_url() -> String { + format!("{}/OVMF_CODE.fd", crate::asset_base()) +} + +fn ovmf_digest_url() -> String { + format!("{}/OVMF_CODE.fd.sha256.txt", crate::asset_base()) +} pub(crate) async fn ensure_ovmf_fd( falcon_dir: &str, @@ -31,7 +34,7 @@ pub(crate) async fn ensure_ovmf_fd( async fn download_ovmf(path: &str, log: &Logger) -> Result<()> { info!(log, "downloading ovmf"); - crate::download_large_file(OVMF_URL, path, log).await?; + crate::download_large_file(&ovmf_url(), path, log).await?; Ok(()) } @@ -63,7 +66,7 @@ async fn get_expected_ovmf_digest_impl() -> Result { .connect_timeout(Duration::from_secs(15)) .timeout(Duration::from_secs(30)) .build()?; - let response = client.get(OVMF_DIGEST_URL).send().await?; + let response = client.get(ovmf_digest_url()).send().await?; let text = response.text().await?; Ok(text.trim().to_owned()) }