@@ -66,37 +66,21 @@ public struct RegistryClient {
6666 /// - registry: HTTP URL of the registry's API endpoint.
6767 /// - client: HTTPClient object to use to connect to the registry.
6868 /// - 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.
7169 /// - Throws: If the registry name is invalid.
7270 /// - Throws: If a connection to the registry cannot be established.
7371 public init (
7472 registry: URL ,
7573 client: HTTPClient ,
76- auth: AuthHandler ? = nil ,
77- encodingWith encoder: JSONEncoder ? = nil ,
78- decodingWith decoder: JSONDecoder ? = nil
74+ auth: AuthHandler ? = nil
7975 ) async throws {
8076 registryURL = registry
8177 self . client = client
8278 self . auth = auth
8379
8480 // The registry server does not normalize JSON and calculates digests over the raw message text.
8581 // 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 ( )
10084
10185 // Verify that we can talk to the registry
10286 self . authChallenge = try await RegistryClient . checkAPI ( client: self . client, registryURL: self . registryURL)
0 commit comments