Class: DependencyProxy::HeadManifestService

Inherits:
BaseService show all
Defined in:
app/services/dependency_proxy/head_manifest_service.rb

Constant Summary collapse

ACCEPT_HEADERS =
DependencyProxy::Manifest::ACCEPTED_TYPES.join(',')

Instance Attribute Summary

Attributes inherited from BaseService

#current_user, #params, #project

Instance Method Summary collapse

Methods included from BaseServiceUtility

#deny_visibility_level, #event_service, #log_error, #log_info, #notification_service, #system_hook_service, #todo_service, #visibility_level

Methods included from Gitlab::Allowable

#can?

Constructor Details

#initialize(image, tag, token) ⇒ HeadManifestService

Returns a new instance of HeadManifestService.



7
8
9
10
11
# File 'app/services/dependency_proxy/head_manifest_service.rb', line 7

def initialize(image, tag, token)
  @image = image
  @tag = tag
  @token = token
end

Instance Method Details

#executeObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/services/dependency_proxy/head_manifest_service.rb', line 13

def execute
  response = Gitlab::HTTP.head(manifest_url, headers: auth_headers.merge(Accept: ACCEPT_HEADERS))

  if response.success?
    success(
      digest: response.headers[DependencyProxy::Manifest::DIGEST_HEADER],
      content_type: response.headers['content-type']
    )
  else
    error(response.body, response.code)
  end
rescue Timeout::Error => exception
  error(exception.message, 599)
end