Skip to content

Commit 334b53c

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 e5c1149 commit 334b53c

15 files changed

Lines changed: 71 additions & 185 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
};
@@ -468,7 +468,7 @@ fn boot_entry_from_composefs_deployment(
468468
let image = match origin.get::<String>("origin", ORIGIN_CONTAINER) {
469469
Some(img_name_from_config) => {
470470
let ostree_img_ref = OstreeImageReference::from_str(&img_name_from_config)?;
471-
let img_ref = ImageReference::from(ostree_img_ref);
471+
let img_ref = crate::spec::ImageReferenceSig::from(ostree_img_ref);
472472

473473
let img_conf = get_imginfo(storage, &verity)?;
474474

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};
@@ -1347,15 +1347,15 @@ async fn upgrade(
13471347

13481348
Ok(())
13491349
}
1350-
pub(crate) fn imgref_for_switch(opts: &SwitchOpts) -> Result<ImageReference> {
1350+
pub(crate) fn imgref_for_switch(opts: &SwitchOpts) -> Result<ImageReferenceSig> {
13511351
let transport = ostree_container::Transport::try_from(opts.transport.as_str())?;
13521352
let imgref = ostree_container::ImageReference {
13531353
transport,
13541354
name: opts.target.to_string(),
13551355
};
13561356
let sigverify = sigpolicy_from_opt(opts.enforce_container_sigpolicy);
13571357
let target = ostree_container::OstreeImageReference { sigverify, imgref };
1358-
let target = ImageReference::from(target);
1358+
let target = ImageReferenceSig::from(target);
13591359

13601360
return Ok(target);
13611361
}
@@ -2482,7 +2482,7 @@ mod tests {
24822482
#[test]
24832483
fn test_image_reference_with_tag() {
24842484
// Test basic tag replacement for registry transport
2485-
let current = ImageReference {
2485+
let current = ImageReferenceSig {
24862486
image: "quay.io/example/myapp:v1.0".to_string(),
24872487
transport: "registry".to_string(),
24882488
signature: None,
@@ -2492,7 +2492,7 @@ mod tests {
24922492
assert_eq!(result.transport, "registry");
24932493

24942494
// Test tag replacement with digest (digest should be stripped for registry)
2495-
let current_with_digest = ImageReference {
2495+
let current_with_digest = ImageReferenceSig {
24962496
image: "quay.io/example/myapp:v1.0@sha256:abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890".to_string(),
24972497
transport: "registry".to_string(),
24982498
signature: None,
@@ -2501,7 +2501,7 @@ mod tests {
25012501
assert_eq!(result.image, "quay.io/example/myapp:v2.0");
25022502

25032503
// Test that non-registry transport works (containers-storage)
2504-
let containers_storage = ImageReference {
2504+
let containers_storage = ImageReferenceSig {
25052505
image: "localhost/myapp:v1.0".to_string(),
25062506
transport: "containers-storage".to_string(),
25072507
signature: None,
@@ -2511,7 +2511,7 @@ mod tests {
25112511
assert_eq!(result.transport, "containers-storage");
25122512

25132513
// Test digest stripping for non-registry transport
2514-
let containers_storage_with_digest = ImageReference {
2514+
let containers_storage_with_digest = ImageReferenceSig {
25152515
image:
25162516
"localhost/myapp:v1.0@sha256:abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890"
25172517
.to_string(),
@@ -2523,7 +2523,7 @@ mod tests {
25232523
assert_eq!(result.transport, "containers-storage");
25242524

25252525
// Test image without tag (edge case)
2526-
let no_tag = ImageReference {
2526+
let no_tag = ImageReferenceSig {
25272527
image: "localhost/myapp".to_string(),
25282528
transport: "containers-storage".to_string(),
25292529
signature: None,

crates/lib/src/deploy.rs

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

2626
use crate::progress_jsonl::{Event, ProgressWriter, SubTaskBytes, SubTaskStep};
27-
use crate::spec::ImageReference;
27+
use crate::spec::ImageReferenceSig;
2828
use crate::spec::{BootOrder, HostSpec};
2929
use crate::status::labels_of_config;
3030
use crate::store::Storage;
@@ -48,7 +48,7 @@ const BOOTC_DERIVED_KEY: &str = "bootc.derived";
4848

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

5454
/// State of a locally fetched image
@@ -388,7 +388,7 @@ fn check_disk_space_inner(
388388
fd: impl AsFd,
389389
bytes_to_fetch: u64,
390390
min_free: u64,
391-
imgref: &ImageReference,
391+
imgref: &ImageReferenceSig,
392392
) -> Result<()> {
393393
let stat = rustix::fs::fstatvfs(fd)?;
394394
let bytes_avail = stat.f_bsize.checked_mul(stat.f_bavail).unwrap_or(u64::MAX);
@@ -411,7 +411,7 @@ fn check_disk_space_inner(
411411
pub(crate) fn check_disk_space_ostree(
412412
repo: &ostree::Repo,
413413
image_meta: &PreparedImportMeta,
414-
imgref: &ImageReference,
414+
imgref: &ImageReferenceSig,
415415
) -> Result<()> {
416416
let min_free = repo.min_free_space_bytes().unwrap_or(0);
417417
check_disk_space_inner(
@@ -427,7 +427,7 @@ pub(crate) fn check_disk_space_ostree(
427427
pub(crate) fn check_disk_space_unified(
428428
cfs: &crate::store::ComposefsRepository,
429429
image_meta: &PreparedImportMeta,
430-
imgref: &ImageReference,
430+
imgref: &ImageReferenceSig,
431431
) -> Result<()> {
432432
check_disk_space_inner(cfs.objects_dir()?, image_meta.bytes_to_fetch, 0, imgref)
433433
}
@@ -437,7 +437,7 @@ pub(crate) fn check_disk_space_unified(
437437
pub(crate) fn check_disk_space_composefs(
438438
cfs: &crate::store::ComposefsRepository,
439439
manifest: &ostree_ext::oci_spec::image::ImageManifest,
440-
imgref: &ImageReference,
440+
imgref: &ImageReferenceSig,
441441
) -> Result<()> {
442442
let bytes_to_fetch: u64 = manifest
443443
.layers()
@@ -464,7 +464,7 @@ pub(crate) enum PreparedPullResult {
464464

465465
pub(crate) async fn prepare_for_pull(
466466
repo: &ostree::Repo,
467-
imgref: &ImageReference,
467+
imgref: &ImageReferenceSig,
468468
target_imgref: Option<&OstreeImageReference>,
469469
booted_deployment: Option<&ostree::Deployment>,
470470
) -> Result<PreparedPullResult> {
@@ -511,7 +511,7 @@ pub(crate) async fn prepare_for_pull(
511511
/// Returns true if the image exists in bootc storage.
512512
pub(crate) async fn image_exists_in_unified_storage(
513513
store: &Storage,
514-
imgref: &ImageReference,
514+
imgref: &ImageReferenceSig,
515515
) -> Result<bool> {
516516
let imgstore = store.get_ensure_imgstore()?;
517517
let image_ref_str = imgref.to_transport_image()?;
@@ -522,7 +522,7 @@ pub(crate) async fn image_exists_in_unified_storage(
522522
/// This reuses the same infrastructure as LBIs.
523523
pub(crate) async fn prepare_for_pull_unified(
524524
repo: &ostree::Repo,
525-
imgref: &ImageReference,
525+
imgref: &ImageReferenceSig,
526526
target_imgref: Option<&OstreeImageReference>,
527527
store: &Storage,
528528
booted_deployment: Option<&ostree::Deployment>,
@@ -548,7 +548,7 @@ pub(crate) async fn prepare_for_pull_unified(
548548

549549
// Now create a containers-storage reference to read from bootc storage
550550
tracing::info!("Unified pull: now importing from containers-storage transport");
551-
let containers_storage_imgref = ImageReference {
551+
let containers_storage_imgref = ImageReferenceSig {
552552
transport: "containers-storage".to_string(),
553553
image: imgref.image.clone(),
554554
signature: imgref.signature.clone(),
@@ -614,7 +614,7 @@ pub(crate) async fn prepare_for_pull_unified(
614614
/// Unified pull: Use podman to pull to containers-storage, then read from there
615615
pub(crate) async fn pull_unified(
616616
repo: &ostree::Repo,
617-
imgref: &ImageReference,
617+
imgref: &ImageReferenceSig,
618618
target_imgref: Option<&OstreeImageReference>,
619619
quiet: bool,
620620
prog: ProgressWriter,
@@ -642,7 +642,7 @@ pub(crate) async fn pull_unified(
642642
imgref,
643643
)?;
644644
// To avoid duplicate success logs, pass a containers-storage imgref to the importer
645-
let cs_imgref = ImageReference {
645+
let cs_imgref = ImageReferenceSig {
646646
transport: "containers-storage".to_string(),
647647
image: imgref.image.clone(),
648648
signature: imgref.signature.clone(),
@@ -654,7 +654,7 @@ pub(crate) async fn pull_unified(
654654

655655
#[context("Pulling")]
656656
pub(crate) async fn pull_from_prepared(
657-
imgref: &ImageReference,
657+
imgref: &ImageReferenceSig,
658658
quiet: bool,
659659
prog: ProgressWriter,
660660
mut prepared_image: PreparedImportMeta,
@@ -729,7 +729,7 @@ pub(crate) async fn pull_from_prepared(
729729
/// Wrapper for pulling a container image, wiring up status output.
730730
pub(crate) async fn pull(
731731
repo: &ostree::Repo,
732-
imgref: &ImageReference,
732+
imgref: &ImageReferenceSig,
733733
target_imgref: Option<&OstreeImageReference>,
734734
quiet: bool,
735735
prog: ProgressWriter,
@@ -922,7 +922,7 @@ async fn deploy(
922922
}
923923

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

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

@@ -1385,7 +1385,7 @@ mod tests {
13851385
builder,
13861386
)?;
13871387
let deploydir = &td.open_dir(deploydir)?;
1388-
let orig_imgref = ImageReference {
1388+
let orig_imgref = ImageReferenceSig {
13891389
image: "quay.io/exampleos/original:sometag".into(),
13901390
transport: "registry".into(),
13911391
signature: None,
@@ -1398,7 +1398,7 @@ mod tests {
13981398
)?;
13991399
}
14001400

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