docker_registry2 1.14.0 → 1.15.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: 6c331456d39ce2a4a57002e7117101f261b2b78bea3b056843430b6c8ccc2110
4
- data.tar.gz: 2370009afd0319cfc35a49443e51ad6566508362e5cf3fce941af793c16ac885
3
+ metadata.gz: 2b93252a450c644a699ad3e18d6350d734de156a6c034d326be58745c8454242
4
+ data.tar.gz: af73611edfe95ec8b47cda4059a82b1902c0c3230dba8399c524e7cb4a6491e0
5
5
  SHA512:
6
- metadata.gz: 32a04a5987fa31cd7feb34d476f82b771e02fd4e5f93caeb4888ad27da0ab7b20cd5cf279f3f06954c599cf68ac930ed9183e5b0410ef90642110bd9ca859b62
7
- data.tar.gz: 6ae15951f3f7ca11af1700a701fbc5e270f4adf9a9fb1998bb3657ef85fc79bd1c7cb18e1f9e598e8d592eec9d3c2dfb412d34c7c39fab26b7a3df69585b0dc0
6
+ metadata.gz: 5e2c641cc6a23b0751b535dfebaa780ab87fc9992f7639423537f369e33b8b034b81d2ea215a83117667527c4bdf4998b5df1bae308b70f95f31ccc835082979
7
+ data.tar.gz: a40c907aa5f98b0f1d719d1b3a57a75c9ae39dd95a8fcdc63c596d5444383ea241c6522f1314526ed81bc9c6412f4d1da2f0062dba4704feec24ef509d7fa028
@@ -17,7 +17,7 @@ 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}"
20
+ @base_uri = "#{@uri.scheme}://#{@uri.host}:#{@uri.port}#{@uri.path}"
21
21
  @user = options[:user]
22
22
  @password = options[:password]
23
23
  @http_options = options[:http_options] || {}
@@ -83,21 +83,9 @@ module DockerRegistry2
83
83
 
84
84
  # do we include the hashes?
85
85
  if withHashes
86
- useGet = false
87
86
  resp['hashes'] = {}
88
87
  resp['tags'].each do |tag|
89
- if useGet
90
- head = doget "/v2/#{repo}/manifests/#{tag}"
91
- else
92
- begin
93
- head = dohead "/v2/#{repo}/manifests/#{tag}"
94
- rescue DockerRegistry2::InvalidMethod
95
- # in case we are in a registry pre-2.3.0, which did not support manifest HEAD
96
- useGet = true
97
- head = doget "/v2/#{repo}/manifests/#{tag}"
98
- end
99
- end
100
- resp['hashes'][tag] = head.headers[:docker_content_digest]
88
+ resp['hashes'][tag] = digest(repo, tag)
101
89
  end
102
90
  end
103
91
 
@@ -138,12 +126,29 @@ module DockerRegistry2
138
126
  end
139
127
  end
140
128
 
141
- def digest(repo, tag)
142
- tag_path = "/v2/#{repo}/manifests/#{tag}"
143
- dohead(tag_path).headers[:docker_content_digest]
144
- rescue DockerRegistry2::InvalidMethod
145
- # Pre-2.3.0 registries didn't support manifest HEAD requests
146
- doget(tag_path).headers[:docker_content_digest]
129
+ def digest(image, tag, architecture = nil, os = nil, variant = nil)
130
+ manifest = manifest(image, tag)
131
+ parsed_manifest = JSON.parse(manifest.body)
132
+
133
+ # Multi-arch images
134
+ if parsed_manifest.key?('manifests')
135
+ manifests = parsed_manifest['manifests']
136
+
137
+ return manifests if architecture.nil? || os.nil?
138
+
139
+ manifests.each do |entry|
140
+ if !variant.nil?
141
+ return entry['digest'] if entry['platform']['architecture'] == architecture && entry['platform']['os'] == os && entry['platform']['variant'] == variant
142
+ elsif entry['platform']['architecture'] == architecture && entry['platform']['os'] == os
143
+ return entry['digest']
144
+ end
145
+ end
146
+
147
+ raise DockerRegistry2::NotFound, "No matches found for the image=#{image} tag=#{tag} os=#{os} architecture=#{architecture}"
148
+
149
+ end
150
+
151
+ parsed_manifest.dig('config', 'digest')
147
152
  end
148
153
 
149
154
  def rmtag(image, tag)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DockerRegistry2
4
- VERSION = '1.14.0'
4
+ VERSION = '1.15.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.14.0
4
+ version: 1.15.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: 2023-03-31 00:00:00.000000000 Z
14
+ date: 2023-05-01 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: bundler