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