Skip to content

Commit cad0718

Browse files
committed
install: make the source digest optional
This is a prep work for the following commit. It will implement pulling the container image from an explicitly given container reference. Thus, there's no need to always fetch the digest because the caller is being explicit about the container image, so let's make the field optional. Signed-off-by: Ondřej Budai <[email protected]>
1 parent c3d595c commit cad0718

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

lib/src/install.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ pub(crate) struct SourceInfo {
222222
/// Image reference we'll pull from (today always containers-storage: type)
223223
pub(crate) imageref: ostree_container::ImageReference,
224224
/// The digest to use for pulls
225-
pub(crate) digest: String,
225+
pub(crate) digest: Option<String>,
226226
/// Whether or not SELinux appears to be enabled in the source commit
227227
pub(crate) selinux: bool,
228228
}
@@ -384,7 +384,7 @@ impl SourceInfo {
384384
let selinux = crate::lsm::xattrs_have_selinux(&xattrs);
385385
Ok(Self {
386386
imageref,
387-
digest,
387+
digest: Some(digest),
388388
selinux,
389389
})
390390
}
@@ -572,8 +572,12 @@ async fn initialize_ostree_root_from_self(
572572
let mut temporary_dir = None;
573573
let src_imageref = if state.skopeo_supports_containers_storage {
574574
// We always use exactly the digest of the running image to ensure predictability.
575-
let spec =
576-
crate::utils::digested_pullspec(&state.source.imageref.name, &state.source.digest);
575+
let digest = state
576+
.source
577+
.digest
578+
.as_ref()
579+
.ok_or_else(|| anyhow::anyhow!("Missing container image digest"))?;
580+
let spec = crate::utils::digested_pullspec(&state.source.imageref.name, digest);
577581
ostree_container::ImageReference {
578582
transport: ostree_container::Transport::ContainerStorage,
579583
name: spec,

0 commit comments

Comments
 (0)