docker_registry2 1.13.0 → 1.14.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: 7d2c4b1b61074554ed7e15a5d3c662ebeaae19594cb8c4e3e3ba3dc78e67f0c5
4
- data.tar.gz: a1dea179ace034fff0914bbc2a1eb6bcd0dd24cd274f01379a6ffd8215e56c7d
3
+ metadata.gz: 6c331456d39ce2a4a57002e7117101f261b2b78bea3b056843430b6c8ccc2110
4
+ data.tar.gz: 2370009afd0319cfc35a49443e51ad6566508362e5cf3fce941af793c16ac885
5
5
  SHA512:
6
- metadata.gz: 7778fc311ce302caf634887a0801490043e7550d819dde8926312b0496134736dfeec474b045ecc5e74a7f29b7195a5977c52b530496edf6a54d187be0ce039e
7
- data.tar.gz: 7ff181d7d3b7fe9ba0f87e2cdf342044a1e4442e55fe760ea5cf351994f41c0bf5d6316b33d1e920533b5ee7032dcb10a4230b5ca5d469dbedbe47919eb4063d
6
+ metadata.gz: 32a04a5987fa31cd7feb34d476f82b771e02fd4e5f93caeb4888ad27da0ab7b20cd5cf279f3f06954c599cf68ac930ed9183e5b0410ef90642110bd9ca859b62
7
+ data.tar.gz: 6ae15951f3f7ca11af1700a701fbc5e270f4adf9a9fb1998bb3657ef85fc79bd1c7cb18e1f9e598e8d592eec9d3c2dfb412d34c7c39fab26b7a3df69585b0dc0
@@ -5,7 +5,7 @@ require 'rest-client'
5
5
  require 'json'
6
6
 
7
7
  module DockerRegistry2
8
- class Registry
8
+ class Registry # rubocop:disable Metrics/ClassLength
9
9
  # @param [#to_s] base_uri Docker registry base URI
10
10
  # @param [Hash] options Client options
11
11
  # @option options [#to_s] :user User name for basic authentication
@@ -45,26 +45,22 @@ module DockerRegistry2
45
45
  # response with the URL of the next page. See <https://docs.docker.com/registry/spec/api/#pagination>. This method
46
46
  # iterates over the pages and calls the given block with each response.
47
47
  def paginate_doget(url)
48
- while url
48
+ loop do
49
49
  response = doget(url)
50
50
  yield response
51
51
 
52
- break unless (link = response.headers[:link])
53
-
54
- url = parse_link_header(link)[:next]
52
+ link_header = response.headers[:link]
53
+ break unless link_header
55
54
 
55
+ url = parse_link_header(link_header)[:next]
56
56
  end
57
57
  end
58
58
 
59
59
  def search(query = '')
60
60
  all_repos = []
61
- paginate_doget '/v2/_catalog' do |response|
62
- # parse the response
61
+ paginate_doget('/v2/_catalog') do |response|
63
62
  repos = JSON.parse(response)['repositories']
64
- if query.strip.length.positive?
65
- re = Regexp.new query
66
- repos = repos.find_all { |e| re =~ e }
67
- end
63
+ repos.select! { |repo| repo.match?(/#{query}/) } unless query.empty?
68
64
  all_repos += repos
69
65
  end
70
66
  all_repos
@@ -411,7 +407,14 @@ module DockerRegistry2
411
407
  def headers(payload: nil, bearer_token: nil)
412
408
  headers = {}
413
409
  headers['Authorization'] = "Bearer #{bearer_token}" unless bearer_token.nil?
414
- headers['Accept'] = 'application/vnd.docker.distribution.manifest.v2+json,application/vnd.docker.distribution.manifest.list.v2+json,application/json' if payload.nil?
410
+ if payload.nil?
411
+ headers['Accept'] =
412
+ %w[application/vnd.docker.distribution.manifest.v2+json
413
+ application/vnd.docker.distribution.manifest.list.v2+json
414
+ application/vnd.oci.image.manifest.v1+json
415
+ application/vnd.oci.image.index.v1+json
416
+ application/json].join(',')
417
+ end
415
418
  headers['Content-Type'] = 'application/vnd.docker.distribution.manifest.v2+json' unless payload.nil?
416
419
 
417
420
  headers
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DockerRegistry2
4
- VERSION = '1.13.0'
4
+ VERSION = '1.14.0'
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.13.0
4
+ version: 1.14.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-12-23 00:00:00.000000000 Z
14
+ date: 2023-03-31 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: bundler