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 10:41:47 -04:00
@manifest = client.repository_tags(name)
end
def valid?
manifest.present?
end
def tags
return @tags if defined?(@tags)
2016-05-04 10:16:54 -04:00
return [] unless manifest && manifest['tags']
2016-05-12 14:03:04 -04: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 14:03:04 -04:00
2016-05-16 19:03:55 -04:00
tags.all?(&:delete)
end
end
end