blob: 710f8169a004df301331efbf1af1bf2bd806e75c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# frozen_string_literal: true
module ContainerRegistry
class Registry
include Gitlab::Utils::StrongMemoize
attr_reader :uri, :client, :path
def initialize(uri, options = {})
@uri = uri
@options = options
@path = @options[:path] || default_path
@client = ContainerRegistry::Client.new(@uri, @options)
end
def gitlab_api_client
strong_memoize(:gitlab_api_client) do
token = Auth::ContainerRegistryAuthenticationService.import_access_token
url = Gitlab.config.registry.api_url
host_port = Gitlab.config.registry.host_port
ContainerRegistry::GitlabApiClient.new(url, token: token, path: host_port)
end
end
private
def default_path
@uri.sub(%r{^https?://}, '')
end
end
end
|