Skip to content

Commit 2d1e928

Browse files
authored
Merge pull request #819 from cgwalters/status-non-bootc
status: Output targeted message in non-bootc case, update docs
2 parents 4621d76 + 485516e commit 2d1e928

16 files changed

+88
-45
lines changed

docs/src/man/bootc-container-lint.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ part of a build process; it will error if any problems are detected.
2323

2424
# VERSION
2525

26-
v0.1.13
26+
v0.1.16

docs/src/man/bootc-container.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ bootc-container-help(8)
3030

3131
# VERSION
3232

33-
v0.1.13
33+
v0.1.16

docs/src/man/bootc-edit.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,4 @@ Only changes to the \`spec\` section are honored.
3636

3737
# VERSION
3838

39-
v0.1.13
39+
v0.1.16

docs/src/man/bootc-install-print-configuration.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ string-valued filesystem name suitable for passing to \`mkfs.\$type\`.
2727

2828
# VERSION
2929

30-
v0.1.13
30+
v0.1.16

docs/src/man/bootc-install-to-disk.md

+7-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ bootc-install-to-disk - Install to the target block device
1010
\[**\--enforce-container-sigpolicy**\] \[**\--target-ostree-remote**\]
1111
\[**\--skip-fetch-check**\] \[**\--disable-selinux**\] \[**\--karg**\]
1212
\[**\--root-ssh-authorized-keys**\] \[**\--generic-image**\]
13-
\[**\--via-loopback**\] \[**-h**\|**\--help**\] \<*DEVICE*\>
13+
\[**\--stateroot**\] \[**\--via-loopback**\] \[**-h**\|**\--help**\]
14+
\<*DEVICE*\>
1415

1516
# DESCRIPTION
1617

@@ -129,6 +130,10 @@ boot.
129130
\- All bootloader types will be installed - Changes to the system
130131
firmware will be skipped
131132

133+
**\--stateroot**=*STATEROOT*
134+
135+
: The stateroot name to use. Defaults to \`default\`
136+
132137
**\--via-loopback**
133138

134139
: Instead of targeting a block device, write to a file via loopback
@@ -144,4 +149,4 @@ firmware will be skipped
144149

145150
# VERSION
146151

147-
v0.1.13
152+
v0.1.16

docs/src/man/bootc-install-to-existing-root.md

+7-3
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ bootc-install-to-existing-root - Install to the host root filesystem
1010
\[**\--target-ostree-remote**\] \[**\--skip-fetch-check**\]
1111
\[**\--disable-selinux**\] \[**\--karg**\]
1212
\[**\--root-ssh-authorized-keys**\] \[**\--generic-image**\]
13-
\[**\--acknowledge-destructive**\] \[**-h**\|**\--help**\]
14-
\[*ROOT_PATH*\]
13+
\[**\--stateroot**\] \[**\--acknowledge-destructive**\]
14+
\[**-h**\|**\--help**\] \[*ROOT_PATH*\]
1515

1616
# DESCRIPTION
1717

@@ -115,6 +115,10 @@ boot.
115115
\- All bootloader types will be installed - Changes to the system
116116
firmware will be skipped
117117

118+
**\--stateroot**=*STATEROOT*
119+
120+
: The stateroot name to use. Defaults to \`default\`
121+
118122
**\--acknowledge-destructive**
119123

120124
: Accept that this is a destructive action and skip a warning timer
@@ -130,4 +134,4 @@ firmware will be skipped
130134

131135
# VERSION
132136

133-
v0.1.13
137+
v0.1.16

docs/src/man/bootc-install-to-filesystem.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ filesystem structure
1313
\[**\--target-ostree-remote**\] \[**\--skip-fetch-check**\]
1414
\[**\--disable-selinux**\] \[**\--karg**\]
1515
\[**\--root-ssh-authorized-keys**\] \[**\--generic-image**\]
16-
\[**-h**\|**\--help**\] \<*ROOT_PATH*\>
16+
\[**\--stateroot**\] \[**-h**\|**\--help**\] \<*ROOT_PATH*\>
1717

1818
# DESCRIPTION
1919

@@ -144,6 +144,10 @@ boot.
144144
\- All bootloader types will be installed - Changes to the system
145145
firmware will be skipped
146146

147+
**\--stateroot**=*STATEROOT*
148+
149+
: The stateroot name to use. Defaults to \`default\`
150+
147151
**-h**, **\--help**
148152

149153
: Print help (see a summary with -h)
@@ -157,4 +161,4 @@ mounting. To override this, use \`\--root-mount-spec\`.
157161

158162
# VERSION
159163

160-
v0.1.13
164+
v0.1.16

docs/src/man/bootc-install.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ bootc-install - Install the running container to a target
1010

1111
Install the running container to a target.
1212

13-
\## Understanding installations
13+
## Understanding installations
1414

1515
OCI containers are effectively layers of tarballs with JSON for
1616
metadata; they cannot be booted directly. The \`bootc install\` flow is
@@ -61,4 +61,4 @@ bootc-install-help(8)
6161

6262
# VERSION
6363

64-
v0.1.13
64+
v0.1.16

docs/src/man/bootc-rollback.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ rollback invocation.
3434

3535
# VERSION
3636

37-
v0.1.13
37+
v0.1.16

docs/src/man/bootc-status.md

+20-8
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,21 @@ bootc-status - Display status
1111

1212
Display status
1313

14-
This will output a YAML-formatted object using a schema intended to
15-
match a Kubernetes resource that describes the state of the booted
16-
system.
14+
If standard output is a terminal, this will output a description of the
15+
bootc system state. If standard output is not a terminal, output a
16+
YAML-formatted object using a schema intended to match a Kubernetes
17+
resource that describes the state of the booted system.
1718

18-
The exact API format is not currently declared stable.
19+
## Parsing output via programs
20+
21+
Either the default YAML format or \`\--format=json\` can be used. Do not
22+
attempt to explicitly parse the output of \`\--format=humanreadable\` as
23+
it will very likely change over time.
24+
25+
## Programmatically detecting whether the system is deployed via bootc
26+
27+
Invoke e.g. \`bootc status \--json\`, and check if \`status.booted\` is
28+
not \`null\`.
1929

2030
# OPTIONS
2131

@@ -26,16 +36,18 @@ The exact API format is not currently declared stable.
2636
\
2737
*Possible values:*
2838

39+
> - humanreadable: Output in Human Readable format
40+
>
2941
> - yaml: Output in YAML format
3042
>
3143
> - json: Output in JSON format
3244
3345
**\--format-version**=*FORMAT_VERSION*
3446

3547
: The desired format version. There is currently one supported
36-
version, which is version \`0\`. Pass this option to explicitly
37-
request it; it is possible that multiple versions will be supported
38-
in the future
48+
version, which is exposed as both \`0\` and \`1\`. Pass this option
49+
to explicitly request it; it is possible that another future version
50+
2 or newer will be supported in the future
3951

4052
**\--booted**
4153

@@ -47,4 +59,4 @@ The exact API format is not currently declared stable.
4759

4860
# VERSION
4961

50-
v0.1.13
62+
v0.1.16

docs/src/man/bootc-switch.md

+11-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ bootc-switch - Target a new container image reference to boot
44

55
# SYNOPSIS
66

7-
**bootc switch** \[**\--quiet**\] \[**\--transport**\]
7+
**bootc switch** \[**\--quiet**\] \[**\--apply**\] \[**\--transport**\]
88
\[**\--enforce-container-sigpolicy**\] \[**\--ostree-remote**\]
99
\[**\--retain**\] \[**-h**\|**\--help**\] \<*TARGET*\>
1010

@@ -15,7 +15,7 @@ Target a new container image reference to boot.
1515
This is almost exactly the same operation as \`upgrade\`, but
1616
additionally changes the container image reference instead.
1717

18-
\## Usage
18+
## Usage
1919

2020
A common pattern is to have a management agent control operating system
2121
updates via container image tags; for example,
@@ -30,6 +30,14 @@ updates via container image tags; for example,
3030

3131
: Dont display progress
3232

33+
**\--apply**
34+
35+
: Restart or reboot into the new target image.
36+
37+
Currently, this option always reboots. In the future this command will
38+
detect the case where no kernel changes are queued, and perform a
39+
userspace-only restart.
40+
3341
**\--transport**=*TRANSPORT* \[default: registry\]
3442

3543
: The transport; e.g. oci, oci-archive, containers-storage. Defaults
@@ -61,4 +69,4 @@ includes a default policy which requires signatures.
6169

6270
# VERSION
6371

64-
v0.1.13
72+
v0.1.16

docs/src/man/bootc-upgrade.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,4 @@ userspace-only restart.
5252

5353
# VERSION
5454

55-
v0.1.13
55+
v0.1.16

docs/src/man/bootc-usr-overlay.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,20 @@ will be discarded on reboot
1212
Adds a transient writable overlayfs on \`/usr\` that will be discarded
1313
on reboot.
1414

15-
\## Use cases
15+
## Use cases
1616

1717
A common pattern is wanting to use tracing/debugging tools, such as
1818
\`strace\` that may not be in the base image. A system package manager
1919
such as \`apt\` or \`dnf\` can apply changes into this transient overlay
2020
that will be discarded on reboot.
2121

22-
\## /etc and /var
22+
## /etc and /var
2323

2424
However, this command has no effect on \`/etc\` and \`/var\` - changes
2525
written there will persist. It is common for package installations to
2626
modify these directories.
2727

28-
\## Unmounting
28+
## Unmounting
2929

3030
Almost always, a system process will hold a reference to the open mount
3131
point. You can however invoke \`umount -l /usr\` to perform a \"lazy
@@ -39,4 +39,4 @@ unmount\".
3939

4040
# VERSION
4141

42-
v0.1.13
42+
v0.1.16

docs/src/man/bootc.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,4 @@ bootc-help(8)
7272

7373
# VERSION
7474

75-
v0.1.13
75+
v0.1.16

lib/src/cli.rs

+12-3
Original file line numberDiff line numberDiff line change
@@ -369,10 +369,19 @@ pub(crate) enum Opt {
369369
Edit(EditOpts),
370370
/// Display status
371371
///
372-
/// This will output a YAML-formatted object using a schema intended to match a Kubernetes resource
373-
/// that describes the state of the booted system.
372+
/// If standard output is a terminal, this will output a description of the bootc system state.
373+
/// If standard output is not a terminal, output a YAML-formatted object using a schema
374+
/// intended to match a Kubernetes resource that describes the state of the booted system.
374375
///
375-
/// The exact API format is not currently declared stable.
376+
/// ## Parsing output via programs
377+
///
378+
/// Either the default YAML format or `--format=json` can be used. Do not attempt to
379+
/// explicitly parse the output of `--format=humanreadable` as it will very likely
380+
/// change over time.
381+
///
382+
/// ## Programmatically detecting whether the system is deployed via bootc
383+
///
384+
/// Invoke e.g. `bootc status --json`, and check if `status.booted` is not `null`.
376385
Status(StatusOpts),
377386
/// Adds a transient writable overlayfs on `/usr` that will be discarded on reboot.
378387
///

lib/src/status.rs

+12-11
Original file line numberDiff line numberDiff line change
@@ -364,8 +364,7 @@ fn human_render_ostree(mut out: impl Write, slot_name: &str, _ostree_commit: &st
364364
Ok(())
365365
}
366366

367-
/// Implementation of rendering our host structure in a "human readable" way.
368-
fn human_readable_output(mut out: impl Write, host: &Host) -> Result<()> {
367+
fn human_readable_output_booted(mut out: impl Write, host: &Host) -> Result<()> {
369368
for (slot_name, status) in [
370369
("staged", &host.status.staged),
371370
("booted", &host.status.booted),
@@ -386,6 +385,16 @@ fn human_readable_output(mut out: impl Write, host: &Host) -> Result<()> {
386385
Ok(())
387386
}
388387

388+
/// Implementation of rendering our host structure in a "human readable" way.
389+
fn human_readable_output(mut out: impl Write, host: &Host) -> Result<()> {
390+
if host.status.booted.is_some() {
391+
human_readable_output_booted(out, host)?;
392+
} else {
393+
writeln!(out, "System is not deployed via bootc.")?;
394+
}
395+
Ok(())
396+
}
397+
389398
#[cfg(test)]
390399
mod tests {
391400
use super::*;
@@ -465,15 +474,7 @@ mod tests {
465474
// staged/rollback image, no booted
466475
let w = human_status_from_spec_fixture(include_str!("fixtures/spec-staged-rollback.yaml"))
467476
.expect("No spec found");
468-
let expected = indoc::indoc! { r"
469-
Current staged image: quay.io/example/someimage:latest
470-
Image version: nightly (2023-10-14 19:22:15 UTC)
471-
Image digest: sha256:16dc2b6256b4ff0d2ec18d2dbfb06d117904010c8cf9732cdb022818cf7a7566
472-
No booted image present
473-
Current rollback image: quay.io/example/someimage:latest
474-
Image version: nightly (2023-09-30 19:22:16 UTC)
475-
Image digest: sha256:736b359467c9437c1ac915acaae952aad854e07eb4a16a94999a48af08c83c34
476-
"};
477+
let expected = "System is not deployed via bootc.\n";
477478
similar_asserts::assert_eq!(w, expected);
478479
}
479480

0 commit comments

Comments
 (0)