Skip to content

Commit 2eeb1ec

Browse files
committed
Add support for configmaps
This is part of #22
1 parent 221e382 commit 2eeb1ec

File tree

10 files changed

+933
-33
lines changed

10 files changed

+933
-33
lines changed

lib/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ tempfile = "3.3.0"
4040
toml = "0.7.2"
4141
xshell = { version = "0.2", optional = true }
4242
uuid = { version = "1.2.2", features = ["v4"] }
43+
reqwest = { version = "0.11.14", features = ["json"] }
4344

4445
[features]
4546
default = ["install"]

lib/src/cli.rs

+20-12
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ pub(crate) enum Opt {
131131
/// Add a transient writable overlayfs on `/usr` that will be discarded on reboot.
132132
#[clap(alias = "usroverlay")]
133133
UsrOverlay,
134+
/// Manipulate configuration
135+
#[clap(subcommand)]
136+
Config(crate::config::ConfigOpts),
134137
/// Install to the target block device
135138
#[cfg(feature = "install")]
136139
Install(crate::install::InstallOpts),
@@ -231,15 +234,13 @@ async fn pull(
231234

232235
/// Stage (queue deployment of) a fetched container image.
233236
#[context("Staging")]
234-
async fn stage(
237+
pub(crate) async fn stage(
235238
sysroot: &SysrootLock,
236239
stateroot: &str,
237240
image: Box<LayeredImageState>,
238241
spec: &HostSpec,
239242
) -> Result<()> {
240-
let cancellable = gio::Cancellable::NONE;
241-
let stateroot = Some(stateroot);
242-
let merge_deployment = sysroot.merge_deployment(stateroot);
243+
let merge_deployment = sysroot.merge_deployment(Some(stateroot));
243244
let origin = glib::KeyFile::new();
244245
let ostree_imgref = spec
245246
.image
@@ -252,14 +253,15 @@ async fn stage(
252253
imgref.to_string().as_str(),
253254
);
254255
}
255-
let _new_deployment = sysroot.stage_tree_with_options(
256-
stateroot,
257-
image.merge_commit.as_str(),
258-
Some(&origin),
256+
crate::deploy::deploy(
257+
sysroot,
259258
merge_deployment.as_ref(),
260-
&Default::default(),
261-
cancellable,
262-
)?;
259+
stateroot,
260+
image,
261+
&origin,
262+
)
263+
.await?;
264+
crate::deploy::cleanup(sysroot).await?;
263265
if let Some(imgref) = ostree_imgref.as_ref() {
264266
println!("Queued for next boot: {imgref}");
265267
}
@@ -282,7 +284,7 @@ pub(crate) fn require_root() -> Result<()> {
282284

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

300+
pub(crate) fn target_deployment(sysroot: &SysrootLock) -> Result<ostree::Deployment> {
301+
let booted_deployment = sysroot.require_booted_deployment()?;
302+
Ok(sysroot.staged_deployment().unwrap_or(booted_deployment))
303+
}
304+
298305
/// Implementation of the `bootc upgrade` CLI command.
299306
#[context("Upgrading")]
300307
async fn upgrade(opts: UpgradeOpts) -> Result<()> {
@@ -476,6 +483,7 @@ where
476483
Opt::Switch(opts) => switch(opts).await,
477484
Opt::Edit(opts) => edit(opts).await,
478485
Opt::UsrOverlay => usroverlay().await,
486+
Opt::Config(opts) => crate::config::run(opts).await,
479487
#[cfg(feature = "install")]
480488
Opt::Install(opts) => crate::install::install(opts).await,
481489
#[cfg(feature = "install")]

0 commit comments

Comments
 (0)