@@ -253,6 +253,12 @@ pub(crate) fn get_status(
253
253
. map ( |d| boot_entry_from_deployment ( sysroot, d) )
254
254
. transpose ( )
255
255
. context ( "Rollback deployment" ) ?;
256
+ let other_deployments = deployments
257
+ . other
258
+ . iter ( )
259
+ . map ( |d| boot_entry_from_deployment ( sysroot, d) )
260
+ . collect :: < Result < Vec < _ > > > ( )
261
+ . context ( "Other deployments" ) ?;
256
262
let spec = staged
257
263
. as_ref ( )
258
264
. or ( booted. as_ref ( ) )
@@ -279,6 +285,7 @@ pub(crate) fn get_status(
279
285
staged,
280
286
booted,
281
287
rollback,
288
+ other_deployments,
282
289
rollback_queued,
283
290
ty,
284
291
} ;
@@ -361,7 +368,7 @@ fn write_row_name(mut out: impl Write, s: &str, prefix_len: usize) -> Result<()>
361
368
/// Write the data for a container image based status.
362
369
fn human_render_slot (
363
370
mut out : impl Write ,
364
- slot : Slot ,
371
+ slot : Option < Slot > ,
365
372
entry : & crate :: spec:: BootEntry ,
366
373
image : & crate :: spec:: ImageStatus ,
367
374
) -> Result < ( ) > {
@@ -375,9 +382,10 @@ fn human_render_slot(
375
382
Cow :: Owned ( format ! ( "{transport}:{imagename}" ) )
376
383
} ;
377
384
let prefix = match slot {
378
- Slot :: Staged => " Staged image" . into ( ) ,
379
- Slot :: Booted => format ! ( "{} Booted image" , crate :: glyph:: Glyph :: BlackCircle ) ,
380
- Slot :: Rollback => " Rollback image" . into ( ) ,
385
+ Some ( Slot :: Staged ) => " Staged image" . into ( ) ,
386
+ Some ( Slot :: Booted ) => format ! ( "{} Booted image" , crate :: glyph:: Glyph :: BlackCircle ) ,
387
+ Some ( Slot :: Rollback ) => " Rollback image" . into ( ) ,
388
+ _ => " Other image" . into ( ) ,
381
389
} ;
382
390
let prefix_len = prefix. chars ( ) . count ( ) ;
383
391
writeln ! ( out, "{prefix}: {imageref}" ) ?;
@@ -408,6 +416,11 @@ fn human_render_slot(
408
416
writeln ! ( out, "{timestamp}" ) ?;
409
417
}
410
418
419
+ if entry. pinned {
420
+ write_row_name ( & mut out, "Pinned" , prefix_len) ?;
421
+ writeln ! ( out, "yes" ) ?;
422
+ }
423
+
411
424
tracing:: debug!( "pinned={}" , entry. pinned) ;
412
425
413
426
Ok ( ( ) )
@@ -416,20 +429,27 @@ fn human_render_slot(
416
429
/// Output a rendering of a non-container boot entry.
417
430
fn human_render_slot_ostree (
418
431
mut out : impl Write ,
419
- slot : Slot ,
432
+ slot : Option < Slot > ,
420
433
entry : & crate :: spec:: BootEntry ,
421
434
ostree_commit : & str ,
422
435
) -> Result < ( ) > {
423
436
// TODO consider rendering more ostree stuff here like rpm-ostree status does
424
437
let prefix = match slot {
425
- Slot :: Staged => " Staged ostree" . into ( ) ,
426
- Slot :: Booted => format ! ( "{} Booted ostree" , crate :: glyph:: Glyph :: BlackCircle ) ,
427
- Slot :: Rollback => " Rollback ostree" . into ( ) ,
438
+ Some ( Slot :: Staged ) => " Staged ostree" . into ( ) ,
439
+ Some ( Slot :: Booted ) => format ! ( "{} Booted ostree" , crate :: glyph:: Glyph :: BlackCircle ) ,
440
+ Some ( Slot :: Rollback ) => " Rollback ostree" . into ( ) ,
441
+ _ => " Other ostree" . into ( ) ,
428
442
} ;
429
443
let prefix_len = prefix. len ( ) ;
430
444
writeln ! ( out, "{prefix}" ) ?;
431
445
write_row_name ( & mut out, "Commit" , prefix_len) ?;
432
446
writeln ! ( out, "{ostree_commit}" ) ?;
447
+
448
+ if entry. pinned {
449
+ write_row_name ( & mut out, "Pinned" , prefix_len) ?;
450
+ writeln ! ( out, "yes" ) ?;
451
+ }
452
+
433
453
tracing:: debug!( "pinned={}" , entry. pinned) ;
434
454
Ok ( ( ) )
435
455
}
@@ -448,14 +468,27 @@ fn human_readable_output_booted(mut out: impl Write, host: &Host) -> Result<()>
448
468
writeln ! ( out) ?;
449
469
}
450
470
if let Some ( image) = & host_status. image {
451
- human_render_slot ( & mut out, slot_name, host_status, image) ?;
471
+ human_render_slot ( & mut out, Some ( slot_name) , host_status, image) ?;
452
472
} else if let Some ( ostree) = host_status. ostree . as_ref ( ) {
453
- human_render_slot_ostree ( & mut out, slot_name, host_status, & ostree. checksum ) ?;
473
+ human_render_slot_ostree ( & mut out, Some ( slot_name) , host_status, & ostree. checksum ) ?;
454
474
} else {
455
475
writeln ! ( out, "Current {slot_name} state is unknown" ) ?;
456
476
}
457
477
}
458
478
}
479
+
480
+ if !host. status . other_deployments . is_empty ( ) {
481
+ for entry in & host. status . other_deployments {
482
+ writeln ! ( out) ?;
483
+
484
+ if let Some ( image) = & entry. image {
485
+ human_render_slot ( & mut out, None , entry, image) ?;
486
+ } else if let Some ( ostree) = entry. ostree . as_ref ( ) {
487
+ human_render_slot_ostree ( & mut out, None , entry, & ostree. checksum ) ?;
488
+ }
489
+ }
490
+ }
491
+
459
492
Ok ( ( ) )
460
493
}
461
494
@@ -490,7 +523,7 @@ mod tests {
490
523
Staged image: quay.io/example/someimage:latest
491
524
Digest: sha256:16dc2b6256b4ff0d2ec18d2dbfb06d117904010c8cf9732cdb022818cf7a7566 (arm64)
492
525
Version: nightly (2023-10-14T19:22:15Z)
493
-
526
+
494
527
● Booted image: quay.io/example/someimage:latest
495
528
Digest: sha256:736b359467c9437c1ac915acaae952aad854e07eb4a16a94999a48af08c83c34 (arm64)
496
529
Version: nightly (2023-09-30T19:22:16Z)
@@ -508,7 +541,7 @@ mod tests {
508
541
let expected = indoc:: indoc! { r"
509
542
Staged ostree
510
543
Commit: 1c24260fdd1be20f72a4a97a75c582834ee3431fbb0fa8e4f482bb219d633a45
511
-
544
+
512
545
● Booted ostree
513
546
Commit: f9fa3a553ceaaaf30cf85bfe7eed46a822f7b8fd7e14c1e3389cbc3f6d27f791
514
547
" } ;
@@ -524,7 +557,7 @@ mod tests {
524
557
Staged image: quay.io/centos-bootc/centos-bootc:stream9
525
558
Digest: sha256:47e5ed613a970b6574bfa954ab25bb6e85656552899aa518b5961d9645102b38 (s390x)
526
559
Version: stream9.20240807.0
527
-
560
+
528
561
● Booted ostree
529
562
Commit: f9fa3a553ceaaaf30cf85bfe7eed46a822f7b8fd7e14c1e3389cbc3f6d27f791
530
563
" } ;
@@ -588,4 +621,23 @@ mod tests {
588
621
Some ( ImageSignature :: OstreeRemote ( "fedora" . into( ) ) )
589
622
) ;
590
623
}
624
+
625
+ #[ test]
626
+ fn test_human_readable_booted_pinned_spec ( ) {
627
+ // booted image, no staged/rollback
628
+ let w = human_status_from_spec_fixture ( include_str ! ( "fixtures/spec-booted-pinned.yaml" ) )
629
+ . expect ( "No spec found" ) ;
630
+ let expected = indoc:: indoc! { r"
631
+ ● Booted image: quay.io/centos-bootc/centos-bootc:stream9
632
+ Digest: sha256:47e5ed613a970b6574bfa954ab25bb6e85656552899aa518b5961d9645102b38 (arm64)
633
+ Version: stream9.20240807.0
634
+ Pinned: yes
635
+
636
+ Other image: quay.io/centos-bootc/centos-bootc:stream9
637
+ Digest: sha256:47e5ed613a970b6574bfa954ab25bb6e85656552899aa518b5961d9645102b37 (arm64)
638
+ Version: stream9.20240807.0
639
+ Pinned: yes
640
+ " } ;
641
+ similar_asserts:: assert_eq!( w, expected) ;
642
+ }
591
643
}
0 commit comments