Commit b5043d5d authored by Kamil Trzcinski's avatar Kamil Trzcinski

Fix review comments

parent 60869580
...@@ -39,6 +39,7 @@ documentation](../workflow/add-user/add-user.md). ...@@ -39,6 +39,7 @@ documentation](../workflow/add-user/add-user.md).
| Cancel and retry builds | | | ✓ | ✓ | ✓ | | Cancel and retry builds | | | ✓ | ✓ | ✓ |
| Create or update commit status | | | ✓ | ✓ | ✓ | | Create or update commit status | | | ✓ | ✓ | ✓ |
| Update a container registry | | | ✓ | ✓ | ✓ | | Update a container registry | | | ✓ | ✓ | ✓ |
| Remove a container registry images | | | ✓ | ✓ | ✓ |
| Create new milestones | | | | ✓ | ✓ | | Create new milestones | | | | ✓ | ✓ |
| Add new team members | | | | ✓ | ✓ | | Add new team members | | | | ✓ | ✓ |
| Push to protected branches | | | | ✓ | ✓ | | Push to protected branches | | | | ✓ | ✓ |
......
...@@ -44,7 +44,6 @@ module ContainerRegistry ...@@ -44,7 +44,6 @@ module ContainerRegistry
end end
def data def data
return @data if defined?(@data)
@data ||= client.blob(repository.name, digest, type) @data ||= client.blob(repository.name, digest, type)
end end
......
...@@ -9,20 +9,8 @@ module ContainerRegistry ...@@ -9,20 +9,8 @@ module ContainerRegistry
def initialize(base_uri, options = {}) def initialize(base_uri, options = {})
@base_uri = base_uri @base_uri = base_uri
@faraday = Faraday.new(@base_uri) do |builder| @faraday = Faraday.new(@base_uri) do |conn|
builder.request :json initialize_connection(conn)
builder.headers['Accept'] = MANIFEST_VERSION
builder.response :json, :content_type => /\bjson$/
builder.response :json, :content_type => 'application/vnd.docker.distribution.manifest.v1+prettyjws'
if options[:user] && options[:password]
builder.request(:basic_auth, options[:user].to_s, options[:password].to_s)
elsif options[:token]
builder.request(:authorization, :bearer, options[:token].to_s)
end
builder.adapter :net_http
end end
end end
...@@ -60,5 +48,22 @@ module ContainerRegistry ...@@ -60,5 +48,22 @@ module ContainerRegistry
def delete_blob(name, digest) def delete_blob(name, digest)
@faraday.delete("/v2/#{name}/blobs/#{digest}").success? @faraday.delete("/v2/#{name}/blobs/#{digest}").success?
end end
private
def initialize_connection(conn)
conn.request :json
conn.headers['Accept'] = MANIFEST_VERSION
conn.response :json, :content_type => /\bjson$/
if options[:user] && options[:password]
conn.request(:basic_auth, options[:user].to_s, options[:password].to_s)
elsif options[:token]
conn.request(:authorization, :bearer, options[:token].to_s)
end
conn.adapter :net_http
end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment