Skip to content

Commit d6374b5

Browse files
committed
ContainerRegistry: Remove return-type overloaded version of getBlob()
1 parent 94b8861 commit d6374b5

File tree

2 files changed

+10
-29
lines changed

2 files changed

+10
-29
lines changed

Sources/ContainerRegistry/Blobs.swift

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -76,28 +76,6 @@ public extension RegistryClient {
7676
.data
7777
}
7878

79-
/// Fetches a blob and tries to decode it as a JSON object.
80-
///
81-
/// - Parameters:
82-
/// - repository: Name of the repository containing the blob.
83-
/// - digest: Digest of the blob.
84-
/// - Returns: The decoded object.
85-
/// - Throws: If the blob download fails or the blob cannot be decoded.
86-
///
87-
/// Some JSON objects, such as ImageConfiguration, are stored
88-
/// in the registry as plain blobs with MIME type "application/octet-stream".
89-
/// This function attempts to decode the received data without reference
90-
/// to the MIME type.
91-
func getBlob<Response: Decodable>(repository: ImageReference.Repository, digest: ImageReference.Digest) async throws
92-
-> Response
93-
{
94-
let (data, _) = try await executeRequestThrowing(
95-
.get(repository, path: "blobs/\(digest)", accepting: ["application/octet-stream"]),
96-
decodingErrors: [.notFound]
97-
)
98-
return try decoder.decode(Response.self, from: data)
99-
}
100-
10179
/// Uploads a blob to the registry.
10280
///
10381
/// This function uploads a blob of unstructured data to the registry.

Sources/ContainerRegistry/RegistryClient+ImageConfiguration.swift

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,12 @@ extension RegistryClient {
2121
/// - Throws: If the blob cannot be decoded as an `ImageConfiguration`.
2222
///
2323
/// Image configuration records are stored as blobs in the registry. This function retrieves the requested blob and tries to decode it as a configuration record.
24-
public func getImageConfiguration(forImage image: ImageReference, digest: ImageReference.Digest) async throws
25-
-> ImageConfiguration
26-
{
27-
try await getBlob(repository: image.repository, digest: digest)
24+
public func getImageConfiguration(
25+
forImage image: ImageReference,
26+
digest: ImageReference.Digest
27+
) async throws -> ImageConfiguration {
28+
let data = try await getBlob(repository: image.repository, digest: digest)
29+
return try decoder.decode(ImageConfiguration.self, from: data)
2830
}
2931

3032
/// Upload an image configuration record to the registry.
@@ -35,9 +37,10 @@ extension RegistryClient {
3537
/// - Throws: If the blob upload fails.
3638
///
3739
/// Image configuration records are stored as blobs in the registry. This function encodes the provided configuration record and stores it as a blob in the registry.
38-
public func putImageConfiguration(forImage image: ImageReference, configuration: ImageConfiguration) async throws
39-
-> ContentDescriptor
40-
{
40+
public func putImageConfiguration(
41+
forImage image: ImageReference,
42+
configuration: ImageConfiguration
43+
) async throws -> ContentDescriptor {
4144
try await putBlob(
4245
repository: image.repository,
4346
mediaType: "application/vnd.oci.image.config.v1+json",

0 commit comments

Comments
 (0)