2016-05-09 15:14:46 -04:00
|
|
|
module ContainerRegistry
|
2016-05-04 08:22:54 -04:00
|
|
|
class Repository
|
|
|
|
attr_reader :registry, :name
|
|
|
|
|
2016-05-17 14:20:11 -04:00
|
|
|
delegate :client, to: :registry
|
|
|
|
|
2016-05-04 08:22:54 -04:00
|
|
|
def initialize(registry, name)
|
|
|
|
@registry, @name = registry, name
|
|
|
|
end
|
|
|
|
|
2016-05-09 15:27:06 -04:00
|
|
|
def path
|
|
|
|
[registry.path, name].compact.join('/')
|
|
|
|
end
|
|
|
|
|
2016-05-17 14:20:11 -04:00
|
|
|
def tag(tag)
|
2016-05-09 15:14:46 -04:00
|
|
|
ContainerRegistry::Tag.new(self, tag)
|
2016-05-04 08:22:54 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def manifest
|
|
|
|
return @manifest if defined?(@manifest)
|
2016-05-17 10:41:47 -04:00
|
|
|
|
2016-05-04 08:22:54 -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
|
|
|
|
2016-05-04 08:22:54 -04:00
|
|
|
@tags = manifest['tags'].map do |tag|
|
2016-05-09 15:14:46 -04:00
|
|
|
ContainerRegistry::Tag.new(self, tag)
|
2016-05-04 08:22:54 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-05-17 14:20:11 -04:00
|
|
|
def blob(config)
|
|
|
|
ContainerRegistry::Blob.new(self, config)
|
|
|
|
end
|
|
|
|
|
2016-05-04 08:35:18 -04:00
|
|
|
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)
|
2016-05-04 08:22:54 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|