2018-10-06 23:10:08 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-05-09 19:14:46 +00:00
|
|
|
module ContainerRegistry
|
2016-05-04 12:22:54 +00:00
|
|
|
class Registry
|
2022-01-25 18:11:55 +00:00
|
|
|
include Gitlab::Utils::StrongMemoize
|
|
|
|
|
2016-05-09 19:27:06 +00:00
|
|
|
attr_reader :uri, :client, :path
|
2016-05-04 12:22:54 +00:00
|
|
|
|
|
|
|
def initialize(uri, options = {})
|
2016-05-17 14:41:47 +00:00
|
|
|
@uri = uri
|
2022-01-25 18:11:55 +00:00
|
|
|
@options = options
|
|
|
|
@path = @options[:path] || default_path
|
|
|
|
@client = ContainerRegistry::Client.new(@uri, @options)
|
|
|
|
end
|
|
|
|
|
|
|
|
def gitlab_api_client
|
|
|
|
strong_memoize(:gitlab_api_client) do
|
|
|
|
ContainerRegistry::GitlabApiClient.new(@uri, @options)
|
|
|
|
end
|
2016-05-04 12:22:54 +00:00
|
|
|
end
|
|
|
|
|
2016-05-17 14:41:47 +00:00
|
|
|
private
|
|
|
|
|
|
|
|
def default_path
|
2018-01-27 05:35:53 +00:00
|
|
|
@uri.sub(%r{^https?://}, '')
|
2016-05-17 14:41:47 +00:00
|
|
|
end
|
2016-05-04 12:22:54 +00:00
|
|
|
end
|
|
|
|
end
|