oci_registry 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 929ac794aafd238965aad937e7f2a1cb197986e582893d5e4051c93e0098a88a
4
- data.tar.gz: 64e51f1abdbd0176f6d337a72b4c1bd1e261f3c9f599aaddd78311caadcd3070
3
+ metadata.gz: dac93e38a0e1f8f5dfc3356937c8c2530d9408142f0f4aa40d42a859198adb95
4
+ data.tar.gz: 52e01c9f726497aa20403b2acc7e8be1c589524b6d5acc919a657c257af15232
5
5
  SHA512:
6
- metadata.gz: b41dbb62fb262b588b43d5503c782a3d43857dc4b79dceed24e428666910f88bdaaabde7c6fccc957cfa9b661f1aad11d07e5dce5f3bd73c870846ed382299e3
7
- data.tar.gz: a5f268cfae9dd9372f7ff8a62c9c5cef9514969e2d96ab14c1f203e28cb0df6e5c38d2486a57dcd9e50dcb51e56716b2b107efe2b4767d633d93323a9b9df200
6
+ metadata.gz: d95d2ef1bdc6b82e7fc5c1fa11f8fb7b2b1fe831085f97940ffd95ae67cda95e9c355b7798eeadbda57d95724e8e25337dce7314bc2569a1e59dc2ffcdd0914a
7
+ data.tar.gz: e99863199acfbdf80c02020305ef65ced204b2c5ffedc7b79dfe36cc6e1850fcab8537737b3953211dfafe2996ab2e0210cc74f26601e83a3873205421c3a89e
@@ -29,7 +29,15 @@ module OCIRegistry
29
29
  # warn "Redirected to #{location}"
30
30
  # Handle the case where location is a relative URL by reconstructing the full URL
31
31
  new_uri = ::URI.join(uri, location)
32
- http_get(new_uri, headers, limit - 1)
32
+
33
+ # Don't forward Authorization header across domain boundaries
34
+ # This was discovered through pain and suffering when Docker redirects to S3.
35
+ new_headers = headers.dup
36
+ if uri.host != new_uri.host
37
+ new_headers.delete('Authorization')
38
+ end
39
+
40
+ http_get(new_uri, new_headers, limit - 1)
33
41
  # 429
34
42
  when Net::HTTPTooManyRequests
35
43
  puts "Rate limited: #{response.code} #{response.message}"
@@ -58,7 +66,9 @@ module OCIRegistry
58
66
  json = JSON.parse(response.body)
59
67
  json['token']
60
68
  else
61
- raise "Failed to obtain token: #{response.code} #{response.message}"
69
+ error_detail = response.body.to_s.strip
70
+ error_detail = ": #{error_detail}" unless error_detail.empty?
71
+ raise "Failed to obtain token: #{response.code} #{response.message}#{error_detail}"
62
72
  end
63
73
  end
64
74
 
@@ -80,7 +90,9 @@ module OCIRegistry
80
90
  if response.is_a?(Net::HTTPSuccess)
81
91
  JSON.parse(response.body)
82
92
  else
83
- raise "Failed to fetch manifest: #{response.code} #{response.message}"
93
+ error_detail = response.body.to_s.strip
94
+ error_detail = ": #{error_detail}" unless error_detail.empty?
95
+ raise "Failed to fetch manifest: #{response.code} #{response.message}#{error_detail}"
84
96
  end
85
97
  end
86
98
 
@@ -94,7 +106,9 @@ module OCIRegistry
94
106
  if response.is_a?(Net::HTTPSuccess)
95
107
  JSON.parse(response.body)
96
108
  else
97
- raise "Failed to retrieve image configuration for #{uri.inspect}: #{response.code} #{response.message}"
109
+ error_detail = response.body.to_s.strip
110
+ error_detail = ": #{error_detail}" unless error_detail.empty?
111
+ raise "Failed to retrieve image configuration for #{uri.inspect}: #{response.code} #{response.message}#{error_detail}"
98
112
  end
99
113
  end
100
114
 
@@ -124,7 +138,9 @@ module OCIRegistry
124
138
  break
125
139
  end
126
140
  else
127
- puts "Failed to fetch tags for #{repository}: https://#{host}#{next_url} #{response.code} #{response.message}"
141
+ error_detail = response.body.to_s.strip
142
+ error_detail = ": #{error_detail}" unless error_detail.empty?
143
+ puts "Failed to fetch tags for #{repository}: https://#{host}#{next_url} #{response.code} #{response.message}#{error_detail}"
128
144
  break
129
145
  end
130
146
  end
@@ -160,7 +176,9 @@ module OCIRegistry
160
176
  found = extract_layer(response.body, file_name)
161
177
  return true if found
162
178
  else
163
- puts "Failed to download layer #{digest}: #{response.code} #{response.message}"
179
+ error_detail = response.body.to_s.strip
180
+ error_detail = ": #{error_detail}" unless error_detail.empty?
181
+ puts "Failed to download layer #{digest}: #{response.code} #{response.message}#{error_detail}"
164
182
  end
165
183
  end
166
184
  false
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OCIRegistry
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oci_registry
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Siegel
@@ -131,7 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
131
131
  - !ruby/object:Gem::Version
132
132
  version: '0'
133
133
  requirements: []
134
- rubygems_version: 3.5.22
134
+ rubygems_version: 3.5.16
135
135
  signing_key:
136
136
  specification_version: 4
137
137
  summary: Ruby client for OCI/Docker Registry HTTP API v2