2018-10-06 19:10:08 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-05-09 15:14:46 -04:00
|
|
|
module ContainerRegistry
|
2016-05-04 08:22:54 -04:00
|
|
|
class Registry
|
2022-02-18 07:15:31 -05:00
|
|
|
attr_reader :uri, :client, :gitlab_api_client, :path
|
2016-05-04 08:22:54 -04:00
|
|
|
|
|
|
|
def initialize(uri, options = {})
|
2016-05-17 10:41:47 -04:00
|
|
|
@uri = uri
|
2022-01-25 13:11:55 -05:00
|
|
|
@options = options
|
|
|
|
@path = @options[:path] || default_path
|
|
|
|
@client = ContainerRegistry::Client.new(@uri, @options)
|
2022-02-01 04:13:59 -05:00
|
|
|
|
2022-02-18 07:15:31 -05:00
|
|
|
import_token = Auth::ContainerRegistryAuthenticationService.import_access_token
|
|
|
|
@gitlab_api_client = ContainerRegistry::GitlabApiClient.new(@uri, @options.merge(import_token: import_token))
|
2016-05-04 08:22:54 -04:00
|
|
|
end
|
|
|
|
|
2016-05-17 10:41:47 -04:00
|
|
|
private
|
|
|
|
|
|
|
|
def default_path
|
2018-01-27 00:35:53 -05:00
|
|
|
@uri.sub(%r{^https?://}, '')
|
2016-05-17 10:41:47 -04:00
|
|
|
end
|
2016-05-04 08:22:54 -04:00
|
|
|
end
|
|
|
|
end
|