docker_registry2 1.17.0 → 1.18.1

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: 6f7daed06a8c800b4df3412aee52d8204af23092206f073b7688f01ec6ef1011
4
- data.tar.gz: a7ddaecc362241ea127ea67146ec75dd94eec6affcef9fa9f527b73048dd08f7
3
+ metadata.gz: 3210236b320a090f2886dca3102073b9c128ffd9ce6ec39e7623f2299a77c428
4
+ data.tar.gz: 67fb86e3c93a888f3e9f8a7fa327379bc97a56afe284cb8c64a71bc73618ecfb
5
5
  SHA512:
6
- metadata.gz: 7449e24efd8d8a56dfacb59b3945c3f083b75f91505bd67f4fefb60b3cc3078df2c3289f86fdd14cf2b9f34ba52b34363e6fccb7088e9813adc80341c525a915
7
- data.tar.gz: a7ad67b22dce29604879d7de2d8955e7698dd5292c972a9ae06cf2e78f5aa1396c12a105cd05153dc905f5b7ecf4b30555c0d67a7e2ee8d13d1005aa4534a438
6
+ metadata.gz: 1917a3edf585627022223123e7eefe254aa84d9ad91243ea029bd81cbf3272364c5a881f1b20df95203336085dda67dc5ade26e29c5bf0da3b08c9b5cf520a56
7
+ data.tar.gz: 76e2f9676f2ff888a2a42d2f02814f7ef521b1ab0bc1b92a32dfae7fe94699aa548359ada17ea898ddce27b67ba38d3cc888c6f2cea76fe6cea83c0baad2b55c
@@ -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', '>= 0.26.0'
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
@@ -22,4 +22,8 @@ module DockerRegistry2
22
22
  def self.manifest(repository, tag)
23
23
  @reg.manifest(repository, tag)
24
24
  end
25
+
26
+ def self.manifest_digest(repository, tag)
27
+ @reg.manifest_digest(repository, tag)
28
+ end
25
29
  end
@@ -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
- break unless link_header
54
+ link_header = response.headers[:link] or break
55
+ next_url = parse_link_header(link_header)[:next] or break
54
56
 
55
- url = parse_link_header(link_header)[:next]
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('/v2/_catalog') do |response|
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 "/v2/#{repo}/tags/list#{query_vars}"
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 "/v2/#{repo}/manifests/#{tag}"
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 = "/v2/#{repo}/blobs/#{digest}"
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)
@@ -126,6 +130,14 @@ module DockerRegistry2
126
130
  end
127
131
  end
128
132
 
133
+ def manifest_digest(repo, tag)
134
+ tag_path = "v2/#{repo}/manifests/#{tag}"
135
+ dohead(tag_path).headers[:docker_content_digest]
136
+ rescue DockerRegistry2::InvalidMethod
137
+ # Pre-2.3.0 registries didn't support manifest HEAD requests
138
+ doget(tag_path).headers[:docker_content_digest]
139
+ end
140
+
129
141
  def digest(image, tag, architecture = nil, os = nil, variant = nil)
130
142
  manifest = manifest(image, tag)
131
143
  parsed_manifest = JSON.parse(manifest.body)
@@ -153,9 +165,9 @@ module DockerRegistry2
153
165
 
154
166
  def rmtag(image, tag)
155
167
  # TODO: Need full response back. Rewrite other manifests() calls without JSON?
156
- reference = doget("/v2/#{image}/manifests/#{tag}").headers[:docker_content_digest]
168
+ reference = doget("v2/#{image}/manifests/#{tag}").headers[:docker_content_digest]
157
169
 
158
- dodelete("/v2/#{image}/manifests/#{reference}").code
170
+ dodelete("v2/#{image}/manifests/#{reference}").code
159
171
  end
160
172
 
161
173
  def pull(repo, tag, dir)
@@ -187,7 +199,6 @@ module DockerRegistry2
187
199
  # download layer
188
200
  # puts "getting layer (v2) #{layer['digest']}"
189
201
  blob(repo, layer['digest'], layer_file)
190
- layer_file
191
202
  end
192
203
  end
193
204
 
@@ -207,7 +218,6 @@ module DockerRegistry2
207
218
  # puts "getting layer (v1) #{layer['blobSum']}"
208
219
  blob(repo, layer['blobSum'], layer_file)
209
220
  # return layer file
210
- layer_file
211
221
  end
212
222
  end
213
223
 
@@ -218,7 +228,7 @@ module DockerRegistry2
218
228
 
219
229
  raise DockerRegistry2::RegistryVersionException unless manifest['schemaVersion'] == 2
220
230
 
221
- doput "/v2/#{newrepo}/manifests/#{newtag}", manifest.to_json
231
+ doput "v2/#{newrepo}/manifests/#{newtag}", manifest.to_json
222
232
  end
223
233
 
224
234
  def copy(repo, tag, newregistry, newrepo, newtag); end
@@ -226,14 +236,13 @@ module DockerRegistry2
226
236
  # gets the size of a particular blob, given the repo and the content-addressable hash
227
237
  # usually unneeded, since manifest includes it
228
238
  def blob_size(repo, blobSum)
229
- response = dohead "/v2/#{repo}/blobs/#{blobSum}"
239
+ response = dohead "v2/#{repo}/blobs/#{blobSum}"
230
240
  Integer(response.headers[:content_length], 10)
231
241
  end
232
242
 
233
243
  # Parse the value of the Link HTTP header and return a Hash whose keys are the rel values turned into symbols, and
234
244
  # the values are URLs. For example, `{ next: '/v2/_catalog?n=100&last=x' }`.
235
245
  def parse_link_header(header)
236
- last = ''
237
246
  parts = header.split(',')
238
247
  links = {}
239
248
 
@@ -282,7 +291,7 @@ module DockerRegistry2
282
291
  end
283
292
  response = RestClient::Request.execute(@http_options.merge(
284
293
  method: type,
285
- url: @base_uri + url,
294
+ url: URI.join(@base_uri, url).to_s,
286
295
  headers: headers(payload: payload),
287
296
  block_response: block,
288
297
  payload: payload
@@ -293,7 +302,7 @@ module DockerRegistry2
293
302
  raise DockerRegistry2::NotFound, "Image not found at #{@uri.host}"
294
303
  rescue RestClient::Unauthorized => e
295
304
  header = e.response.headers[:www_authenticate]
296
- method = header.to_s.downcase.split(' ')[0]
305
+ method = header.to_s.downcase.split[0]
297
306
  case method
298
307
  when 'basic'
299
308
  response = do_basic_req(type, url, stream, payload)
@@ -319,7 +328,7 @@ module DockerRegistry2
319
328
  end
320
329
  response = RestClient::Request.execute(@http_options.merge(
321
330
  method: type,
322
- url: @base_uri + url,
331
+ url: URI.join(@base_uri, url).to_s,
323
332
  user: @user,
324
333
  password: @password,
325
334
  headers: headers(payload: payload),
@@ -352,7 +361,7 @@ module DockerRegistry2
352
361
  end
353
362
  response = RestClient::Request.execute(@http_options.merge(
354
363
  method: type,
355
- url: @base_uri + url,
364
+ url: URI.join(@base_uri, url).to_s,
356
365
  headers: headers(payload: payload, bearer_token: token),
357
366
  block_response: block,
358
367
  payload: payload
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DockerRegistry2
4
- VERSION = '1.17.0'
4
+ VERSION = '1.18.1'
5
5
  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.17.0
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: 2023-07-18 00:00:00.000000000 Z
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: 0.26.0
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: 0.26.0
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.3.26
148
+ rubygems_version: 3.5.9
148
149
  signing_key:
149
150
  specification_version: 4
150
151
  summary: Docker v2 registry HTTP API client