docker_registry2 1.18.0 → 1.18.2

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: 396635930a86cd9f517fe62ec5d697162800ceed5da3209b56c9951529c48acd
4
- data.tar.gz: aa924fcb85dedc352020b686ecae75d2b755ee1d4d87ab4cc7f27991a0a3e84b
3
+ metadata.gz: 6087558b34bf6fb8953c216c820b1823c53efab8696a9ce36e05d995089f2287
4
+ data.tar.gz: 0a88cad1f6e1e47198c626bbf9ee78c5d4201ebf8d50a10dbde2b77fb46a6949
5
5
  SHA512:
6
- metadata.gz: 2dfbaa1a8e21b917363855a5f31c57dbd08517d0f58fc1faf43520d6e321074d4b6083246ee3863a4e6a886d5f5dc9ba239eeef7deda747536db69a77f08a480
7
- data.tar.gz: 6b034ef24e2f306d8a4a5047e03a101307c55698e0ce3295eefc15481abbc64034b07bc61b5c0651aad41bd03f2a6920f0cf98b81c733c845353d1e784db8aad
6
+ metadata.gz: e80d966c2720e940312674dfd30cf24ec2be1266a3ef86141cefec1be158221ae898ac7e97839ffb6a3e218838c37b9aa95b26b42fe19a5b1d6b46643213a871
7
+ data.tar.gz: 1cab4aa7740798df185769d23cd6841aa4aaadbd338e41657b6435cd84173619604883492bb5f6801bbb7651968940252f01b67486c1b9de45787b0736534d1a
@@ -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
@@ -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)
@@ -127,7 +131,7 @@ module DockerRegistry2
127
131
  end
128
132
 
129
133
  def manifest_digest(repo, tag)
130
- tag_path = "/v2/#{repo}/manifests/#{tag}"
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("/v2/#{image}/manifests/#{tag}").headers[:docker_content_digest]
168
+ reference = doget("v2/#{image}/manifests/#{tag}").headers[:docker_content_digest]
165
169
 
166
- dodelete("/v2/#{image}/manifests/#{reference}").code
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 "/v2/#{newrepo}/manifests/#{newtag}", manifest.to_json
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 "/v2/#{repo}/blobs/#{blobSum}"
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
 
@@ -260,9 +261,7 @@ module DockerRegistry2
260
261
  links = parse_link_header(header)
261
262
  if links[:next]
262
263
  query = URI(links[:next]).query
263
- link_key = @uri.host.eql?('quay.io') || @uri.host.eql?('registry.access.redhat.com') ? 'next_page' : 'last'
264
- last = URI.decode_www_form(query).to_h[link_key]
265
-
264
+ last = URI.decode_www_form(query).to_h['last']
266
265
  end
267
266
  last
268
267
  end
@@ -290,7 +289,7 @@ module DockerRegistry2
290
289
  end
291
290
  response = RestClient::Request.execute(@http_options.merge(
292
291
  method: type,
293
- url: @base_uri + url,
292
+ url: URI.join(@base_uri, url).to_s,
294
293
  headers: headers(payload: payload),
295
294
  block_response: block,
296
295
  payload: payload
@@ -301,7 +300,7 @@ module DockerRegistry2
301
300
  raise DockerRegistry2::NotFound, "Image not found at #{@uri.host}"
302
301
  rescue RestClient::Unauthorized => e
303
302
  header = e.response.headers[:www_authenticate]
304
- method = header.to_s.downcase.split(' ')[0]
303
+ method = header.to_s.downcase.split[0]
305
304
  case method
306
305
  when 'basic'
307
306
  response = do_basic_req(type, url, stream, payload)
@@ -327,7 +326,7 @@ module DockerRegistry2
327
326
  end
328
327
  response = RestClient::Request.execute(@http_options.merge(
329
328
  method: type,
330
- url: @base_uri + url,
329
+ url: URI.join(@base_uri, url).to_s,
331
330
  user: @user,
332
331
  password: @password,
333
332
  headers: headers(payload: payload),
@@ -360,7 +359,7 @@ module DockerRegistry2
360
359
  end
361
360
  response = RestClient::Request.execute(@http_options.merge(
362
361
  method: type,
363
- url: @base_uri + url,
362
+ url: URI.join(@base_uri, url).to_s,
364
363
  headers: headers(payload: payload, bearer_token: token),
365
364
  block_response: block,
366
365
  payload: payload
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DockerRegistry2
4
- VERSION = '1.18.0'
4
+ VERSION = '1.18.2'
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.18.0
4
+ version: 1.18.2
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-28 00:00:00.000000000 Z
14
+ date: 2024-08-01 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.11
148
149
  signing_key:
149
150
  specification_version: 4
150
151
  summary: Docker v2 registry HTTP API client