Skip to content

Commit

Permalink
deploy: Change pull function to take sysroot
Browse files Browse the repository at this point in the history
Prep for a podman backend, where we will write outside of the
ostree repo.

Signed-off-by: Colin Walters <[email protected]>
  • Loading branch information
cgwalters committed Dec 3, 2023
1 parent f7036d5 commit 6956054
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
7 changes: 3 additions & 4 deletions lib/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ async fn upgrade(opts: UpgradeOpts) -> Result<()> {
}
}
} else {
let fetched = crate::deploy::pull(&sysroot.repo(), imgref, opts.quiet).await?;
let fetched = crate::deploy::pull(&sysroot, imgref, opts.quiet).await?;
let staged_digest = staged_image.as_ref().map(|s| s.image_digest.as_str());
let fetched_digest = fetched.manifest_digest.as_str();
tracing::debug!("staged: {staged_digest:?}");
Expand Down Expand Up @@ -371,7 +371,7 @@ async fn switch(opts: SwitchOpts) -> Result<()> {
}
let new_spec = RequiredHostSpec::from_spec(&new_spec)?;

let fetched = crate::deploy::pull(repo, &target, opts.quiet).await?;
let fetched = crate::deploy::pull(sysroot, &target, opts.quiet).await?;

if !opts.retain {
// By default, we prune the previous ostree ref so it will go away after later upgrades
Expand All @@ -395,7 +395,6 @@ async fn switch(opts: SwitchOpts) -> Result<()> {
async fn edit(opts: EditOpts) -> Result<()> {
prepare_for_write().await?;
let sysroot = &get_locked_sysroot().await?;
let repo = &sysroot.repo();
let (booted_deployment, _deployments, host) =
crate::status::get_status_require_booted(sysroot)?;
let new_host: Host = if let Some(filename) = opts.filename {
Expand All @@ -414,7 +413,7 @@ async fn edit(opts: EditOpts) -> Result<()> {
return Ok(());
}
let new_spec = RequiredHostSpec::from_spec(&new_host.spec)?;
let fetched = crate::deploy::pull(repo, new_spec.image, opts.quiet).await?;
let fetched = crate::deploy::pull(sysroot, new_spec.image, opts.quiet).await?;

// TODO gc old layers here

Expand Down
3 changes: 2 additions & 1 deletion lib/src/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,11 @@ pub(crate) async fn new_importer(
/// Wrapper for pulling a container image, wiring up status output.
#[context("Pulling")]
pub(crate) async fn pull(
repo: &ostree::Repo,
sysroot: &SysrootLock,
imgref: &ImageReference,
quiet: bool,
) -> Result<Box<LayeredImageState>> {
let repo = &sysroot.repo();
let imgref = &OstreeImageReference::from(imgref.clone());
let mut imp = new_importer(repo, imgref).await?;
let prep = match imp.prepare().await? {
Expand Down

0 comments on commit 6956054

Please sign in to comment.