@@ -72,22 +72,32 @@ func currentPlatform() gcr.Platform {
7272
7373// inspectManifest synchronously inspects a remote image to get its digest
7474// without pulling the image. This is used for upfront digest discovery.
75+ // For multi-arch images, it returns the platform-specific manifest digest
76+ // (matching the current host platform) rather than the manifest index digest.
7577func (c * ociClient ) inspectManifest (ctx context.Context , imageRef string ) (string , error ) {
7678 ref , err := name .ParseReference (imageRef )
7779 if err != nil {
7880 return "" , fmt .Errorf ("parse image reference: %w" , err )
7981 }
8082
81- // Use system authentication (reads from ~/.docker/config.json, etc.)
82- // Default retry: only on network errors, max ~1.3s total
83- descriptor , err := remote .Head (ref ,
83+ // Use remote.Image with platform filtering to get the platform-specific digest.
84+ // For multi-arch images, this resolves the manifest index to the correct platform.
85+ // This matches what pullToOCILayout does to ensure cache key consistency.
86+ // Note: remote.Image is lazy - it only fetches the manifest, not layer blobs.
87+ img , err := remote .Image (ref ,
8488 remote .WithContext (ctx ),
85- remote .WithAuthFromKeychain (authn .DefaultKeychain ))
89+ remote .WithAuthFromKeychain (authn .DefaultKeychain ),
90+ remote .WithPlatform (currentPlatform ()))
8691 if err != nil {
8792 return "" , fmt .Errorf ("fetch manifest: %w" , wrapRegistryError (err ))
8893 }
8994
90- return descriptor .Digest .String (), nil
95+ digest , err := img .Digest ()
96+ if err != nil {
97+ return "" , fmt .Errorf ("get image digest: %w" , err )
98+ }
99+
100+ return digest .String (), nil
91101}
92102
93103// pullResult contains the metadata and digest from pulling an image
0 commit comments