docker_registry2 1.11.0 → 1.12.0

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: 7c94a748970c4e621a4bb1b856ea14915fbc83b55cff85743e7ef4333afb2360
4
- data.tar.gz: 340ce8d170519eb1a958a3c4d08314658d214ad0bd3e8c57d30d931086d885b0
3
+ metadata.gz: 869a69624555c180f16132300dfc203787a4e3ffd616f49f26ec7f199b469f1a
4
+ data.tar.gz: cab7c1746af1ef6956726f42524da542f2ebf9a2fe4a56cc793148aa04a285d4
5
5
  SHA512:
6
- metadata.gz: d4b64a53ae13758dadce8fd95708fbabd76cc604a740194584ba472022a2fd71c01c7526c1d577fa7aa253a8c72df069dce5b8242e48402dc2518f1d9e117633
7
- data.tar.gz: e3416ec4b0d38da96d5f7053b791f5d1b795b00a10a91d30c7aef30d454956728b94751cbb3d3eeeb9ac2a980404c1a5abbfdb0f327044e500891db20bc9c169
6
+ metadata.gz: 953669f5e94fef460fe7a3d866964aa76c87a29b2e2285ecb9a85a7058c43317ea1a683aa96e4c23bda450f48805edbc5c681f601ce00a81ae1e93020f6e02c0
7
+ data.tar.gz: 02fbf888184e024bdf49a62b8b2e4161ae02d1df7f265bbf93aa5e4244fde50221e4fd93e085c291f4333c2ba691ffcc469d016832091c8cb3a286bea39978ba
@@ -38,15 +38,34 @@ class DockerRegistry2::Registry
38
38
  return doreq "head", url
39
39
  end
40
40
 
41
+ # When a result set is too large, the Docker registry returns only the first items and adds a Link header in the
42
+ # response with the URL of the next page. See <https://docs.docker.com/registry/spec/api/#pagination>. This method
43
+ # iterates over the pages and calls the given block with each response.
44
+ def paginate_doget(url)
45
+ while url
46
+ response = doget(url)
47
+ yield response
48
+
49
+ if (link = response.headers[:link])
50
+ url = parse_link_header(link)[:next]
51
+ else
52
+ break
53
+ end
54
+ end
55
+ end
56
+
41
57
  def search(query = '')
42
- response = doget "/v2/_catalog"
43
- # parse the response
44
- repos = JSON.parse(response)["repositories"]
45
- if query.strip.length > 0
46
- re = Regexp.new query
47
- repos = repos.find_all {|e| re =~ e }
58
+ all_repos = []
59
+ paginate_doget "/v2/_catalog" do |response|
60
+ # parse the response
61
+ repos = JSON.parse(response)["repositories"]
62
+ if query.strip.length > 0
63
+ re = Regexp.new query
64
+ repos = repos.find_all {|e| re =~ e }
65
+ end
66
+ all_repos += repos
48
67
  end
49
- return repos
68
+ all_repos
50
69
  end
51
70
 
52
71
  def tags(repo,count=nil,last="",withHashes = false, auto_paginate: false)
@@ -208,7 +227,9 @@ class DockerRegistry2::Registry
208
227
  Integer(response.headers[:content_length],10)
209
228
  end
210
229
 
211
- def last(header)
230
+ # Parse the value of the Link HTTP header and return a Hash whose keys are the rel values turned into symbols, and
231
+ # the values are URLs. For example, `{ next: '/v2/_catalog?n=100&last=x' }`.
232
+ def parse_link_header(header)
212
233
  last=''
213
234
  parts = header.split(',')
214
235
  links = Hash.new
@@ -221,6 +242,11 @@ class DockerRegistry2::Registry
221
242
  links[name] = url
222
243
  end
223
244
 
245
+ links
246
+ end
247
+
248
+ def last(header)
249
+ links = parse_link_header(header)
224
250
  if links[:next]
225
251
  query=URI(links[:next]).query
226
252
  link_key = @uri.host.eql?('quay.io') ? 'next_page' : 'last'
@@ -1,3 +1,3 @@
1
1
  module DockerRegistry2
2
- VERSION = '1.11.0'
2
+ VERSION = '1.12.0'
3
3
  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.11.0
4
+ version: 1.12.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: 2022-07-26 00:00:00.000000000 Z
14
+ date: 2022-08-23 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: bundler