Skip to content

Commit

Permalink
install: Factor out helper to create aleph version
Browse files Browse the repository at this point in the history
Prep for the anaconda install completion work.

Signed-off-by: Colin Walters <[email protected]>
  • Loading branch information
cgwalters committed Nov 22, 2024
1 parent 7c8121a commit fd86d1d
Showing 1 changed file with 27 additions and 17 deletions.
44 changes: 27 additions & 17 deletions lib/src/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,32 @@ impl FromStr for MountSpec {
}
}

impl InstallAleph {
#[context("Creating aleph data")]
pub(crate) fn new(
src_imageref: &ostree_container::OstreeImageReference,
imgstate: &ostree_container::store::LayeredImageState,
selinux_state: &SELinuxFinalState,
) -> Result<Self> {
let uname = rustix::system::uname();
let labels = crate::status::labels_of_config(&imgstate.configuration);
let timestamp = labels
.and_then(|l| {
l.get(oci_spec::image::ANNOTATION_CREATED)
.map(|s| s.as_str())
})
.and_then(crate::status::try_deserialize_timestamp);
let r = InstallAleph {
image: src_imageref.imgref.name.clone(),
version: imgstate.version().as_ref().map(|s| s.to_string()),
timestamp,
kernel: uname.release().to_str()?.to_string(),
selinux: selinux_state.to_aleph().to_string(),
};
Ok(r)
}
}

impl SourceInfo {
// Inspect container information and convert it to an ostree image reference
// that pulls from containers-storage.
Expand Down Expand Up @@ -842,23 +868,7 @@ async fn install_container(
osconfig::inject_root_ssh_authorized_keys(&root, sepolicy, contents)?;
}

let uname = rustix::system::uname();

let labels = crate::status::labels_of_config(&imgstate.configuration);
let timestamp = labels
.and_then(|l| {
l.get(oci_spec::image::ANNOTATION_CREATED)
.map(|s| s.as_str())
})
.and_then(crate::status::try_deserialize_timestamp);
let aleph = InstallAleph {
image: src_imageref.imgref.name.clone(),
version: imgstate.version().as_ref().map(|s| s.to_string()),
timestamp,
kernel: uname.release().to_str()?.to_string(),
selinux: state.selinux_state.to_aleph().to_string(),
};

let aleph = InstallAleph::new(&src_imageref, &imgstate, &state.selinux_state)?;
Ok((deployment, aleph))
}

Expand Down

0 comments on commit fd86d1d

Please sign in to comment.