@@ -3,10 +3,12 @@ use std::collections::VecDeque;
33use crate :: spec:: { BootEntry , Host , HostSpec , HostStatus , ImageStatus } ;
44use crate :: spec:: { ImageReference , ImageSignature } ;
55use anyhow:: { Context , Result } ;
6+ use k8s_openapi:: apimachinery:: pkg:: apis:: meta:: v1 as k8smeta;
67use ostree:: glib;
78use ostree_container:: OstreeImageReference ;
89use ostree_ext:: container as ostree_container;
910use ostree_ext:: keyfileext:: KeyFileExt ;
11+ use ostree_ext:: oci_spec;
1012use ostree_ext:: ostree;
1113use ostree_ext:: sysroot:: SysrootLock ;
1214
@@ -87,6 +89,22 @@ pub(crate) struct Deployments {
8789 pub ( crate ) other : VecDeque < ostree:: Deployment > ,
8890}
8991
92+ fn try_deserialize_timestamp ( t : & str ) -> Option < k8smeta:: Time > {
93+ match chrono:: DateTime :: parse_from_rfc3339 ( t) . context ( "Parsing timestamp" ) {
94+ Ok ( t) => Some ( k8smeta:: Time ( t. with_timezone ( & chrono:: Utc ) ) ) ,
95+ Err ( e) => {
96+ tracing:: warn!( "Invalid timestamp in image: {:#}" , e) ;
97+ None
98+ }
99+ }
100+ }
101+
102+ pub ( crate ) fn labels_of_config (
103+ config : & oci_spec:: image:: ImageConfiguration ,
104+ ) -> Option < & std:: collections:: HashMap < String , String > > {
105+ config. config ( ) . as_ref ( ) . and_then ( |c| c. labels ( ) . as_ref ( ) )
106+ }
107+
90108fn boot_entry_from_deployment (
91109 sysroot : & SysrootLock ,
92110 deployment : & ostree:: Deployment ,
@@ -98,9 +116,23 @@ fn boot_entry_from_deployment(
98116 let csum = deployment. csum ( ) ;
99117 let incompatible = crate :: utils:: origin_has_rpmostree_stuff ( origin) ;
100118 let imgstate = ostree_container:: store:: query_image_commit ( repo, & csum) ?;
119+ let config = imgstate. configuration . as_ref ( ) ;
120+ let labels = config. and_then ( labels_of_config) ;
121+ let timestamp = labels
122+ . and_then ( |l| {
123+ l. get ( oci_spec:: image:: ANNOTATION_CREATED )
124+ . map ( |s| s. as_str ( ) )
125+ } )
126+ . and_then ( try_deserialize_timestamp) ;
127+
128+ let version = config
129+ . and_then ( ostree_container:: version_for_config)
130+ . map ( ToOwned :: to_owned) ;
101131 (
102132 Some ( ImageStatus {
103133 image,
134+ version,
135+ timestamp,
104136 image_digest : imgstate. manifest_digest ,
105137 } ) ,
106138 incompatible,
0 commit comments