Skip to content

Commit

Permalink
ContainerRegistry: Pass through the manifest's mediaType, if set
Browse files Browse the repository at this point in the history
  • Loading branch information
euanh committed Oct 14, 2024
1 parent 692cb27 commit 062465a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Sources/ContainerRegistry/Manifests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@

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")

let httpResponse = try await executeRequestThrowing(
// 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,
Expand All @@ -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")

Expand Down

0 comments on commit 062465a

Please sign in to comment.