gitlab-org--gitlab-foss/lib/container_registry/repository.rb

49 lines
886 B
Ruby
Raw Normal View History

module ContainerRegistry
class Repository
attr_reader :registry, :name
delegate :client, to: :registry
def initialize(registry, name)
@registry, @name = registry, name
end
def path
[registry.path, name].compact.join('/')
end
def tag(tag)
ContainerRegistry::Tag.new(self, tag)
end
def manifest
return @manifest if defined?(@manifest)
2016-05-17 14:41:47 +00:00
@manifest = client.repository_tags(name)
end
def valid?
manifest.present?
end
def tags
return @tags if defined?(@tags)
2016-05-04 14:16:54 +00:00
return [] unless manifest && manifest['tags']
2016-05-12 18:03:04 +00:00
@tags = manifest['tags'].map do |tag|
ContainerRegistry::Tag.new(self, tag)
end
end
def blob(config)
ContainerRegistry::Blob.new(self, config)
end
def delete_tags
return unless tags
2016-05-12 18:03:04 +00:00
2016-05-16 23:03:55 +00:00
tags.all?(&:delete)
end
end
end