docker_registry2 1.18.0 → 1.18.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/docker_registry2.gemspec +2 -2
- data/lib/registry/registry.rb +21 -20
- data/lib/registry/version.rb +1 -1
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3210236b320a090f2886dca3102073b9c128ffd9ce6ec39e7623f2299a77c428
|
4
|
+
data.tar.gz: 67fb86e3c93a888f3e9f8a7fa327379bc97a56afe284cb8c64a71bc73618ecfb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1917a3edf585627022223123e7eefe254aa84d9ad91243ea029bd81cbf3272364c5a881f1b20df95203336085dda67dc5ade26e29c5bf0da3b08c9b5cf520a56
|
7
|
+
data.tar.gz: 76e2f9676f2ff888a2a42d2f02814f7ef521b1ab0bc1b92a32dfae7fe94699aa548359ada17ea898ddce27b67ba38d3cc888c6f2cea76fe6cea83c0baad2b55c
|
data/docker_registry2.gemspec
CHANGED
@@ -22,15 +22,15 @@ Gem::Specification.new do |spec|
|
|
22
22
|
File.directory?(f)
|
23
23
|
end
|
24
24
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
25
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
26
25
|
spec.require_paths = ['lib']
|
27
26
|
|
28
27
|
spec.add_development_dependency 'bundler'
|
29
28
|
spec.add_development_dependency 'rake', '~> 10.0'
|
30
29
|
spec.add_development_dependency 'rspec', '~> 3'
|
31
|
-
spec.add_development_dependency 'rubocop', '>=
|
30
|
+
spec.add_development_dependency 'rubocop', '>= 1.63.0'
|
32
31
|
spec.add_development_dependency 'vcr', '~> 6'
|
33
32
|
spec.add_development_dependency 'webmock'
|
34
33
|
|
35
34
|
spec.add_dependency 'rest-client', '>= 1.8.0'
|
35
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
36
36
|
end
|
data/lib/registry/registry.rb
CHANGED
@@ -17,7 +17,9 @@ module DockerRegistry2
|
|
17
17
|
# @option options [Hash] :http_options Extra options for RestClient::Request.execute.
|
18
18
|
def initialize(uri, options = {})
|
19
19
|
@uri = URI.parse(uri)
|
20
|
-
@base_uri = "#{@uri.scheme}://#{@uri.host}:#{@uri.port}#{@uri.path}"
|
20
|
+
@base_uri = +"#{@uri.scheme}://#{@uri.host}:#{@uri.port}#{@uri.path}"
|
21
|
+
# `URI.join("https://example.com/foo/bar", "v2")` drops `bar` in the base URL. A trailing slash prevents that.
|
22
|
+
@base_uri << '/' unless @base_uri.end_with? '/'
|
21
23
|
@user = options[:user]
|
22
24
|
@password = options[:password]
|
23
25
|
@http_options = options[:http_options] || {}
|
@@ -49,16 +51,18 @@ module DockerRegistry2
|
|
49
51
|
response = doget(url)
|
50
52
|
yield response
|
51
53
|
|
52
|
-
link_header = response.headers[:link]
|
53
|
-
|
54
|
+
link_header = response.headers[:link] or break
|
55
|
+
next_url = parse_link_header(link_header)[:next] or break
|
54
56
|
|
55
|
-
|
57
|
+
# The next URL in the Link header may be relative to the request URL, or absolute.
|
58
|
+
# URI.join handles both cases nicely.
|
59
|
+
url = URI.join(response.request.url, next_url)
|
56
60
|
end
|
57
61
|
end
|
58
62
|
|
59
63
|
def search(query = '')
|
60
64
|
all_repos = []
|
61
|
-
paginate_doget('
|
65
|
+
paginate_doget('v2/_catalog') do |response|
|
62
66
|
repos = JSON.parse(response)['repositories']
|
63
67
|
repos.select! { |repo| repo.match?(/#{query}/) } unless query.empty?
|
64
68
|
all_repos += repos
|
@@ -75,7 +79,7 @@ module DockerRegistry2
|
|
75
79
|
query_vars = ''
|
76
80
|
query_vars = "?#{URI.encode_www_form(params)}" if params.length.positive?
|
77
81
|
|
78
|
-
response = doget "
|
82
|
+
response = doget "v2/#{repo}/tags/list#{query_vars}"
|
79
83
|
# parse the response
|
80
84
|
resp = JSON.parse response
|
81
85
|
# parse out next page link if necessary
|
@@ -104,7 +108,7 @@ module DockerRegistry2
|
|
104
108
|
|
105
109
|
def manifest(repo, tag)
|
106
110
|
# first get the manifest
|
107
|
-
response = doget "
|
111
|
+
response = doget "v2/#{repo}/manifests/#{tag}"
|
108
112
|
parsed = JSON.parse response.body
|
109
113
|
manifest = DockerRegistry2::Manifest[parsed]
|
110
114
|
manifest.body = response.body
|
@@ -113,7 +117,7 @@ module DockerRegistry2
|
|
113
117
|
end
|
114
118
|
|
115
119
|
def blob(repo, digest, outpath = nil)
|
116
|
-
blob_url = "
|
120
|
+
blob_url = "v2/#{repo}/blobs/#{digest}"
|
117
121
|
if outpath.nil?
|
118
122
|
response = doget(blob_url)
|
119
123
|
DockerRegistry2::Blob.new(response.headers, response.body)
|
@@ -127,7 +131,7 @@ module DockerRegistry2
|
|
127
131
|
end
|
128
132
|
|
129
133
|
def manifest_digest(repo, tag)
|
130
|
-
tag_path = "
|
134
|
+
tag_path = "v2/#{repo}/manifests/#{tag}"
|
131
135
|
dohead(tag_path).headers[:docker_content_digest]
|
132
136
|
rescue DockerRegistry2::InvalidMethod
|
133
137
|
# Pre-2.3.0 registries didn't support manifest HEAD requests
|
@@ -161,9 +165,9 @@ module DockerRegistry2
|
|
161
165
|
|
162
166
|
def rmtag(image, tag)
|
163
167
|
# TODO: Need full response back. Rewrite other manifests() calls without JSON?
|
164
|
-
reference = doget("
|
168
|
+
reference = doget("v2/#{image}/manifests/#{tag}").headers[:docker_content_digest]
|
165
169
|
|
166
|
-
dodelete("
|
170
|
+
dodelete("v2/#{image}/manifests/#{reference}").code
|
167
171
|
end
|
168
172
|
|
169
173
|
def pull(repo, tag, dir)
|
@@ -195,7 +199,6 @@ module DockerRegistry2
|
|
195
199
|
# download layer
|
196
200
|
# puts "getting layer (v2) #{layer['digest']}"
|
197
201
|
blob(repo, layer['digest'], layer_file)
|
198
|
-
layer_file
|
199
202
|
end
|
200
203
|
end
|
201
204
|
|
@@ -215,7 +218,6 @@ module DockerRegistry2
|
|
215
218
|
# puts "getting layer (v1) #{layer['blobSum']}"
|
216
219
|
blob(repo, layer['blobSum'], layer_file)
|
217
220
|
# return layer file
|
218
|
-
layer_file
|
219
221
|
end
|
220
222
|
end
|
221
223
|
|
@@ -226,7 +228,7 @@ module DockerRegistry2
|
|
226
228
|
|
227
229
|
raise DockerRegistry2::RegistryVersionException unless manifest['schemaVersion'] == 2
|
228
230
|
|
229
|
-
doput "
|
231
|
+
doput "v2/#{newrepo}/manifests/#{newtag}", manifest.to_json
|
230
232
|
end
|
231
233
|
|
232
234
|
def copy(repo, tag, newregistry, newrepo, newtag); end
|
@@ -234,14 +236,13 @@ module DockerRegistry2
|
|
234
236
|
# gets the size of a particular blob, given the repo and the content-addressable hash
|
235
237
|
# usually unneeded, since manifest includes it
|
236
238
|
def blob_size(repo, blobSum)
|
237
|
-
response = dohead "
|
239
|
+
response = dohead "v2/#{repo}/blobs/#{blobSum}"
|
238
240
|
Integer(response.headers[:content_length], 10)
|
239
241
|
end
|
240
242
|
|
241
243
|
# Parse the value of the Link HTTP header and return a Hash whose keys are the rel values turned into symbols, and
|
242
244
|
# the values are URLs. For example, `{ next: '/v2/_catalog?n=100&last=x' }`.
|
243
245
|
def parse_link_header(header)
|
244
|
-
last = ''
|
245
246
|
parts = header.split(',')
|
246
247
|
links = {}
|
247
248
|
|
@@ -290,7 +291,7 @@ module DockerRegistry2
|
|
290
291
|
end
|
291
292
|
response = RestClient::Request.execute(@http_options.merge(
|
292
293
|
method: type,
|
293
|
-
url: @base_uri
|
294
|
+
url: URI.join(@base_uri, url).to_s,
|
294
295
|
headers: headers(payload: payload),
|
295
296
|
block_response: block,
|
296
297
|
payload: payload
|
@@ -301,7 +302,7 @@ module DockerRegistry2
|
|
301
302
|
raise DockerRegistry2::NotFound, "Image not found at #{@uri.host}"
|
302
303
|
rescue RestClient::Unauthorized => e
|
303
304
|
header = e.response.headers[:www_authenticate]
|
304
|
-
method = header.to_s.downcase.split
|
305
|
+
method = header.to_s.downcase.split[0]
|
305
306
|
case method
|
306
307
|
when 'basic'
|
307
308
|
response = do_basic_req(type, url, stream, payload)
|
@@ -327,7 +328,7 @@ module DockerRegistry2
|
|
327
328
|
end
|
328
329
|
response = RestClient::Request.execute(@http_options.merge(
|
329
330
|
method: type,
|
330
|
-
url: @base_uri
|
331
|
+
url: URI.join(@base_uri, url).to_s,
|
331
332
|
user: @user,
|
332
333
|
password: @password,
|
333
334
|
headers: headers(payload: payload),
|
@@ -360,7 +361,7 @@ module DockerRegistry2
|
|
360
361
|
end
|
361
362
|
response = RestClient::Request.execute(@http_options.merge(
|
362
363
|
method: type,
|
363
|
-
url: @base_uri
|
364
|
+
url: URI.join(@base_uri, url).to_s,
|
364
365
|
headers: headers(payload: payload, bearer_token: token),
|
365
366
|
block_response: block,
|
366
367
|
payload: payload
|
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.18.
|
4
|
+
version: 1.18.1
|
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: 2024-05-13 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: bundler
|
@@ -61,14 +61,14 @@ dependencies:
|
|
61
61
|
requirements:
|
62
62
|
- - ">="
|
63
63
|
- !ruby/object:Gem::Version
|
64
|
-
version:
|
64
|
+
version: 1.63.0
|
65
65
|
type: :development
|
66
66
|
prerelease: false
|
67
67
|
version_requirements: !ruby/object:Gem::Requirement
|
68
68
|
requirements:
|
69
69
|
- - ">="
|
70
70
|
- !ruby/object:Gem::Version
|
71
|
-
version:
|
71
|
+
version: 1.63.0
|
72
72
|
- !ruby/object:Gem::Dependency
|
73
73
|
name: vcr
|
74
74
|
requirement: !ruby/object:Gem::Requirement
|
@@ -128,7 +128,8 @@ files:
|
|
128
128
|
homepage: https://github.com/deitch/docker_registry2
|
129
129
|
licenses:
|
130
130
|
- MIT
|
131
|
-
metadata:
|
131
|
+
metadata:
|
132
|
+
rubygems_mfa_required: 'true'
|
132
133
|
post_install_message:
|
133
134
|
rdoc_options: []
|
134
135
|
require_paths:
|
@@ -144,7 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
144
145
|
- !ruby/object:Gem::Version
|
145
146
|
version: '0'
|
146
147
|
requirements: []
|
147
|
-
rubygems_version: 3.
|
148
|
+
rubygems_version: 3.5.9
|
148
149
|
signing_key:
|
149
150
|
specification_version: 4
|
150
151
|
summary: Docker v2 registry HTTP API client
|