1515public extension RegistryClient {
1616 func putManifest(
1717 repository: ImageReference . Repository ,
18- reference: any ImageReference . Reference ,
18+ reference: ( any ImageReference . Reference ) ? = nil ,
1919 manifest: ImageManifest
20- ) async throws
21- -> String
22- {
20+ ) async throws -> ContentDescriptor {
2321 // See https://github.com/opencontainers/distribution-spec/blob/main/spec.md#pushing-manifests
24- let httpResponse = try await executeRequestThrowing (
25- // All blob uploads have Content-Type: application/octet-stream on the wire, even if mediatype is different
22+
23+ let encoded = try encoder. encode ( manifest)
24+ let digest = digest ( of: encoded)
25+ let mediaType = manifest. mediaType ?? " application/vnd.oci.image.manifest.v1+json "
26+
27+ let _ = try await executeRequestThrowing (
2628 . put(
2729 repository,
28- path: " manifests/ \( reference) " ,
29- contentType: manifest . mediaType ?? " application/vnd.oci.image.manifest.v1+json "
30+ path: " manifests/ \( reference ?? digest ) " ,
31+ contentType: mediaType
3032 ) ,
31- uploading: manifest ,
33+ uploading: encoded ,
3234 expectingStatus: . created,
3335 decodingErrors: [ . notFound]
3436 )
3537
36- // The distribution spec says the response MUST contain a Location header
37- // providing a URL from which the saved manifest can be downloaded.
38- // However some registries return URLs which cannot be fetched, and
39- // ECR does not set this header at all.
40- // If the header is not present, create a suitable value.
41- // https://github.com/opencontainers/distribution-spec/blob/main/spec.md#pulling-manifests
42- return httpResponse. response. headerFields [ . location]
43- ?? registryURL. distributionEndpoint ( forRepository: repository, andEndpoint: " manifests/ \( manifest. digest) " )
44- . absoluteString
38+ return . init( mediaType: mediaType, digest: " \( digest) " , size: Int64 ( encoded. count) )
4539 }
4640
47- func getManifest( repository: ImageReference . Repository , reference: any ImageReference . Reference ) async throws
48- -> ImageManifest
49- {
41+ func getManifest(
42+ repository: ImageReference . Repository ,
43+ reference: any ImageReference . Reference
44+ ) async throws -> ImageManifest {
5045 // See https://github.com/opencontainers/distribution-spec/blob/main/spec.md#pulling-manifests
5146 try await executeRequestThrowing (
5247 . get(
@@ -62,9 +57,10 @@ public extension RegistryClient {
6257 . data
6358 }
6459
65- func getIndex( repository: ImageReference . Repository , reference: any ImageReference . Reference ) async throws
66- -> ImageIndex
67- {
60+ func getIndex(
61+ repository: ImageReference . Repository ,
62+ reference: any ImageReference . Reference
63+ ) async throws -> ImageIndex {
6864 // See https://github.com/opencontainers/distribution-spec/blob/main/spec.md#pulling-manifests
6965 try await executeRequestThrowing (
7066 . get(
0 commit comments