@@ -253,6 +253,15 @@ 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 pinned = deployments
257
+ . other
258
+ . iter ( )
259
+ . filter_map ( |d| {
260
+ d. is_pinned ( )
261
+ . then ( || boot_entry_from_deployment ( sysroot, d) . ok ( ) )
262
+ } )
263
+ . collect :: < Option < Vec < _ > > > ( )
264
+ . filter ( |v| !v. is_empty ( ) ) ;
256
265
let spec = staged
257
266
. as_ref ( )
258
267
. or ( booted. as_ref ( ) )
@@ -280,6 +289,7 @@ pub(crate) fn get_status(
280
289
booted,
281
290
rollback,
282
291
rollback_queued,
292
+ pinned,
283
293
ty,
284
294
} ;
285
295
Ok ( ( deployments, host) )
@@ -336,6 +346,7 @@ pub enum Slot {
336
346
Staged ,
337
347
Booted ,
338
348
Rollback ,
349
+ Pinned ,
339
350
}
340
351
341
352
impl std:: fmt:: Display for Slot {
@@ -344,6 +355,7 @@ impl std::fmt::Display for Slot {
344
355
Slot :: Staged => "staged" ,
345
356
Slot :: Booted => "booted" ,
346
357
Slot :: Rollback => "rollback" ,
358
+ Slot :: Pinned => "pinned" ,
347
359
} ;
348
360
f. write_str ( s)
349
361
}
@@ -377,6 +389,7 @@ fn human_render_imagestatus(
377
389
Slot :: Staged => " Staged image" . into ( ) ,
378
390
Slot :: Booted => format ! ( "{} Booted image" , crate :: glyph:: Glyph :: BlackCircle ) ,
379
391
Slot :: Rollback => " Rollback image" . into ( ) ,
392
+ Slot :: Pinned => " Pinned image" . into ( ) ,
380
393
} ;
381
394
let prefix_len = prefix. chars ( ) . count ( ) ;
382
395
writeln ! ( out, "{prefix}: {imageref}" ) ?;
@@ -416,6 +429,7 @@ fn human_render_ostree(mut out: impl Write, slot: Slot, ostree_commit: &str) ->
416
429
Slot :: Staged => " Staged ostree" . into ( ) ,
417
430
Slot :: Booted => format ! ( "{} Booted ostree" , crate :: glyph:: Glyph :: BlackCircle ) ,
418
431
Slot :: Rollback => " Rollback ostree" . into ( ) ,
432
+ Slot :: Pinned => " Pinned ostree" . into ( ) ,
419
433
} ;
420
434
let prefix_len = prefix. len ( ) ;
421
435
writeln ! ( out, "{prefix}" ) ?;
@@ -446,6 +460,18 @@ fn human_readable_output_booted(mut out: impl Write, host: &Host) -> Result<()>
446
460
}
447
461
}
448
462
}
463
+
464
+ if let Some ( pinned) = & host. status . pinned {
465
+ writeln ! ( out) ?;
466
+ for entry in pinned {
467
+ if let Some ( image) = & entry. image {
468
+ human_render_imagestatus ( & mut out, Slot :: Pinned , image) ?;
469
+ } else if let Some ( ostree) = entry. ostree . as_ref ( ) {
470
+ human_render_ostree ( & mut out, Slot :: Pinned , & ostree. checksum ) ?;
471
+ }
472
+ }
473
+ }
474
+
449
475
Ok ( ( ) )
450
476
}
451
477
@@ -480,7 +506,7 @@ mod tests {
480
506
Staged image: quay.io/example/someimage:latest
481
507
Digest: sha256:16dc2b6256b4ff0d2ec18d2dbfb06d117904010c8cf9732cdb022818cf7a7566 (arm64)
482
508
Version: nightly (2023-10-14T19:22:15Z)
483
-
509
+
484
510
● Booted image: quay.io/example/someimage:latest
485
511
Digest: sha256:736b359467c9437c1ac915acaae952aad854e07eb4a16a94999a48af08c83c34 (arm64)
486
512
Version: nightly (2023-09-30T19:22:16Z)
@@ -498,7 +524,7 @@ mod tests {
498
524
let expected = indoc:: indoc! { r"
499
525
Staged ostree
500
526
Commit: 1c24260fdd1be20f72a4a97a75c582834ee3431fbb0fa8e4f482bb219d633a45
501
-
527
+
502
528
● Booted ostree
503
529
Commit: f9fa3a553ceaaaf30cf85bfe7eed46a822f7b8fd7e14c1e3389cbc3f6d27f791
504
530
" } ;
@@ -514,7 +540,7 @@ mod tests {
514
540
Staged image: quay.io/centos-bootc/centos-bootc:stream9
515
541
Digest: sha256:47e5ed613a970b6574bfa954ab25bb6e85656552899aa518b5961d9645102b38 (s390x)
516
542
Version: stream9.20240807.0
517
-
543
+
518
544
● Booted ostree
519
545
Commit: f9fa3a553ceaaaf30cf85bfe7eed46a822f7b8fd7e14c1e3389cbc3f6d27f791
520
546
" } ;
@@ -534,6 +560,23 @@ mod tests {
534
560
similar_asserts:: assert_eq!( w, expected) ;
535
561
}
536
562
563
+ #[ test]
564
+ fn test_human_readable_booted_pinned_spec ( ) {
565
+ // booted image, no staged/rollback
566
+ let w = human_status_from_spec_fixture ( include_str ! ( "fixtures/spec-booted-pinned.yaml" ) )
567
+ . expect ( "No spec found" ) ;
568
+ let expected = indoc:: indoc! { r"
569
+ ● Booted image: quay.io/centos-bootc/centos-bootc:stream9
570
+ Digest: sha256:47e5ed613a970b6574bfa954ab25bb6e85656552899aa518b5961d9645102b38 (arm64)
571
+ Version: stream9.20240807.0
572
+
573
+ Pinned image: quay.io/centos-bootc/centos-bootc:stream9
574
+ Digest: sha256:47e5ed613a970b6574bfa954ab25bb6e85656552899aa518b5961d9645102b37 (arm64)
575
+ Version: stream9.20240807.0
576
+ " } ;
577
+ similar_asserts:: assert_eq!( w, expected) ;
578
+ }
579
+
537
580
#[ test]
538
581
fn test_human_readable_staged_rollback_spec ( ) {
539
582
// staged/rollback image, no booted
0 commit comments