docker_registry2 1.9.0 → 1.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +7 -0
- data/lib/registry/registry.rb +17 -21
- data/lib/registry/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6878db7e5b30918ddcb5417f6092ae01a35ca6037c9d0203217450198fe831d0
|
4
|
+
data.tar.gz: 207bc12bacd847a6573b322cdee58c3fe33bb85db1c831458cca7e942f8232bd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
data/lib/registry/registry.rb
CHANGED
@@ -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
|
-
#
|
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
|
-
@
|
18
|
-
@
|
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
|
-
|
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
|
-
|
351
|
-
read_timeout: @read_timeout
|
352
|
-
)
|
348
|
+
))
|
353
349
|
rescue RestClient::Unauthorized, RestClient::Forbidden
|
354
350
|
# bad authentication
|
355
351
|
raise DockerRegistry2::RegistryAuthenticationException
|
data/lib/registry/version.rb
CHANGED
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.
|
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:
|
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.
|
105
|
+
rubygems_version: 3.1.4
|
106
106
|
signing_key:
|
107
107
|
specification_version: 4
|
108
108
|
summary: Docker v2 registry HTTP API client
|