@@ -28,9 +28,7 @@ public func digest<D: DataProtocol>(of data: D) -> String {
2828
2929extension RegistryClient {
3030 // Internal helper method to initiate a blob upload in 'two shot' mode
31- func startBlobUploadSession( repository: String ) async throws -> URL {
32- precondition ( repository. count > 0 , " repository must not be an empty string " )
33-
31+ func startBlobUploadSession( repository: Repository ) async throws -> URL {
3432 // Upload in "two shot" mode.
3533 // See https://github.com/opencontainers/distribution-spec/blob/main/spec.md#post-then-put
3634 // - POST to obtain a session ID.
@@ -67,8 +65,7 @@ extension RegistryClient {
6765extension HTTPField . Name { static let dockerContentDigest = Self ( " Docker-Content-Digest " ) ! }
6866
6967public extension RegistryClient {
70- func blobExists( repository: String , digest: String ) async throws -> Bool {
71- precondition ( repository. count > 0 , " repository must not be an empty string " )
68+ func blobExists( repository: Repository , digest: String ) async throws -> Bool {
7269 precondition ( digest. count > 0 )
7370
7471 do {
@@ -87,8 +84,7 @@ public extension RegistryClient {
8784 /// - digest: Digest of the blob.
8885 /// - Returns: The downloaded data.
8986 /// - Throws: If the blob download fails.
90- func getBlob( repository: String , digest: String ) async throws -> Data {
91- precondition ( repository. count > 0 , " repository must not be an empty string " )
87+ func getBlob( repository: Repository , digest: String ) async throws -> Data {
9288 precondition ( digest. count > 0 , " digest must not be an empty string " )
9389
9490 return try await executeRequestThrowing (
@@ -110,8 +106,7 @@ public extension RegistryClient {
110106 /// in the registry as plain blobs with MIME type "application/octet-stream".
111107 /// This function attempts to decode the received data without reference
112108 /// to the MIME type.
113- func getBlob< Response: Decodable > ( repository: String , digest: String ) async throws -> Response {
114- precondition ( repository. count > 0 , " repository must not be an empty string " )
109+ func getBlob< Response: Decodable > ( repository: Repository , digest: String ) async throws -> Response {
115110 precondition ( digest. count > 0 , " digest must not be an empty string " )
116111
117112 return try await executeRequestThrowing (
@@ -132,11 +127,9 @@ public extension RegistryClient {
132127 /// - Returns: An ContentDescriptor object representing the
133128 /// uploaded blob.
134129 /// - Throws: If the blob cannot be encoded or the upload fails.
135- func putBlob( repository: String , mediaType: String = " application/octet-stream " , data: Data ) async throws
130+ func putBlob( repository: Repository , mediaType: String = " application/octet-stream " , data: Data ) async throws
136131 -> ContentDescriptor
137132 {
138- precondition ( repository. count > 0 , " repository must not be an empty string " )
139-
140133 // Ask the server to open a session and tell us where to upload our data
141134 let location = try await startBlobUploadSession ( repository: repository)
142135
@@ -179,7 +172,7 @@ public extension RegistryClient {
179172 /// Some JSON objects, such as ImageConfiguration, are stored
180173 /// in the registry as plain blobs with MIME type "application/octet-stream".
181174 /// This function encodes the data parameter and uploads it as a generic blob.
182- func putBlob< Body: Encodable > ( repository: String , mediaType: String = " application/octet-stream " , data: Body )
175+ func putBlob< Body: Encodable > ( repository: Repository , mediaType: String = " application/octet-stream " , data: Body )
183176 async throws -> ContentDescriptor
184177 {
185178 let encoded = try encoder. encode ( data)
0 commit comments