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