Skip to content

Commit 8c73037

Browse files
composefs-backend: Fix image pull from registry
skopeo (in composefs-rs) doesn't understand the transport "registry:", so we convert it to "docker://" when passing it to skopeo Signed-off-by: Pragyan Poudyal <[email protected]>
1 parent fb08c0a commit 8c73037

File tree

2 files changed

+31
-5
lines changed

2 files changed

+31
-5
lines changed

crates/lib/src/bootc_composefs/repo.rs

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,25 @@ pub(crate) async fn initialize_composefs_repository(
5454
.await
5555
}
5656

57+
/// skopeo (in composefs-rs) doesn't understand "registry:"
58+
/// This function will convert it to "docker://" and return the image ref
59+
///
60+
/// Ex
61+
/// docker://quay.io/some-image
62+
/// containers-storage:some-image
63+
pub(crate) fn get_imgref(transport: &String, image: &String) -> String {
64+
let img = image.strip_prefix(":").unwrap_or(&image);
65+
let transport = transport.strip_suffix(":").unwrap_or(&transport);
66+
67+
let final_imgref = if transport == "registry" {
68+
format!("docker://{img}")
69+
} else {
70+
format!("{transport}:{img}")
71+
};
72+
73+
final_imgref
74+
}
75+
5776
/// Pulls the `image` from `transport` into a composefs repository at /sysroot
5877
/// Checks for boot entries in the image and returns them
5978
#[context("Pulling composefs repository")]
@@ -70,10 +89,13 @@ pub(crate) async fn pull_composefs_repo(
7089

7190
let repo = open_composefs_repo(&rootfs_dir).context("Opening compoesfs repo")?;
7291

73-
let (id, verity) =
74-
composefs_oci_pull(&Arc::new(repo), &format!("{transport}:{image}"), None, None)
75-
.await
76-
.context("Pulling composefs repo")?;
92+
let final_imgref = get_imgref(transport, image);
93+
94+
tracing::debug!("Image to pull {final_imgref}");
95+
96+
let (id, verity) = composefs_oci_pull(&Arc::new(repo), &final_imgref, None, None)
97+
.await
98+
.context("Pulling composefs repo")?;
7799

78100
tracing::info!("id: {}, verity: {}", hex::encode(id), verity.to_hex());
79101

crates/lib/src/bootc_composefs/state.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use rustix::{
1818
};
1919

2020
use crate::bootc_composefs::boot::BootType;
21+
use crate::bootc_composefs::repo::get_imgref;
2122
use crate::bootc_composefs::status::get_sorted_type1_boot_entries;
2223
use crate::parsers::bls_config::BLSConfigType;
2324
use crate::{
@@ -132,9 +133,12 @@ pub(crate) fn write_composefs_state(
132133
..
133134
} = &imgref;
134135

136+
let imgref = get_imgref(&transport, &image_name);
137+
135138
let mut config = tini::Ini::new().section("origin").item(
136139
ORIGIN_CONTAINER,
137-
format!("ostree-unverified-image:{transport}{image_name}"),
140+
// TODO (Johan-Liebert1): The image won't always be unverified
141+
format!("ostree-unverified-image:{imgref}"),
138142
);
139143

140144
config = config

0 commit comments

Comments
 (0)