Skip to content

Commit

Permalink
Add support for configmaps
Browse files Browse the repository at this point in the history
This is part of #22
  • Loading branch information
cgwalters committed Aug 7, 2023
1 parent 221e382 commit 2eeb1ec
Show file tree
Hide file tree
Showing 10 changed files with 933 additions and 33 deletions.
1 change: 1 addition & 0 deletions lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ tempfile = "3.3.0"
toml = "0.7.2"
xshell = { version = "0.2", optional = true }
uuid = { version = "1.2.2", features = ["v4"] }
reqwest = { version = "0.11.14", features = ["json"] }

[features]
default = ["install"]
Expand Down
32 changes: 20 additions & 12 deletions lib/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ pub(crate) enum Opt {
/// Add a transient writable overlayfs on `/usr` that will be discarded on reboot.
#[clap(alias = "usroverlay")]
UsrOverlay,
/// Manipulate configuration
#[clap(subcommand)]
Config(crate::config::ConfigOpts),
/// Install to the target block device
#[cfg(feature = "install")]
Install(crate::install::InstallOpts),
Expand Down Expand Up @@ -231,15 +234,13 @@ async fn pull(

/// Stage (queue deployment of) a fetched container image.
#[context("Staging")]
async fn stage(
pub(crate) async fn stage(
sysroot: &SysrootLock,
stateroot: &str,
image: Box<LayeredImageState>,
spec: &HostSpec,
) -> Result<()> {
let cancellable = gio::Cancellable::NONE;
let stateroot = Some(stateroot);
let merge_deployment = sysroot.merge_deployment(stateroot);
let merge_deployment = sysroot.merge_deployment(Some(stateroot));
let origin = glib::KeyFile::new();
let ostree_imgref = spec
.image
Expand All @@ -252,14 +253,15 @@ async fn stage(
imgref.to_string().as_str(),
);
}
let _new_deployment = sysroot.stage_tree_with_options(
stateroot,
image.merge_commit.as_str(),
Some(&origin),
crate::deploy::deploy(
sysroot,
merge_deployment.as_ref(),
&Default::default(),
cancellable,
)?;
stateroot,
image,
&origin,
)
.await?;
crate::deploy::cleanup(sysroot).await?;
if let Some(imgref) = ostree_imgref.as_ref() {
println!("Queued for next boot: {imgref}");
}
Expand All @@ -282,7 +284,7 @@ pub(crate) fn require_root() -> Result<()> {

/// A few process changes that need to be made for writing.
#[context("Preparing for write")]
async fn prepare_for_write() -> Result<()> {
pub(crate) async fn prepare_for_write() -> Result<()> {
if ostree_ext::container_utils::is_ostree_container()? {
anyhow::bail!(
"Detected container (ostree base); this command requires a booted host system."
Expand All @@ -295,6 +297,11 @@ async fn prepare_for_write() -> Result<()> {
Ok(())
}

pub(crate) fn target_deployment(sysroot: &SysrootLock) -> Result<ostree::Deployment> {
let booted_deployment = sysroot.require_booted_deployment()?;
Ok(sysroot.staged_deployment().unwrap_or(booted_deployment))
}

/// Implementation of the `bootc upgrade` CLI command.
#[context("Upgrading")]
async fn upgrade(opts: UpgradeOpts) -> Result<()> {
Expand Down Expand Up @@ -476,6 +483,7 @@ where
Opt::Switch(opts) => switch(opts).await,
Opt::Edit(opts) => edit(opts).await,
Opt::UsrOverlay => usroverlay().await,
Opt::Config(opts) => crate::config::run(opts).await,
#[cfg(feature = "install")]
Opt::Install(opts) => crate::install::install(opts).await,
#[cfg(feature = "install")]
Expand Down
Loading

0 comments on commit 2eeb1ec

Please sign in to comment.