File tree Expand file tree Collapse file tree 4 files changed +21
-8
lines changed
Tests/ContainerRegistryTests Expand file tree Collapse file tree 4 files changed +21
-8
lines changed Original file line number Diff line number Diff line change @@ -45,9 +45,9 @@ public extension RegistryClient {
4545 func getManifest(
4646 repository: ImageReference . Repository ,
4747 reference: any ImageReference . Reference
48- ) async throws -> ImageManifest {
48+ ) async throws -> ( ImageManifest , ContentDescriptor ) {
4949 // See https://github.com/opencontainers/distribution-spec/blob/main/spec.md#pulling-manifests
50- let ( data, _ ) = try await executeRequestThrowing (
50+ let ( data, response ) = try await executeRequestThrowing (
5151 . get(
5252 repository,
5353 path: " manifests/ \( reference) " ,
@@ -58,7 +58,14 @@ public extension RegistryClient {
5858 ) ,
5959 decodingErrors: [ . notFound]
6060 )
61- return try decoder. decode ( ImageManifest . self, from: data)
61+ return (
62+ try decoder. decode ( ImageManifest . self, from: data) ,
63+ ContentDescriptor (
64+ mediaType: response. headerFields [ . contentType] ?? " application/vnd.oci.image.manifest.v1+json " ,
65+ digest: " \( digest ( of: data) ) " ,
66+ size: Int64 ( data. count)
67+ )
68+ )
6269 }
6370
6471 func getIndex(
Original file line number Diff line number Diff line change @@ -16,7 +16,9 @@ import struct Foundation.Data
1616import ContainerRegistry
1717
1818extension RegistryClient {
19- func getImageManifest( forImage image: ImageReference , architecture: String ) async throws -> ImageManifest {
19+ func getImageManifest( forImage image: ImageReference , architecture: String ) async throws -> (
20+ ImageManifest , ContentDescriptor
21+ ) {
2022 // We pushed the amd64 tag but it points to a single-architecture index, not directly to a manifest
2123 // if we get an index we should get a manifest, otherwise we might get a manifest directly
2224
Original file line number Diff line number Diff line change @@ -249,12 +249,13 @@ extension RegistryClient {
249249
250250 let baseImageManifest : ImageManifest
251251 let baseImageConfiguration : ImageConfiguration
252+ let baseImageDescriptor : ContentDescriptor
252253 if let source {
253- baseImageManifest = try await source. getImageManifest (
254+ ( baseImageManifest, baseImageDescriptor ) = try await source. getImageManifest (
254255 forImage: baseImage,
255256 architecture: architecture
256257 )
257- log ( " Found base image manifest: \( baseImageManifest . digest) " )
258+ log ( " Found base image manifest: \( baseImageDescriptor . digest) " )
258259
259260 baseImageConfiguration = try await source. getImageConfiguration (
260261 forImage: baseImage,
Original file line number Diff line number Diff line change @@ -148,7 +148,10 @@ struct SmokeTests {
148148 manifest: test_manifest
149149 )
150150
151- let manifest = try await client. getManifest ( repository: repository, reference: ImageReference . Tag ( " latest " ) )
151+ let ( manifest, _) = try await client. getManifest (
152+ repository: repository,
153+ reference: ImageReference . Tag ( " latest " )
154+ )
152155 #expect( manifest. schemaVersion == 2 )
153156 #expect( manifest. config. mediaType == " application/vnd.docker.container.image.v1+json " )
154157 #expect( manifest. layers. count == 1 )
@@ -187,7 +190,7 @@ struct SmokeTests {
187190 manifest: test_manifest
188191 )
189192
190- let manifest = try await client. getManifest (
193+ let ( manifest, _ ) = try await client. getManifest (
191194 repository: repository,
192195 reference: test_manifest. digest
193196 )
You can’t perform that action at this time.
0 commit comments