Skip to content

Commit f01fbae

Browse files
authored
Merge pull request #1239 from cgwalters/status-arch
spec, status: Add architecture
2 parents 4f5d55a + dd71d07 commit f01fbae

11 files changed

+22
-6
lines changed

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

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ status:
1414
image:
1515
image: quay.io/centos-bootc/centos-bootc:stream9
1616
transport: registry
17+
architecture: arm64
1718
version: stream9.20240807.0
1819
timestamp: null
1920
imageDigest: sha256:47e5ed613a970b6574bfa954ab25bb6e85656552899aa518b5961d9645102b38

lib/src/fixtures/spec-ostree-remote.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ status:
1414
image:
1515
image: quay.io/otherexample/otherimage:latest
1616
transport: registry
17+
architecture: arm64
1718
version: 20231230.1
1819
timestamp: 2023-12-30T16:10:11Z
1920
imageDigest: sha256:b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c

lib/src/fixtures/spec-ostree-to-bootc.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ status:
1313
image:
1414
image: quay.io/centos-bootc/centos-bootc:stream9
1515
transport: registry
16+
architecture: s390x
1617
version: stream9.20240807.0
1718
timestamp: null
1819
imageDigest: sha256:47e5ed613a970b6574bfa954ab25bb6e85656552899aa518b5961d9645102b38

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

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ status:
1414
image: quay.io/example/someimage:latest
1515
transport: registry
1616
signature: insecure
17+
architecture: arm64
1718
version: nightly
1819
# This one has nanoseconds, which should be dropped for human consumption
1920
timestamp: 2023-10-14T19:22:15.42Z
@@ -29,6 +30,7 @@ status:
2930
image: quay.io/example/someimage:latest
3031
transport: registry
3132
signature: insecure
33+
architecture: arm64
3234
version: nightly
3335
timestamp: 2023-09-30T19:22:16Z
3436
imageDigest: sha256:736b359467c9437c1ac915acaae952aad854e07eb4a16a94999a48af08c83c34

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

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ status:
1414
image: quay.io/example/someimage:latest
1515
transport: registry
1616
signature: insecure
17+
architecture: s390x
1718
version: nightly
1819
timestamp: 2023-10-14T19:22:15Z
1920
imageDigest: sha256:16dc2b6256b4ff0d2ec18d2dbfb06d117904010c8cf9732cdb022818cf7a7566
@@ -29,6 +30,7 @@ status:
2930
image: quay.io/example/someimage:latest
3031
transport: registry
3132
signature: insecure
33+
architecture: s390x
3234
version: nightly
3335
timestamp: 2023-09-30T19:22:16Z
3436
imageDigest: sha256:736b359467c9437c1ac915acaae952aad854e07eb4a16a94999a48af08c83c34

lib/src/fixtures/spec-v1a1-orig.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ status:
1717
version: nightly
1818
timestamp: 2023-10-14T19:22:15Z
1919
imageDigest: sha256:16dc2b6256b4ff0d2ec18d2dbfb06d117904010c8cf9732cdb022818cf7a7566
20+
architecture: amd64
2021
incompatible: false
2122
pinned: false
2223
ostree:
@@ -31,6 +32,7 @@ status:
3132
version: nightly
3233
timestamp: 2023-09-30T19:22:16Z
3334
imageDigest: sha256:736b359467c9437c1ac915acaae952aad854e07eb4a16a94999a48af08c83c34
35+
architecture: amd64
3436
incompatible: false
3537
pinned: false
3638
ostree:

lib/src/fixtures/spec-v1a1.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ status:
1313
image:
1414
image: quay.io/otherexample/otherimage:latest
1515
transport: registry
16+
architecture: s390x
1617
version: 20231230.1
1718
timestamp: 2023-12-30T16:10:11Z
1819
imageDigest: sha256:b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c

lib/src/fixtures/spec-via-local-oci.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ status:
1414
image:
1515
image: /var/mnt/osupdate
1616
transport: oci
17+
architecture: amd64
1718
version: stream9.20240807.0
1819
timestamp: null
1920
imageDigest: sha256:47e5ed613a970b6574bfa954ab25bb6e85656552899aa518b5961d9645102b38

lib/src/spec.rs

+2
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ pub struct ImageStatus {
101101
pub timestamp: Option<chrono::DateTime<chrono::Utc>>,
102102
/// The digest of the fetched image (e.g. sha256:a0...);
103103
pub image_digest: String,
104+
/// The hardware architecture of this image
105+
pub architecture: String,
104106
}
105107

106108
/// A bootable entry

lib/src/status.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -381,9 +381,10 @@ fn human_render_imagestatus(
381381
let prefix_len = prefix.chars().count();
382382
writeln!(out, "{prefix}: {imageref}")?;
383383

384+
let arch = image.architecture.as_str();
384385
write_row_name(&mut out, "Digest", prefix_len)?;
385386
let digest = &image.image_digest;
386-
writeln!(out, "{digest}")?;
387+
writeln!(out, "{digest} ({arch})")?;
387388

388389
// Format the timestamp without nanoseconds since those are just irrelevant noise for human
389390
// consumption - that time scale should basically never matter for container builds.
@@ -477,11 +478,11 @@ mod tests {
477478
.expect("No spec found");
478479
let expected = indoc::indoc! { r"
479480
Staged image: quay.io/example/someimage:latest
480-
Digest: sha256:16dc2b6256b4ff0d2ec18d2dbfb06d117904010c8cf9732cdb022818cf7a7566
481+
Digest: sha256:16dc2b6256b4ff0d2ec18d2dbfb06d117904010c8cf9732cdb022818cf7a7566 (arm64)
481482
Version: nightly (2023-10-14T19:22:15Z)
482483
483484
● Booted image: quay.io/example/someimage:latest
484-
Digest: sha256:736b359467c9437c1ac915acaae952aad854e07eb4a16a94999a48af08c83c34
485+
Digest: sha256:736b359467c9437c1ac915acaae952aad854e07eb4a16a94999a48af08c83c34 (arm64)
485486
Version: nightly (2023-09-30T19:22:16Z)
486487
"};
487488
similar_asserts::assert_eq!(w, expected);
@@ -511,7 +512,7 @@ mod tests {
511512
.expect("No spec found");
512513
let expected = indoc::indoc! { r"
513514
Staged image: quay.io/centos-bootc/centos-bootc:stream9
514-
Digest: sha256:47e5ed613a970b6574bfa954ab25bb6e85656552899aa518b5961d9645102b38
515+
Digest: sha256:47e5ed613a970b6574bfa954ab25bb6e85656552899aa518b5961d9645102b38 (s390x)
515516
Version: stream9.20240807.0
516517
517518
● Booted ostree
@@ -527,7 +528,7 @@ mod tests {
527528
.expect("No spec found");
528529
let expected = indoc::indoc! { r"
529530
● Booted image: quay.io/centos-bootc/centos-bootc:stream9
530-
Digest: sha256:47e5ed613a970b6574bfa954ab25bb6e85656552899aa518b5961d9645102b38
531+
Digest: sha256:47e5ed613a970b6574bfa954ab25bb6e85656552899aa518b5961d9645102b38 (arm64)
531532
Version: stream9.20240807.0
532533
"};
533534
similar_asserts::assert_eq!(w, expected);
@@ -548,7 +549,7 @@ mod tests {
548549
.unwrap();
549550
let expected = indoc::indoc! { r"
550551
● Booted image: oci:/var/mnt/osupdate
551-
Digest: sha256:47e5ed613a970b6574bfa954ab25bb6e85656552899aa518b5961d9645102b38
552+
Digest: sha256:47e5ed613a970b6574bfa954ab25bb6e85656552899aa518b5961d9645102b38 (amd64)
552553
Version: stream9.20240807.0
553554
"};
554555
similar_asserts::assert_eq!(w, expected);

lib/src/store/ostree_container.rs

+2
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,13 @@ fn create_imagestatus(
5555
.and_then(try_deserialize_timestamp);
5656

5757
let version = ostree_container::version_for_config(config).map(ToOwned::to_owned);
58+
let architecture = config.architecture().to_string();
5859
ImageStatus {
5960
image,
6061
version,
6162
timestamp,
6263
image_digest: manifest_digest.to_string(),
64+
architecture,
6365
}
6466
}
6567

0 commit comments

Comments
 (0)