Class: DependencyProxy::FindCachedManifestService

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

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(group, image, tag, token) ⇒ FindCachedManifestService

Returns a new instance of FindCachedManifestService.



5
6
7
8
9
10
11
12
# File 'app/services/dependency_proxy/find_cached_manifest_service.rb', line 5

def initialize(group, image, tag, token)
  @group = group
  @image = image
  @tag = tag
  @token = token
  @file_name = "#{@image}:#{@tag}.json"
  @manifest = nil
end

Instance Method Details

#executeObject



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

def execute
  @manifest = @group.dependency_proxy_manifests
                    .active
                    .find_by_file_name_or_digest(file_name: @file_name, digest: @tag)

  head_result = DependencyProxy::HeadManifestService.new(@image, @tag, @token).execute

  return respond if cached_manifest_matches?(head_result)
  return respond if @manifest && head_result[:status] == :error

  success(manifest: nil, from_cache: false)
rescue Timeout::Error, *Gitlab::HTTP::HTTP_ERRORS
  respond
end