@@ -3,10 +3,12 @@ use std::collections::VecDeque;
3
3
use crate :: spec:: { BootEntry , Host , HostSpec , HostStatus , ImageStatus } ;
4
4
use crate :: spec:: { ImageReference , ImageSignature } ;
5
5
use anyhow:: { Context , Result } ;
6
+ use k8s_openapi:: apimachinery:: pkg:: apis:: meta:: v1 as k8smeta;
6
7
use ostree:: glib;
7
8
use ostree_container:: OstreeImageReference ;
8
9
use ostree_ext:: container as ostree_container;
9
10
use ostree_ext:: keyfileext:: KeyFileExt ;
11
+ use ostree_ext:: oci_spec;
10
12
use ostree_ext:: ostree;
11
13
use ostree_ext:: sysroot:: SysrootLock ;
12
14
@@ -87,6 +89,22 @@ pub(crate) struct Deployments {
87
89
pub ( crate ) other : VecDeque < ostree:: Deployment > ,
88
90
}
89
91
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
+
90
108
fn boot_entry_from_deployment (
91
109
sysroot : & SysrootLock ,
92
110
deployment : & ostree:: Deployment ,
@@ -98,9 +116,23 @@ fn boot_entry_from_deployment(
98
116
let csum = deployment. csum ( ) ;
99
117
let incompatible = crate :: utils:: origin_has_rpmostree_stuff ( origin) ;
100
118
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) ;
101
131
(
102
132
Some ( ImageStatus {
103
133
image,
134
+ version,
135
+ timestamp,
104
136
image_digest : imgstate. manifest_digest ,
105
137
} ) ,
106
138
incompatible,
0 commit comments