Skip to content

Commit aae859f

Browse files
committed
status: Drop nanoseconds from time
This is just irrelevant noise; nanoseconds never matter for container builds. Motivated by just making this look visually nicer. In the future I'd like to look at rendering this how e.g. systemd does it also including a "; 1 day ago" humantime suffix. Signed-off-by: Colin Walters <[email protected]>
1 parent 190085d commit aae859f

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

lib/src/fixtures/spec-staged-booted.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ status:
1515
transport: registry
1616
signature: insecure
1717
version: nightly
18-
timestamp: 2023-10-14T19:22:15Z
18+
# This one has nanoseconds, which should be dropped for human consumption
19+
timestamp: 2023-10-14T19:22:15.42Z
1920
imageDigest: sha256:16dc2b6256b4ff0d2ec18d2dbfb06d117904010c8cf9732cdb022818cf7a7566
2021
incompatible: false
2122
pinned: false

lib/src/status.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,13 @@ fn human_render_imagestatus(
379379
let digest = &image.image_digest;
380380
writeln!(out, "{digest}")?;
381381

382-
let timestamp = image.timestamp.as_ref();
382+
// Format the timestamp without nanoseconds since those are just irrelevant noise for human
383+
// consumption - that time scale should basically never matter for container builds.
384+
let timestamp = image
385+
.timestamp
386+
.as_ref()
387+
// This format is the same as RFC3339, just without nanos.
388+
.map(|t| t.to_utc().format("%Y-%m-%dT%H:%M:%SZ"));
383389
// If we have a version, combine with timestamp
384390
if let Some(version) = image.version.as_deref() {
385391
write_row_name(&mut out, "Version", prefix_len)?;
@@ -466,11 +472,11 @@ mod tests {
466472
let expected = indoc::indoc! { r"
467473
Staged image: quay.io/example/someimage:latest
468474
Digest: sha256:16dc2b6256b4ff0d2ec18d2dbfb06d117904010c8cf9732cdb022818cf7a7566
469-
Version: nightly (2023-10-14 19:22:15 UTC)
475+
Version: nightly (2023-10-14T19:22:15Z)
470476
471477
● Booted image: quay.io/example/someimage:latest
472478
Digest: sha256:736b359467c9437c1ac915acaae952aad854e07eb4a16a94999a48af08c83c34
473-
Version: nightly (2023-09-30 19:22:16 UTC)
479+
Version: nightly (2023-09-30T19:22:16Z)
474480
"};
475481
similar_asserts::assert_eq!(w, expected);
476482
}

0 commit comments

Comments
 (0)