@@ -106,6 +106,9 @@ pub struct ImageInspect {
106106 /// SHA256 image identifier
107107 pub id : String ,
108108
109+ /// Image digest
110+ pub digest : oci_spec:: image:: Digest ,
111+
109112 /// Image size in bytes
110113 pub size : u64 ,
111114
@@ -232,35 +235,6 @@ pub fn get_image_size(name: &str) -> Result<u64> {
232235 Ok ( info. size )
233236}
234237
235- /// Get container image digest (sha256) for caching purposes.
236- /// Returns the digest in the format "sha256:abc123..."
237- pub fn get_image_digest ( name : & str ) -> Result < String > {
238- tracing:: debug!( "Getting digest for image: {}" , name) ;
239-
240- // Use skopeo inspect to get the manifest digest, which is more reliable than podman
241- // for getting the actual @sha256 digest that can be used for caching
242- let output = hostexec:: command ( "skopeo" , None ) ?
243- . args ( [ "inspect" , & format ! ( "containers-storage:{}" , name) ] )
244- . run_and_parse_json :: < serde_json:: Value > ( )
245- . map_err ( |e| eyre ! ( "Failed to inspect image with skopeo: {}" , e) ) ?;
246-
247- // Extract the digest from the skopeo output
248- if let Some ( digest) = output. get ( "Digest" ) . and_then ( |d| d. as_str ( ) ) {
249- tracing:: debug!( "Found image digest: {}" , digest) ;
250- Ok ( digest. to_string ( ) )
251- } else {
252- // Fall back to podman image inspect
253- tracing:: debug!( "No digest in skopeo output, falling back to podman inspect" ) ;
254- let info = inspect ( name) ?;
255- // Podman ID is already in sha256:xxx format
256- if info. id . starts_with ( "sha256:" ) {
257- Ok ( info. id )
258- } else {
259- Ok ( format ! ( "sha256:{}" , info. id) )
260- }
261- }
262- }
263-
264238#[ cfg( test) ]
265239mod tests {
266240 use super :: * ;
0 commit comments