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).
| Cancel and retry builds | | | ✓ | ✓ | ✓ |
| Create or update commit status | | | ✓ | ✓ | ✓ |
| Update a container registry | | | ✓ | ✓ | ✓ |
| Remove a container registry images | | | ✓ | ✓ | ✓ |
| Create new milestones | | | | ✓ | ✓ |
| Add new team members | | | | ✓ | ✓ |
| Push to protected branches | | | | ✓ | ✓ |
......
......@@ -44,7 +44,6 @@ module ContainerRegistry
end
def data
return @data if defined?(@data)
@data ||= client.blob(repository.name, digest, type)
end
......
......@@ -9,20 +9,8 @@ module ContainerRegistry
def initialize(base_uri, options = {})
@base_uri = base_uri
@faraday = Faraday.new(@base_uri) do |builder|
builder.request :json
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
@faraday = Faraday.new(@base_uri) do |conn|
initialize_connection(conn)
end
end
......@@ -60,5 +48,22 @@ module ContainerRegistry
def delete_blob(name, digest)
@faraday.delete("/v2/#{name}/blobs/#{digest}").success?
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
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