Skip to content

Commit ca02877

Browse files
project: Use ImageReference from containers_image_proxy
Refactor `struct ImageReference` as an alias to `containers_image_proxy::ImageReference`, also refactor `enum Transport` as Transport from containers_image_proxy Rename `crate::lib::spec::ImageReference` to `ImageReferenceSig` to avoid confusion with ImageReference from containers_image_proxy Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
1 parent 438b02b commit ca02877

15 files changed

Lines changed: 71 additions & 187 deletions

File tree

crates/lib/src/bootc_composefs/boot.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1405,7 +1405,7 @@ pub(crate) async fn setup_composefs_boot(
14051405
write_composefs_state(
14061406
&root_setup.physical_root_path,
14071407
&id,
1408-
&crate::spec::ImageReference::from(state.target_imgref.clone()),
1408+
&crate::spec::ImageReferenceSig::from(state.target_imgref.clone()),
14091409
None,
14101410
boot_type,
14111411
boot_digest,

crates/lib/src/bootc_composefs/repo.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ async fn pull_composefs_unified(
237237
/// Checks for boot entries in the image and returns them.
238238
#[context("Pulling composefs repository")]
239239
pub(crate) async fn pull_composefs_repo(
240-
spec_imgref: &crate::spec::ImageReference,
240+
spec_imgref: &crate::spec::ImageReferenceSig,
241241
allow_missing_fsverity: bool,
242242
use_unified: bool,
243243
) -> Result<PullRepoResult> {

crates/lib/src/bootc_composefs/state.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ use crate::{
3838
SHARED_VAR_PATH, STATE_DIR_RELATIVE,
3939
},
4040
parsers::bls_config::BLSConfig,
41-
spec::ImageReference,
41+
spec::ImageReferenceSig,
4242
spec::{FilesystemOverlay, FilesystemOverlayAccessMode, FilesystemOverlayPersistence},
4343
utils::path_relative_to,
4444
};
@@ -230,7 +230,7 @@ pub(crate) fn update_boot_digest_in_origin(
230230
pub(crate) async fn write_composefs_state(
231231
root_path: &Utf8PathBuf,
232232
deployment_id: &Sha512HashValue,
233-
target_imgref: &ImageReference,
233+
target_imgref: &ImageReferenceSig,
234234
staged: Option<StagedDeployment>,
235235
boot_type: BootType,
236236
boot_digest: String,

crates/lib/src/bootc_composefs/status.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use crate::{
2525
bls_config::{BLSConfig, BLSConfigType, parse_bls_config},
2626
grub_menuconfig::{MenuEntry, parse_grub_menuentry_file},
2727
},
28-
spec::{BootEntry, BootOrder, Host, HostSpec, ImageReference, ImageStatus},
28+
spec::{BootEntry, BootOrder, Host, HostSpec, ImageStatus},
2929
store::Storage,
3030
utils::{EfiError, read_uefi_var},
3131
};
@@ -493,7 +493,7 @@ fn boot_entry_from_composefs_deployment(
493493
let image = match origin.get::<String>("origin", ORIGIN_CONTAINER) {
494494
Some(img_name_from_config) => {
495495
let ostree_img_ref = OstreeImageReference::from_str(&img_name_from_config)?;
496-
let img_ref = ImageReference::from(ostree_img_ref);
496+
let img_ref = crate::spec::ImageReferenceSig::from(ostree_img_ref);
497497

498498
let img_conf = get_imginfo(storage, &verity)?;
499499

crates/lib/src/bootc_composefs/update.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use crate::{
2929
COMPOSEFS_STAGED_DEPLOYMENT_FNAME, COMPOSEFS_TRANSIENT_STATE_DIR, STATE_DIR_RELATIVE,
3030
TYPE1_ENT_PATH_STAGED, USER_CFG_STAGED,
3131
},
32-
spec::{Bootloader, Host, ImageReference},
32+
spec::{Bootloader, Host, ImageReferenceSig},
3333
store::{BootedComposefs, ComposefsRepository, Storage},
3434
};
3535

@@ -54,7 +54,7 @@ use crate::{
5454
#[context("Checking if image {} is pulled", imgref.image)]
5555
pub(crate) async fn is_image_pulled(
5656
repo: &ComposefsRepository,
57-
imgref: &ImageReference,
57+
imgref: &ImageReferenceSig,
5858
) -> Result<(Option<Sha512HashValue>, ImgConfigManifest)> {
5959
let imgref_repr = imgref.to_image_proxy_ref()?;
6060
let img_config_manifest = get_container_manifest_and_config(&imgref_repr.to_string()).await?;
@@ -242,7 +242,7 @@ pub(crate) async fn do_upgrade(
242242
storage: &Storage,
243243
booted_cfs: &BootedComposefs,
244244
host: &Host,
245-
imgref: &ImageReference,
245+
imgref: &ImageReferenceSig,
246246
opts: &DoUpgradeOpts,
247247
manifest: &ostree_ext::oci_spec::image::ImageManifest,
248248
) -> Result<()> {

crates/lib/src/cli.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ use crate::podstorage::set_additional_image_store;
5353
use crate::progress_jsonl::{ProgressWriter, RawProgressFd};
5454
use crate::spec::FilesystemOverlayAccessMode;
5555
use crate::spec::Host;
56-
use crate::spec::ImageReference;
56+
use crate::spec::ImageReferenceSig;
5757
use crate::status::get_host;
5858
use crate::store::{BootedOstree, Storage};
5959
use crate::store::{BootedStorage, BootedStorageKind};
@@ -1353,15 +1353,15 @@ async fn upgrade(
13531353

13541354
Ok(())
13551355
}
1356-
pub(crate) fn imgref_for_switch(opts: &SwitchOpts) -> Result<ImageReference> {
1356+
pub(crate) fn imgref_for_switch(opts: &SwitchOpts) -> Result<ImageReferenceSig> {
13571357
let transport = ostree_container::Transport::try_from(opts.transport.as_str())?;
13581358
let imgref = ostree_container::ImageReference {
13591359
transport,
13601360
name: opts.target.to_string(),
13611361
};
13621362
let sigverify = sigpolicy_from_opt(opts.enforce_container_sigpolicy);
13631363
let target = ostree_container::OstreeImageReference { sigverify, imgref };
1364-
let target = ImageReference::from(target);
1364+
let target = ImageReferenceSig::from(target);
13651365

13661366
return Ok(target);
13671367
}
@@ -2493,7 +2493,7 @@ mod tests {
24932493
#[test]
24942494
fn test_image_reference_with_tag() {
24952495
// Test basic tag replacement for registry transport
2496-
let current = ImageReference {
2496+
let current = ImageReferenceSig {
24972497
image: "quay.io/example/myapp:v1.0".to_string(),
24982498
transport: "registry".to_string(),
24992499
signature: None,
@@ -2503,7 +2503,7 @@ mod tests {
25032503
assert_eq!(result.transport, "registry");
25042504

25052505
// Test tag replacement with digest (digest should be stripped for registry)
2506-
let current_with_digest = ImageReference {
2506+
let current_with_digest = ImageReferenceSig {
25072507
image: "quay.io/example/myapp:v1.0@sha256:abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890".to_string(),
25082508
transport: "registry".to_string(),
25092509
signature: None,
@@ -2512,7 +2512,7 @@ mod tests {
25122512
assert_eq!(result.image, "quay.io/example/myapp:v2.0");
25132513

25142514
// Test that non-registry transport works (containers-storage)
2515-
let containers_storage = ImageReference {
2515+
let containers_storage = ImageReferenceSig {
25162516
image: "localhost/myapp:v1.0".to_string(),
25172517
transport: "containers-storage".to_string(),
25182518
signature: None,
@@ -2522,7 +2522,7 @@ mod tests {
25222522
assert_eq!(result.transport, "containers-storage");
25232523

25242524
// Test digest stripping for non-registry transport
2525-
let containers_storage_with_digest = ImageReference {
2525+
let containers_storage_with_digest = ImageReferenceSig {
25262526
image:
25272527
"localhost/myapp:v1.0@sha256:abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890"
25282528
.to_string(),
@@ -2534,7 +2534,7 @@ mod tests {
25342534
assert_eq!(result.transport, "containers-storage");
25352535

25362536
// Test image without tag (edge case)
2537-
let no_tag = ImageReference {
2537+
let no_tag = ImageReferenceSig {
25382538
image: "localhost/myapp".to_string(),
25392539
transport: "containers-storage".to_string(),
25402540
signature: None,

crates/lib/src/deploy.rs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use ostree_ext::sysroot::SysrootLock;
2525
use ostree_ext::tokio_util::spawn_blocking_cancellable_flatten;
2626

2727
use crate::progress_jsonl::{Event, ProgressWriter, SubTaskBytes, SubTaskStep};
28-
use crate::spec::ImageReference;
28+
use crate::spec::ImageReferenceSig;
2929
use crate::spec::{BootOrder, HostSpec};
3030
use crate::status::labels_of_config;
3131
use crate::store::Storage;
@@ -49,7 +49,7 @@ const BOOTC_DERIVED_KEY: &str = "bootc.derived";
4949

5050
/// Variant of HostSpec but required to be filled out
5151
pub(crate) struct RequiredHostSpec<'a> {
52-
pub(crate) image: &'a ImageReference,
52+
pub(crate) image: &'a ImageReferenceSig,
5353
}
5454

5555
/// State of a locally fetched image
@@ -389,7 +389,7 @@ fn check_disk_space_inner(
389389
fd: impl AsFd,
390390
bytes_to_fetch: u64,
391391
min_free: u64,
392-
imgref: &ImageReference,
392+
imgref: &ImageReferenceSig,
393393
) -> Result<()> {
394394
let stat = rustix::fs::fstatvfs(fd)?;
395395
let bytes_avail = stat.f_bsize.checked_mul(stat.f_bavail).unwrap_or(u64::MAX);
@@ -412,7 +412,7 @@ fn check_disk_space_inner(
412412
pub(crate) fn check_disk_space_ostree(
413413
repo: &ostree::Repo,
414414
image_meta: &PreparedImportMeta,
415-
imgref: &ImageReference,
415+
imgref: &ImageReferenceSig,
416416
) -> Result<()> {
417417
let min_free = repo.min_free_space_bytes().unwrap_or(0);
418418
check_disk_space_inner(
@@ -428,7 +428,7 @@ pub(crate) fn check_disk_space_ostree(
428428
pub(crate) fn check_disk_space_unified(
429429
cfs: &crate::store::ComposefsRepository,
430430
image_meta: &PreparedImportMeta,
431-
imgref: &ImageReference,
431+
imgref: &ImageReferenceSig,
432432
) -> Result<()> {
433433
check_disk_space_inner(cfs.objects_dir()?, image_meta.bytes_to_fetch, 0, imgref)
434434
}
@@ -438,7 +438,7 @@ pub(crate) fn check_disk_space_unified(
438438
pub(crate) fn check_disk_space_composefs(
439439
cfs: &crate::store::ComposefsRepository,
440440
manifest: &ostree_ext::oci_spec::image::ImageManifest,
441-
imgref: &ImageReference,
441+
imgref: &ImageReferenceSig,
442442
) -> Result<()> {
443443
let bytes_to_fetch: u64 = manifest
444444
.layers()
@@ -465,7 +465,7 @@ pub(crate) enum PreparedPullResult {
465465

466466
pub(crate) async fn prepare_for_pull(
467467
repo: &ostree::Repo,
468-
imgref: &ImageReference,
468+
imgref: &ImageReferenceSig,
469469
target_imgref: Option<&OstreeImageReference>,
470470
booted_deployment: Option<&ostree::Deployment>,
471471
) -> Result<PreparedPullResult> {
@@ -512,7 +512,7 @@ pub(crate) async fn prepare_for_pull(
512512
/// Returns true if the image exists in bootc storage.
513513
pub(crate) async fn image_exists_in_unified_storage(
514514
store: &Storage,
515-
imgref: &ImageReference,
515+
imgref: &ImageReferenceSig,
516516
) -> Result<bool> {
517517
let imgstore = store.get_ensure_imgstore()?;
518518
let image_ref_str = imgref.to_transport_image()?;
@@ -523,7 +523,7 @@ pub(crate) async fn image_exists_in_unified_storage(
523523
/// This reuses the same infrastructure as LBIs.
524524
pub(crate) async fn prepare_for_pull_unified(
525525
repo: &ostree::Repo,
526-
imgref: &ImageReference,
526+
imgref: &ImageReferenceSig,
527527
target_imgref: Option<&OstreeImageReference>,
528528
store: &Storage,
529529
booted_deployment: Option<&ostree::Deployment>,
@@ -549,7 +549,7 @@ pub(crate) async fn prepare_for_pull_unified(
549549

550550
// Now create a containers-storage reference to read from bootc storage
551551
tracing::info!("Unified pull: now importing from containers-storage transport");
552-
let containers_storage_imgref = ImageReference {
552+
let containers_storage_imgref = ImageReferenceSig {
553553
transport: "containers-storage".to_string(),
554554
image: imgref.image.clone(),
555555
signature: imgref.signature.clone(),
@@ -615,7 +615,7 @@ pub(crate) async fn prepare_for_pull_unified(
615615
/// Unified pull: Use podman to pull to containers-storage, then read from there
616616
pub(crate) async fn pull_unified(
617617
repo: &ostree::Repo,
618-
imgref: &ImageReference,
618+
imgref: &ImageReferenceSig,
619619
target_imgref: Option<&OstreeImageReference>,
620620
quiet: bool,
621621
prog: ProgressWriter,
@@ -643,7 +643,7 @@ pub(crate) async fn pull_unified(
643643
imgref,
644644
)?;
645645
// To avoid duplicate success logs, pass a containers-storage imgref to the importer
646-
let cs_imgref = ImageReference {
646+
let cs_imgref = ImageReferenceSig {
647647
transport: "containers-storage".to_string(),
648648
image: imgref.image.clone(),
649649
signature: imgref.signature.clone(),
@@ -655,7 +655,7 @@ pub(crate) async fn pull_unified(
655655

656656
#[context("Pulling")]
657657
pub(crate) async fn pull_from_prepared(
658-
imgref: &ImageReference,
658+
imgref: &ImageReferenceSig,
659659
quiet: bool,
660660
prog: ProgressWriter,
661661
mut prepared_image: PreparedImportMeta,
@@ -730,7 +730,7 @@ pub(crate) async fn pull_from_prepared(
730730
/// Wrapper for pulling a container image, wiring up status output.
731731
pub(crate) async fn pull(
732732
repo: &ostree::Repo,
733-
imgref: &ImageReference,
733+
imgref: &ImageReferenceSig,
734734
target_imgref: Option<&OstreeImageReference>,
735735
quiet: bool,
736736
prog: ProgressWriter,
@@ -923,7 +923,7 @@ async fn deploy(
923923
}
924924

925925
#[context("Generating origin")]
926-
fn origin_from_imageref(imgref: &ImageReference) -> Result<glib::KeyFile> {
926+
fn origin_from_imageref(imgref: &ImageReferenceSig) -> Result<glib::KeyFile> {
927927
let origin = glib::KeyFile::new();
928928
let imgref = OstreeImageReference::from(imgref.clone());
929929
origin.set_string(
@@ -1216,7 +1216,7 @@ fn find_newest_deployment_name(deploysdir: &Dir) -> Result<String> {
12161216
}
12171217

12181218
// Implementation of `bootc switch --in-place`
1219-
pub(crate) fn switch_origin_inplace(root: &Dir, imgref: &ImageReference) -> Result<String> {
1219+
pub(crate) fn switch_origin_inplace(root: &Dir, imgref: &ImageReferenceSig) -> Result<String> {
12201220
// Log the in-place switch operation to systemd journal
12211221
const SWITCH_INPLACE_JOURNAL_ID: &str = "3e2f1a0b9c8d7e6f5a4b3c2d1e0f9a8b7";
12221222

@@ -1386,7 +1386,7 @@ mod tests {
13861386
builder,
13871387
)?;
13881388
let deploydir = &td.open_dir(deploydir)?;
1389-
let orig_imgref = ImageReference {
1389+
let orig_imgref = ImageReferenceSig {
13901390
image: "quay.io/exampleos/original:sometag".into(),
13911391
transport: "registry".into(),
13921392
signature: None,
@@ -1399,7 +1399,7 @@ mod tests {
13991399
)?;
14001400
}
14011401

1402-
let target_imgref = ImageReference {
1402+
let target_imgref = ImageReferenceSig {
14031403
image: "quay.io/someother/otherimage:latest".into(),
14041404
transport: "registry".into(),
14051405
signature: None,
@@ -1466,7 +1466,7 @@ UUID=6907-17CA /boot/efi vfat umask=0077,shortname=win
14661466
#[test]
14671467
fn test_check_disk_space_inner() -> Result<()> {
14681468
let td = cap_std_ext::cap_tempfile::TempDir::new(cap_std::ambient_authority())?;
1469-
let imgref = ImageReference {
1469+
let imgref = ImageReferenceSig {
14701470
image: "quay.io/exampleos/exampleos:latest".into(),
14711471
transport: "registry".into(),
14721472
signature: None,

crates/lib/src/image.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ pub(crate) async fn set_unified(sysroot: &crate::store::Storage) -> Result<()> {
506506

507507
// Optionally verify we can import from containers-storage by preparing in a temp importer
508508
// without actually importing into the main repo; this is a lightweight validation.
509-
let containers_storage_imgref = crate::spec::ImageReference {
509+
let containers_storage_imgref = crate::spec::ImageReferenceSig {
510510
transport: "containers-storage".to_string(),
511511
image: imgref.image.clone(),
512512
signature: imgref.signature.clone(),

crates/lib/src/install.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ use crate::deploy::{MergeState, PreparedPullResult, prepare_for_pull, pull_from_
198198
use crate::install::config::Filesystem as FilesystemEnum;
199199
use crate::lsm;
200200
use crate::progress_jsonl::ProgressWriter;
201-
use crate::spec::{Bootloader, ImageReference};
201+
use crate::spec::{Bootloader, ImageReferenceSig};
202202
use crate::store::Storage;
203203
use crate::task::Task;
204204
use crate::utils::sigpolicy_from_opt;
@@ -1061,7 +1061,7 @@ async fn install_container(
10611061

10621062
// Pull the container image into the target root filesystem. Since this is
10631063
// an install path, we don't need to fsync() individual layers.
1064-
let spec_imgref = ImageReference::from(src_imageref.clone());
1064+
let spec_imgref = ImageReferenceSig::from(src_imageref.clone());
10651065
let repo = &sysroot.repo();
10661066
repo.set_disable_fsync(true);
10671067

@@ -2030,7 +2030,7 @@ async fn install_to_filesystem_impl(
20302030
crate::deploy::check_disk_space_composefs(
20312031
&cfs_repo,
20322032
&img_manifest_config.manifest,
2033-
&crate::spec::ImageReference {
2033+
&crate::spec::ImageReferenceSig {
20342034
image: imgref.name.clone(),
20352035
transport: imgref.transport.to_string(),
20362036
signature: None,

0 commit comments

Comments
 (0)