debian-mirror-gitlab/app/services/dependency_proxy/head_manifest_service.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

35 lines
844 B
Ruby
Raw Normal View History

2021-02-22 17:27:13 +05:30
# frozen_string_literal: true
module DependencyProxy
class HeadManifestService < DependencyProxy::BaseService
2023-05-27 22:25:52 +05:30
ACCEPT_HEADERS = DependencyProxy::Manifest::ACCEPTED_TYPES.join(',')
2021-04-17 20:07:23 +05:30
2021-02-22 17:27:13 +05:30
def initialize(image, tag, token)
@image = image
@tag = tag
@token = token
end
def execute
2021-04-17 20:07:23 +05:30
response = Gitlab::HTTP.head(manifest_url, headers: auth_headers.merge(Accept: ACCEPT_HEADERS))
2021-02-22 17:27:13 +05:30
if response.success?
2021-12-11 22:18:48 +05:30
success(
digest: response.headers[DependencyProxy::Manifest::DIGEST_HEADER],
content_type: response.headers['content-type']
)
2021-02-22 17:27:13 +05:30
else
error(response.body, response.code)
end
rescue Timeout::Error => exception
error(exception.message, 599)
end
private
def manifest_url
registry.manifest_url(@image, @tag)
end
end
end