docker_registry2 1.6.2 → 1.7.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: e35187dcf21e13516ef819f08d95f23f1f398ac8f17b5737dfb829b33d89c431
4
- data.tar.gz: b5ab54fb96709a4de8c1a32d1c2323bb3b7310b38eaba7978cbfa413b7e64751
3
+ metadata.gz: 1591b5d46dda76268ee84b6cc588c6ecd311eb6a2f2627e7522ef516b64c1d84
4
+ data.tar.gz: 9c614d30dab2ca67e50f29d0dba6a320d1ba8c50a493373b7e035469f31de2cd
5
5
  SHA512:
6
- metadata.gz: d57a17a464cdec565613284bd1168c83ee4e58d23dcb7b3773696f5659c9913d368b1592ad50a4e8778045cde6c36e88185d935ceadabdc86b4c2e34cbc3a6e0
7
- data.tar.gz: 1fbca82a8c84baac59370e7a68dc97211127e15a3b572a657b82dee16746685d166f80470cb40def9a04a1d8b35c688013b7e6e085bd565b8d7b4ae9a4a51a70
6
+ metadata.gz: a4e6aba5f883fa302753047e5949542e746d6b17f76dc069a79b0f842a46dc2c643bd1c05c58aa977548c503d5a1c32f15ff9b2b6c4b1a5eb4c7f459a12a7b1f
7
+ data.tar.gz: d755b52601c9891064eb3c9e72b285ffdb7099fd39eaff4a96d1e419597adc6c03c0f3e6b65f4a1f0070db97fdbf576c792f3d1a644d056af32c913c2cc3dbfd
@@ -49,33 +49,27 @@ class DockerRegistry2::Registry
49
49
  return repos
50
50
  end
51
51
 
52
- def tags(repo,count=nil,last="",withHashes = false)
52
+ def tags(repo,count=nil,last="",withHashes = false, auto_paginate: false)
53
53
  #create query params
54
54
  params = []
55
- if last != ""
56
- params.push(["last",last])
57
- end
58
- if count != nil
59
- params.push(["n",count])
60
- end
55
+ params.push(["last",last]) if last && last != ""
56
+ params.push(["n",count]) unless count.nil?
61
57
 
62
58
  query_vars = ""
63
- if params.length > 0
64
- query_vars = "?#{URI.encode_www_form(params)}"
65
- end
59
+ query_vars = "?#{URI.encode_www_form(params)}" if params.length > 0
60
+
66
61
  response = doget "/v2/#{repo}/tags/list#{query_vars}"
67
62
  # parse the response
68
63
  resp = JSON.parse response
69
64
  # parse out next page link if necessary
70
- if response.headers[:link]
71
- resp["last"] = last(response.headers[:link])
72
- end
65
+ resp["last"] = last(response.headers[:link]) if response.headers[:link]
66
+
73
67
  # do we include the hashes?
74
- if withHashes then
68
+ if withHashes
75
69
  useGet = false
76
70
  resp["hashes"] = {}
77
- resp["tags"].each {|tag|
78
- if useGet then
71
+ resp["tags"].each do |tag|
72
+ if useGet
79
73
  head = doget "/v2/#{repo}/manifests/#{tag}"
80
74
  else
81
75
  begin
@@ -87,8 +81,19 @@ class DockerRegistry2::Registry
87
81
  end
88
82
  end
89
83
  resp["hashes"][tag] = head.headers[:docker_content_digest]
90
- }
84
+ end
91
85
  end
86
+
87
+ return resp unless auto_paginate
88
+
89
+ while (last_tag = resp.delete("last"))
90
+ additional_tags = tags(repo, count, last_tag, withHashes)
91
+ resp["last"] = additional_tags["last"]
92
+ resp["tags"] += additional_tags["tags"]
93
+ resp["tags"] = resp["tags"].uniq
94
+ resp["hashes"].merge!(additional_tags["hashes"]) if withHashes
95
+ end
96
+
92
97
  resp
93
98
  end
94
99
 
@@ -1,3 +1,3 @@
1
1
  module DockerRegistry2
2
- VERSION = '1.6.2'
2
+ VERSION = '1.7.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.6.2
4
+ version: 1.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Avi Deitcher https://github.com/deitch