@@ -66,37 +66,21 @@ public struct RegistryClient {
66
66
/// - registry: HTTP URL of the registry's API endpoint.
67
67
/// - client: HTTPClient object to use to connect to the registry.
68
68
/// - auth: An authentication handler which can provide authentication credentials.
69
- /// - encoder: JSONEncoder to use when encoding messages to the registry.
70
- /// - decoder: JSONDecoder to use when decoding messages from the registry.
71
69
/// - Throws: If the registry name is invalid.
72
70
/// - Throws: If a connection to the registry cannot be established.
73
71
public init (
74
72
registry: URL ,
75
73
client: HTTPClient ,
76
- auth: AuthHandler ? = nil ,
77
- encodingWith encoder: JSONEncoder ? = nil ,
78
- decodingWith decoder: JSONDecoder ? = nil
74
+ auth: AuthHandler ? = nil
79
75
) async throws {
80
76
registryURL = registry
81
77
self . client = client
82
78
self . auth = auth
83
79
84
80
// The registry server does not normalize JSON and calculates digests over the raw message text.
85
81
// We must use consistent encoder settings when encoding and calculating digests.
86
- //
87
- // We must also configure the date encoding strategy otherwise the dates are printed as
88
- // fractional numbers of seconds, whereas the container image requires ISO8601.
89
- if let encoder {
90
- self . encoder = encoder
91
- } else {
92
- self . encoder = JSONEncoder ( )
93
- self . encoder. outputFormatting = [ . sortedKeys, . prettyPrinted, . withoutEscapingSlashes]
94
- self . encoder. dateEncodingStrategy = . iso8601
95
- }
96
-
97
- // No special configuration is required for the decoder, but we should use a single instance
98
- // rather than creating new instances where we need them.
99
- self . decoder = decoder ?? JSONDecoder ( )
82
+ self . encoder = containerJSONEncoder ( )
83
+ self . decoder = JSONDecoder ( )
100
84
101
85
// Verify that we can talk to the registry
102
86
self . authChallenge = try await RegistryClient . checkAPI ( client: self . client, registryURL: self . registryURL)
0 commit comments