Skip to content

Commit

Permalink
Port to ostree-ext 0.13, cap-std 3
Browse files Browse the repository at this point in the history
Main changes are

- Configuration object is no longer an `Option<T>`
- The metadata trait extensions now must be from cap-std

Signed-off-by: Colin Walters <walters@verbum.org>
  • Loading branch information
cgwalters committed Jan 24, 2024
1 parent 7874e05 commit f3ded38
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 20 deletions.
4 changes: 2 additions & 2 deletions lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ anstream = "0.6.4"
anstyle = "1.0.4"
anyhow = "1.0"
camino = { version = "1.0.4", features = ["serde1"] }
ostree-ext = { version = "0.12.8" }
ostree-ext = { version = "0.13" }
chrono = { version = "0.4.23", features = ["serde"] }
clap = { version= "4.2", features = ["derive"] }
clap_mangen = { version = "0.2", optional = true }
cap-std-ext = "3"
cap-std-ext = "4"
hex = "^0.4"
fn-error-context = "0.2.0"
gvariant = "0.4.0"
Expand Down
5 changes: 2 additions & 3 deletions lib/src/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use anyhow::Ok;
use anyhow::{Context, Result};

use cap_std::fs::Dir;
use cap_std::fs::{Dir, MetadataExt};
use cap_std_ext::cap_std;
use cap_std_ext::dirext::CapStdExtDirExt;
use fn_error_context::context;
Expand All @@ -16,7 +16,6 @@ use ostree_ext::container::store::PrepareResult;
use ostree_ext::ostree;
use ostree_ext::ostree::Deployment;
use ostree_ext::sysroot::SysrootLock;
use rustix::fs::MetadataExt;

use crate::spec::HostSpec;
use crate::spec::ImageReference;
Expand Down Expand Up @@ -315,7 +314,7 @@ pub(crate) fn switch_origin_inplace(root: &Dir, imgref: &ImageReference) -> Resu

#[test]
fn test_switch_inplace() -> Result<()> {
use std::os::unix::fs::DirBuilderExt;
use cap_std::fs::DirBuilderExt;

let td = cap_std_ext::cap_tempfile::TempDir::new(cap_std::ambient_authority())?;
let mut builder = cap_std::fs::DirBuilder::new();
Expand Down
6 changes: 2 additions & 4 deletions lib/src/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,13 @@ use anyhow::Ok;
use anyhow::{anyhow, Context, Result};
use camino::Utf8Path;
use camino::Utf8PathBuf;
use cap_std::fs::Dir;
use cap_std::fs::{Dir, MetadataExt};
use cap_std_ext::cap_std;
use cap_std_ext::prelude::CapStdExtDirExt;
use chrono::prelude::*;
use clap::ValueEnum;
use ostree_ext::oci_spec;
use rustix::fs::FileTypeExt;
use rustix::fs::MetadataExt;

use fn_error_context::context;
use ostree::gio;
Expand Down Expand Up @@ -691,8 +690,7 @@ async fn initialize_ostree_root_from_self(

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

let config = state.configuration.as_ref();
let labels = config.and_then(crate::status::labels_of_config);
let labels = crate::status::labels_of_config(&state.configuration);
let timestamp = labels
.and_then(|l| {
l.get(oci_spec::image::ANNOTATION_CREATED)
Expand Down
17 changes: 6 additions & 11 deletions lib/src/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,19 +117,17 @@ pub(crate) fn labels_of_config(
pub(crate) fn create_imagestatus(
image: ImageReference,
manifest_digest: &str,
config: Option<&ImageConfiguration>,
config: &ImageConfiguration,
) -> ImageStatus {
let labels = config.and_then(labels_of_config);
let labels = labels_of_config(config);
let timestamp = labels
.and_then(|l| {
l.get(oci_spec::image::ANNOTATION_CREATED)
.map(|s| s.as_str())
})
.and_then(try_deserialize_timestamp);

let version = config
.and_then(ostree_container::version_for_config)
.map(ToOwned::to_owned);
let version = ostree_container::version_for_config(config).map(ToOwned::to_owned);
ImageStatus {
image,
version,
Expand All @@ -155,13 +153,10 @@ fn boot_entry_from_deployment(
let csum = deployment.csum();
let imgstate = ostree_container::store::query_image_commit(repo, &csum)?;
let cached = imgstate.cached_update.map(|cached| {
create_imagestatus(image.clone(), &cached.manifest_digest, Some(&cached.config))
create_imagestatus(image.clone(), &cached.manifest_digest, &cached.config)
});
let imagestatus = create_imagestatus(
image,
&imgstate.manifest_digest,
imgstate.configuration.as_ref(),
);
let imagestatus =
create_imagestatus(image, &imgstate.manifest_digest, &imgstate.configuration);
// We found a container-image based deployment
(Some(imagestatus), cached)
} else {
Expand Down

0 comments on commit f3ded38

Please sign in to comment.