docker_registry2 1.6.0 → 1.6.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
  SHA1:
3
- metadata.gz: 81a59b8010136692df1083c6a952f8cd1daaa731
4
- data.tar.gz: 25f140d4340f8fc8c6c90a3fb9aab39179c1433a
3
+ metadata.gz: bf424b2e5e3bfbadd28cafdf008e134209cf2c2e
4
+ data.tar.gz: 66e95afc5c4e76d1122d72c1ee6b6d5a828adfce
5
5
  SHA512:
6
- metadata.gz: e8d4477daf7c4aa1e03cf4101ca1f6d4e0b3841a34f925461e0af93bdacc34cdde4ee4c0968e6f6d6800f2b2164e3a0d7d6ae736e43e0eeb3d04f289c23eed73
7
- data.tar.gz: ea63c5390cfd87e0746cc2f27acfc640602fe91bf75af982f5db2361c1a36b4ea8706e0ed4ed8da0ed3f4b1ab53a3c8777a7c47312a7925c0dd25ac0d93dfe2d
6
+ metadata.gz: 3105398ddc358110e1b38b5c6ce432b65fc4f8dd3c7a1bbfb44bbf5b7d15d597464821c1733dfaa19fdee157e54ee666a9cb3302565f554e73e87d0669796fc9
7
+ data.tar.gz: 7c9f6d4a74331433957993a54daa4fb189b813e2a2919c940bbd73aa476336026c2a7879100d55bdb5ea44fc4d3457a17f51889439e353bdb5da04624f79a163
data/README.md CHANGED
@@ -117,17 +117,25 @@ The following exceptions are thrown:
117
117
 
118
118
  #### tags
119
119
  ````ruby
120
- results = reg.tags("mylibs",withHashes)
120
+ results = reg.tags("mylibs",count=nil,last="",withHashes=false)
121
121
  ````
122
122
 
123
- Returns all known tags for the repository precisely named `"mylibs"`. If `withHashes` is present and set to `true`, also will return all of the hashes for each tag. See below. Note that retrieving the hashes is an expensive operations, as it requires a separate `HEAD` for each tag. This is why the default is `false`.
123
+ Returns all known tags for the repository precisely named `"mylibs"`.
124
+
125
+ Arguments:
126
+
127
+ * `repository`: name of the repository to return, e.g. "mylibs" above. Relative to the registry to which you connected. REQUIRED.
128
+ * `count`: how many records to return, if the registry supports pagination. Default is not to limit. The behaviour changes by registry implementation. See the section on pagination below. OPTIONAL.
129
+ * `last`: the last record returned, if using pagination. See the section on pagination below. OPTIONAL.
130
+ * `withHashes`: return the hash of the manifest for each tag. Note that retrieving the hashes is an expensive operations, as it requires a separate `HEAD` for each tag. This is why the default is `false`. OPTIONAL.
124
131
 
125
132
  Returns an object with the following key value pairs:
126
133
  array of objects, each of which has the following key/value pairs:
127
134
 
128
- * `name`: full name of repository, e.g. `redis` or `user/redis`
129
- * `tags`: array of strings, each of which is a tag for ths given repository
135
+ * `name`: full name of repository, e.g. `redis` or `user/redis`.
136
+ * `tags`: array of strings, each of which is a tag for ths given repository.
130
137
  * `hashes`: object, keys of which are the tag name, and values of which are the hash. Only provided if `withHashes` is true.
138
+ * `last`: the last entry returned, to be used for pagination, only returned if the results have been paginated by the server.
131
139
 
132
140
  Other fields may be added later. Do *not* assume those are the only fields.
133
141
 
@@ -157,8 +165,60 @@ The following exceptions are thrown:
157
165
  * `RegistryAuthenticationException`: username and password are invalid
158
166
  * `RegistryAuthorizationException`: registry does not support tags using the given credentials, probably because the repository is private and the credentials provided do not have access
159
167
 
168
+ ##### pagination
169
+
170
+ Some regstries support pagination for tags per [this standard](https://docs.docker.com/registry/spec/api/#listing-image-tags). If the registry supports pagination, you have several options:
171
+
172
+ * Ignore it, and simply get back whatever the max number o tags the registry returns in whatever order. In many cases, this will work. `tags("repo")`
173
+ * Set an arbitrarily high number. Note that this may not work, as the registry may implement a limit below your cap. `tags("repo", 5000)`
174
+ * Work with pagination.
175
+
176
+ To work with pagination, after each result set, you keep getting a new result set until there are no more. In this case, with each request, the `tags()` results will tell you what the key of the last one was returned. You pass that into the next call, so it knows where to start for the next set of results. You also can choose to limit the `count`, or just accept whatever default the registry has set.
177
+
178
+ For example, let us assume that the registry has 26 tags, from `"a"` to `"z"`, and that it returns 3 tags with each call by default. Your first call:
179
+
180
+ ```ruby
181
+ res = tags("repo")
182
+ # or, to limit to 3 explicilty
183
+ res = tags("repo")
184
+ ```
185
+
186
+ Your results will be:
187
+
188
+ ```ruby
189
+ {
190
+ "name" => "repo",
191
+ "tags" => ["a","b","c"],
192
+ "last" => "c"
193
+ }
194
+ ```
160
195
 
196
+ Note that it returned 3, either because that was the registry default or you explicitly limited to 3 results. It also told you that the last tag was `"c"`. You now can pass that on to the next request.
161
197
 
198
+ ```ruby
199
+ res = tags("repo",nil,"c")
200
+ # or, to limit to 3 explicitly
201
+ res = tags("repo",3,"c")
202
+ ```
203
+
204
+ The results will be:
205
+
206
+ ```ruby
207
+ {
208
+ "name" => "repo",
209
+ "tags" => ["d","e","f"]
210
+ "last" => "f"
211
+ }
212
+ ```
213
+
214
+ Repeat until you have all of the results. The last one has no more pagination, and so the results will be without a `"last"` field:
215
+
216
+ ```ruby
217
+ {
218
+ "name" => "repo",
219
+ "tags" => ["x","y","z"]
220
+ }
221
+ ```
162
222
 
163
223
 
164
224
  #### manifest
@@ -49,15 +49,21 @@ class DockerRegistry2::Registry
49
49
  return repos
50
50
  end
51
51
 
52
- def tags(repo,count=100,last="",withHashes = false)
52
+ def tags(repo,count=nil,last="",withHashes = false)
53
53
  #create query params
54
54
  params = []
55
55
  if last != ""
56
56
  params.push(["last",last])
57
57
  end
58
- params.push(["n",count])
58
+ if count != nil
59
+ params.push(["n",count])
60
+ end
59
61
 
60
- response = doget "/v2/#{repo}/tags/list?#{URI.encode_www_form(params)}"
62
+ query_vars = ""
63
+ if params.length > 0
64
+ query_vars = "?#{URI.encode_www_form(params)}"
65
+ end
66
+ response = doget "/v2/#{repo}/tags/list#{query_vars}"
61
67
  # parse the response
62
68
  resp = JSON.parse response
63
69
  # parse out next page link if necessary
@@ -1,3 +1,3 @@
1
1
  module DockerRegistry2
2
- VERSION = '1.6.0'
2
+ VERSION = '1.6.1'
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.0
4
+ version: 1.6.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: 2019-06-27 00:00:00.000000000 Z
14
+ date: 2019-06-28 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: bundler