Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/container_registry/registry.rb')
-rw-r--r--lib/container_registry/registry.rb18
1 files changed, 16 insertions, 2 deletions
diff --git a/lib/container_registry/registry.rb b/lib/container_registry/registry.rb
index 523364ac7c7..710f8169a00 100644
--- a/lib/container_registry/registry.rb
+++ b/lib/container_registry/registry.rb
@@ -2,12 +2,26 @@
module ContainerRegistry
class Registry
+ include Gitlab::Utils::StrongMemoize
+
attr_reader :uri, :client, :path
def initialize(uri, options = {})
@uri = uri
- @path = options[:path] || default_path
- @client = ContainerRegistry::Client.new(uri, options)
+ @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