Skip to content

Commit e7bc1c8

Browse files
cli/switch: Make target optional
If we have `--from-downloaded` then make `target` optional Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
1 parent d7078b3 commit e7bc1c8

2 files changed

Lines changed: 12 additions & 7 deletions

File tree

‎crates/lib/src/cli.rs‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,11 +200,12 @@ pub(crate) struct SwitchOpts {
200200
pub(crate) unified_storage_exp: bool,
201201

202202
/// Target image to use for the next boot.
203+
/// Required unless `--from-downloaded` is present.
203204
#[clap(
204-
required_unless_present = "from-downloaded",
205-
conflicts_with = "from-downloaded"
205+
required_unless_present = "from_downloaded",
206+
conflicts_with = "from_downloaded"
206207
)]
207-
pub(crate) target: String,
208+
pub(crate) target: Option<String>,
208209

209210
#[clap(flatten)]
210211
pub(crate) progress: ProgressOptions,
@@ -1434,11 +1435,17 @@ async fn upgrade(
14341435

14351436
Ok(())
14361437
}
1438+
1439+
#[context("Getting imgref for switch")]
14371440
pub(crate) fn imgref_for_switch(opts: &SwitchOpts) -> Result<ImageReference> {
14381441
let transport = ostree_container::Transport::try_from(opts.transport.as_str())?;
14391442
let imgref = ostree_container::ImageReference {
14401443
transport,
1441-
name: opts.target.to_string(),
1444+
name: opts
1445+
.target
1446+
.as_ref()
1447+
.ok_or_else(|| anyhow!("Target image not found"))?
1448+
.to_string(),
14421449
};
14431450
let sigverify = sigpolicy_from_opt(opts.enforce_container_sigpolicy);
14441451
let target = ostree_container::OstreeImageReference { sigverify, imgref };

‎docs/src/man/bootc-switch.8.md‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,7 @@ Soft reboot allows faster system restart by avoiding full hardware reboot when p
3939
<!-- BEGIN GENERATED OPTIONS -->
4040
**TARGET**
4141

42-
Target image to use for the next boot
43-
44-
This argument is required.
42+
Target image to use for the next boot. Required unless `--from-downloaded` is present
4543

4644
**--quiet**
4745

0 commit comments

Comments
 (0)