docker_registry2 1.9.0 → 1.10.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b4b040151a73ef44e9ac9b07bb2998283fb86e1ed33d41cc523b6229e1372121
4
- data.tar.gz: 0b27fcb25ccbe51eb4ee88655ba076d93daa8ed26de37ff0ef32185edceb9b54
3
+ metadata.gz: 6878db7e5b30918ddcb5417f6092ae01a35ca6037c9d0203217450198fe831d0
4
+ data.tar.gz: 207bc12bacd847a6573b322cdee58c3fe33bb85db1c831458cca7e942f8232bd
5
5
  SHA512:
6
- metadata.gz: 0f04c98177280e070b1d2fdc0b9577027a8802db7aa91eac54d62b5adf0043b242d6e3d896a83f8805717c5c551e16585d0c64183247149c62196e7d3092d1b6
7
- data.tar.gz: a4101e6d617104332dbf23a0a2edd4b61dbad4b7f7844317fddbad81461a07671c405195380db95173823217e37b0c7aa839b2fa74b621cf26387a3366e06357
6
+ metadata.gz: fe5ef7fec4e79b5290bafce6837738410e41c0dd50bdeab49ce373bc256338ca0c6300d28417e13cf686d813e71b1ff44315afb80196f19dd84f7b4b870e7008
7
+ data.tar.gz: aad38ab842512d57ed2816f3823d2fb77ab8cbf56ef48c29df476d630881dadaf8de0c71fd543a5c0d5ddf4625baadc38f4a2b860f39d712650d2ba574153d81
data/README.md CHANGED
@@ -55,6 +55,13 @@ opts = { open_timeout: 2, read_timeout: 5 }
55
55
  reg = DockerRegistry2.connect("https://my.registy.corp.com", opts)
56
56
  ```
57
57
 
58
+ Your may pass extra options for RestClient::Request.execute through `http_options` :
59
+
60
+ ```ruby
61
+ opts = { http_options: { proxy: 'http://proxy.example.com:8080/' } }
62
+ reg = DockerRegistry2.connect("https://my.registy.corp.com", opts)
63
+ ```
64
+
58
65
  You can connect anonymously or with credentials:
59
66
 
60
67
  #### Anonymous
@@ -7,15 +7,19 @@ class DockerRegistry2::Registry
7
7
  # @param [Hash] options Client options
8
8
  # @option options [#to_s] :user User name for basic authentication
9
9
  # @option options [#to_s] :password Password for basic authentication
10
- # @option options [#to_s] :open_timeout Time to wait for a connection with a registry
11
- # @option options [#to_s] :read_timeout Time to wait for data from a registry
10
+ # @option options [#to_s] :open_timeout Time to wait for a connection with a registry.
11
+ # It is ignored if http_options[:open_timeout] is also specified.
12
+ # @option options [#to_s] :read_timeout Time to wait for data from a registry.
13
+ # It is ignored if http_options[:read_timeout] is also specified.
14
+ # @option options [Hash] :http_options Extra options for RestClient::Request.execute.
12
15
  def initialize(uri, options = {})
13
16
  @uri = URI.parse(uri)
14
17
  @base_uri = "#{@uri.scheme}://#{@uri.host}:#{@uri.port}"
15
18
  @user = options[:user]
16
19
  @password = options[:password]
17
- @open_timeout = options[:open_timeout] || 2
18
- @read_timeout = options[:read_timeout] || 5
20
+ @http_options = options[:http_options] || {}
21
+ @http_options[:open_timeout] ||= options[:open_timeout] || 2
22
+ @http_options[:read_timeout] ||= options[:read_timeout] || 5
19
23
  end
20
24
 
21
25
  def doget(url)
@@ -35,7 +39,7 @@ class DockerRegistry2::Registry
35
39
  end
36
40
 
37
41
  def ping
38
- response = doget '/v2/'
42
+ doget '/v2/'
39
43
  end
40
44
 
41
45
  def search(query = '')
@@ -244,15 +248,13 @@ class DockerRegistry2::Registry
244
248
  stream.write chunk
245
249
  end
246
250
  }
247
- response = RestClient::Request.execute(
251
+ response = RestClient::Request.execute(@http_options.merge(
248
252
  method: type,
249
253
  url: @base_uri+url,
250
254
  headers: headers(payload: payload),
251
255
  block_response: block,
252
- open_timeout: @open_timeout,
253
- read_timeout: @read_timeout,
254
256
  payload: payload
255
- )
257
+ ))
256
258
  rescue SocketError
257
259
  raise DockerRegistry2::RegistryUnknownException
258
260
  rescue RestClient::NotFound => error
@@ -279,17 +281,15 @@ class DockerRegistry2::Registry
279
281
  stream.write chunk
280
282
  end
281
283
  }
282
- response = RestClient::Request.execute(
284
+ response = RestClient::Request.execute(@http_options.merge(
283
285
  method: type,
284
286
  url: @base_uri+url,
285
287
  user: @user,
286
288
  password: @password,
287
289
  headers: headers(payload: payload),
288
290
  block_response: block,
289
- open_timeout: @open_timeout,
290
- read_timeout: @read_timeout,
291
291
  payload: payload
292
- )
292
+ ))
293
293
  rescue SocketError
294
294
  raise DockerRegistry2::RegistryUnknownException
295
295
  rescue RestClient::Unauthorized
@@ -310,15 +310,13 @@ class DockerRegistry2::Registry
310
310
  stream.write chunk
311
311
  end
312
312
  }
313
- response = RestClient::Request.execute(
313
+ response = RestClient::Request.execute(@http_options.merge(
314
314
  method: type,
315
315
  url: @base_uri+url,
316
316
  headers: headers(payload: payload, bearer_token: token),
317
317
  block_response: block,
318
- open_timeout: @open_timeout,
319
- read_timeout: @read_timeout,
320
318
  payload: payload
321
- )
319
+ ))
322
320
  rescue SocketError
323
321
  raise DockerRegistry2::RegistryUnknownException
324
322
  rescue RestClient::Unauthorized
@@ -342,14 +340,12 @@ class DockerRegistry2::Registry
342
340
  # authenticate against the realm
343
341
  uri = URI.parse(target[:realm])
344
342
  begin
345
- response = RestClient::Request.execute(
343
+ response = RestClient::Request.execute(@http_options.merge(
346
344
  method: :get,
347
345
  url: uri.to_s, headers: {params: target[:params]},
348
346
  user: @user,
349
347
  password: @password,
350
- open_timeout: @open_timeout,
351
- read_timeout: @read_timeout
352
- )
348
+ ))
353
349
  rescue RestClient::Unauthorized, RestClient::Forbidden
354
350
  # bad authentication
355
351
  raise DockerRegistry2::RegistryAuthenticationException
@@ -1,3 +1,3 @@
1
1
  module DockerRegistry2
2
- VERSION = '1.9.0'
2
+ VERSION = '1.10.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: docker_registry2
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.0
4
+ version: 1.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Avi Deitcher https://github.com/deitch
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2019-12-01 00:00:00.000000000 Z
14
+ date: 2020-11-29 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: bundler
@@ -102,7 +102,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0'
104
104
  requirements: []
105
- rubygems_version: 3.0.3
105
+ rubygems_version: 3.1.4
106
106
  signing_key:
107
107
  specification_version: 4
108
108
  summary: Docker v2 registry HTTP API client