From d5be4ee87511d8b0f9baac5a3053f84ec58a4ea2 Mon Sep 17 00:00:00 2001 From: Euan Harris Date: Mon, 14 Oct 2024 13:34:56 +0100 Subject: [PATCH] ContainerRegistry: Pass through the manifest's mediaType, if set --- Sources/ContainerRegistry/Manifests.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Sources/ContainerRegistry/Manifests.swift b/Sources/ContainerRegistry/Manifests.swift index fc73a8f..0deb65f 100644 --- a/Sources/ContainerRegistry/Manifests.swift +++ b/Sources/ContainerRegistry/Manifests.swift @@ -14,6 +14,7 @@ public extension RegistryClient { func putManifest(repository: String, reference: String, manifest: ImageManifest) async throws -> String { + // See https://github.com/opencontainers/distribution-spec/blob/main/spec.md#pushing-manifests precondition(repository.count > 0, "repository must not be an empty string") precondition(reference.count > 0, "reference must not be an empty string") @@ -21,7 +22,7 @@ public extension RegistryClient { // All blob uploads have Content-Type: application/octet-stream on the wire, even if mediatype is different .put( registryURLForPath("/v2/\(repository)/manifests/\(reference)"), - contentType: "application/vnd.oci.image.manifest.v1+json" + contentType: manifest.mediaType ?? "application/vnd.oci.image.manifest.v1+json" ), uploading: manifest, expectingStatus: .created, @@ -35,6 +36,7 @@ public extension RegistryClient { } func getManifest(repository: String, reference: String) async throws -> ImageManifest { + // See https://github.com/opencontainers/distribution-spec/blob/main/spec.md#pulling-manifests precondition(repository.count > 0, "repository must not be an empty string") precondition(reference.count > 0, "reference must not be an empty string")