docker-remote 0.3.0 → 0.4.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/CHANGELOG.md +3 -0
- data/lib/docker/remote/client.rb +40 -12
- data/lib/docker/remote/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6cfe49856e12add82e0b4fa76a42381640b46ab0810a08db03cbd4e6619fa8d5
|
4
|
+
data.tar.gz: d5d7ab9eb55c7d2189ab5127e5b9c03a5e3c2c53a16241e540907cce3158fc72
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 046f4aa7357778f0ded105562fd8ec55e25dc4d012e1c9fcfd01ee4bda47670b26cb83a9fc1bb5f3b4ed625a248af8ea541effceb93e284984c1219baabe634e
|
7
|
+
data.tar.gz: 38cd75b59a2a12e2339fff98a492f97851d28068184dc7b354ef080f70a7e65baf09a5ffe6fc0495d64158e74d58e4826ceec90da75a2ca28535cbbb6d2a8ffd
|
data/CHANGELOG.md
CHANGED
data/lib/docker/remote/client.rb
CHANGED
@@ -21,22 +21,19 @@ module Docker
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def tags
|
24
|
-
|
25
|
-
response = registry_http.request(request)
|
24
|
+
response = get("/v2/#{repo}/tags/list")
|
26
25
|
potentially_raise_error!(response)
|
27
26
|
JSON.parse(response.body)['tags']
|
28
27
|
end
|
29
28
|
|
30
29
|
def manifest_for(reference)
|
31
|
-
|
32
|
-
response = registry_http.request(request)
|
30
|
+
response = get("/v2/#{repo}/manifests/#{reference}")
|
33
31
|
potentially_raise_error!(response)
|
34
32
|
JSON.parse(response.body)
|
35
33
|
end
|
36
34
|
|
37
35
|
def catalog
|
38
|
-
|
39
|
-
response = registry_http.request(request)
|
36
|
+
response = get("/v2/_catalog")
|
40
37
|
potentially_raise_error!(response)
|
41
38
|
JSON.parse(response.body)
|
42
39
|
end
|
@@ -45,8 +42,7 @@ module Docker
|
|
45
42
|
|
46
43
|
def auth
|
47
44
|
@auth ||= begin
|
48
|
-
|
49
|
-
response = registry_http.request(request)
|
45
|
+
response = get('/v2/', use_auth: nil)
|
50
46
|
|
51
47
|
case response.code
|
52
48
|
when '200'
|
@@ -87,15 +83,47 @@ module Docker
|
|
87
83
|
end
|
88
84
|
end
|
89
85
|
|
86
|
+
def get(path, http: registry_http, use_auth: auth, limit: 5)
|
87
|
+
if limit == 0
|
88
|
+
raise DockerRemoteError, 'too many redirects'
|
89
|
+
end
|
90
|
+
|
91
|
+
request = if use_auth
|
92
|
+
use_auth.make_get(path)
|
93
|
+
else
|
94
|
+
Net::HTTP::Get.new(path)
|
95
|
+
end
|
96
|
+
|
97
|
+
response = http.request(request)
|
98
|
+
|
99
|
+
case response
|
100
|
+
when Net::HTTPRedirection
|
101
|
+
redirect_uri = URI.parse(response['location'])
|
102
|
+
redirect_http = make_http(redirect_uri)
|
103
|
+
return get(
|
104
|
+
redirect_uri.path, {
|
105
|
+
http: redirect_http,
|
106
|
+
use_auth: use_auth,
|
107
|
+
limit: limit - 1
|
108
|
+
}
|
109
|
+
)
|
110
|
+
end
|
111
|
+
|
112
|
+
response
|
113
|
+
end
|
114
|
+
|
90
115
|
def registry_uri
|
91
116
|
@registry_uri ||= URI.parse(registry_url)
|
92
117
|
end
|
93
118
|
|
119
|
+
def make_http(uri)
|
120
|
+
Net::HTTP.new(uri.host, uri.port).tap do |http|
|
121
|
+
http.use_ssl = true if uri.scheme == 'https'
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
94
125
|
def registry_http
|
95
|
-
@registry_http ||=
|
96
|
-
Net::HTTP.new(registry_uri.host, registry_uri.port).tap do |http|
|
97
|
-
http.use_ssl = true if registry_uri.scheme == 'https'
|
98
|
-
end
|
126
|
+
@registry_http ||= make_http(registry_uri)
|
99
127
|
end
|
100
128
|
end
|
101
129
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: docker-remote
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cameron Dutro
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-11-02 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A Ruby client for communicating with the Docker registry API v2.
|
14
14
|
email:
|