diff options
author | Kamil Trzciński <ayufan@ayufan.eu> | 2019-01-10 15:22:58 +0100 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2019-01-25 13:13:48 +0100 |
commit | 045d07bab37df2020f650f7354157f5267f57c8a (patch) | |
tree | e99aad48ed248daa02ff1d7fe9250b327ffa77bb /app/models | |
parent | 267ce96e36ecec169b02410bfea85e6d31715910 (diff) | |
download | gitlab-ce-045d07bab37df2020f650f7354157f5267f57c8a.tar.gz |
Add Container Registry API
This includes a set of APIs to manipulate container registry.
This includes also an ability to delete tags based on requested
criteria, like keep-last-n, matching-name, older-than.
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/container_repository.rb | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/app/models/container_repository.rb b/app/models/container_repository.rb index 2c08a8e1acf..cf057d774cf 100644 --- a/app/models/container_repository.rb +++ b/app/models/container_repository.rb @@ -1,6 +1,8 @@ # frozen_string_literal: true class ContainerRepository < ActiveRecord::Base + include Gitlab::Utils::StrongMemoize + belongs_to :project validates :name, length: { minimum: 0, allow_nil: false } @@ -8,6 +10,8 @@ class ContainerRepository < ActiveRecord::Base delegate :client, to: :registry + scope :ordered, -> { order(:name) } + # rubocop: disable CodeReuse/ServiceClass def registry @registry ||= begin @@ -39,11 +43,12 @@ class ContainerRepository < ActiveRecord::Base end def tags - return @tags if defined?(@tags) return [] unless manifest && manifest['tags'] - @tags = manifest['tags'].map do |tag| - ContainerRegistry::Tag.new(self, tag) + strong_memoize(:tags) do + manifest['tags'].sort.map do |tag| + ContainerRegistry::Tag.new(self, tag) + end end end |