Skip to content

Commit 87da23d

Browse files
Johan-Liebert1travier
authored andcommitted
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 6e62ef9 commit 87da23d

File tree

2 files changed

+30
-5
lines changed

2 files changed

+30
-5
lines changed

crates/lib/src/bootc_composefs/repo.rs

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,24 @@ 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+
66+
let final_imgref = if transport == "registry" {
67+
format!("docker://{img}")
68+
} else {
69+
format!("{transport}:{img}")
70+
};
71+
72+
final_imgref
73+
}
74+
5775
/// Pulls the `image` from `transport` into a composefs repository at /sysroot
5876
/// Checks for boot entries in the image and returns them
5977
#[context("Pulling composefs repository")]
@@ -70,10 +88,13 @@ pub(crate) async fn pull_composefs_repo(
7088

7189
let repo = open_composefs_repo(&rootfs_dir).context("Opening compoesfs repo")?;
7290

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

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

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)