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')
-rw-r--r--lib/container_registry/gitlab_api_client.rb3
-rw-r--r--lib/container_registry/referrer.rb13
-rw-r--r--lib/container_registry/tag.rb6
3 files changed, 20 insertions, 2 deletions
diff --git a/lib/container_registry/gitlab_api_client.rb b/lib/container_registry/gitlab_api_client.rb
index 9b6c37da847..276f9b492cb 100644
--- a/lib/container_registry/gitlab_api_client.rb
+++ b/lib/container_registry/gitlab_api_client.rb
@@ -170,7 +170,7 @@ module ContainerRegistry
end
# https://gitlab.com/gitlab-org/container-registry/-/blob/master/docs/spec/gitlab/api.md#list-repository-tags
- def tags(path, page_size: 100, last: nil, before: nil, name: nil, sort: nil)
+ def tags(path, page_size: 100, last: nil, before: nil, name: nil, sort: nil, referrers: nil)
limited_page_size = [page_size, MAX_TAGS_PAGE_SIZE].min
with_token_faraday do |faraday_client|
url = "#{GITLAB_REPOSITORIES_PATH}/#{path}/tags/list/"
@@ -180,6 +180,7 @@ module ContainerRegistry
req.params['before'] = before if before
req.params['name'] = name if name.present?
req.params['sort'] = sort if sort
+ req.params['referrers'] = 'true' if referrers
end
unless response.success?
diff --git a/lib/container_registry/referrer.rb b/lib/container_registry/referrer.rb
new file mode 100644
index 00000000000..e61899b3a1b
--- /dev/null
+++ b/lib/container_registry/referrer.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+module ContainerRegistry
+ class Referrer
+ attr_reader :artifact_type, :digest, :tag
+
+ def initialize(artifact_type, digest, tag)
+ @artifact_type = artifact_type
+ @digest = digest
+ @tag = tag
+ end
+ end
+end
diff --git a/lib/container_registry/tag.rb b/lib/container_registry/tag.rb
index 70742e8bd38..0000a0641be 100644
--- a/lib/container_registry/tag.rb
+++ b/lib/container_registry/tag.rb
@@ -4,7 +4,7 @@ module ContainerRegistry
class Tag
include Gitlab::Utils::StrongMemoize
- attr_reader :repository, :name, :updated_at
+ attr_reader :repository, :name, :updated_at, :referrers
attr_writer :created_at, :manifest_digest, :revision, :total_size
delegate :registry, :client, to: :repository
@@ -14,6 +14,10 @@ module ContainerRegistry
@name = name
end
+ def referrers=(refs)
+ @referrers = Array.wrap(refs).map { |ref| Referrer.new(ref['artifactType'], ref['digest'], self) }
+ end
+
def revision
@revision || config_blob&.revision
end