2016-06-02 11:05:42 +05:30
|
|
|
module ContainerRegistry
|
|
|
|
class Blob
|
|
|
|
attr_reader :repository, :config
|
|
|
|
|
|
|
|
delegate :registry, :client, to: :repository
|
|
|
|
|
|
|
|
def initialize(repository, config)
|
|
|
|
@repository = repository
|
|
|
|
@config = config || {}
|
|
|
|
end
|
|
|
|
|
|
|
|
def valid?
|
|
|
|
digest.present?
|
|
|
|
end
|
|
|
|
|
|
|
|
def path
|
|
|
|
"#{repository.path}@#{digest}"
|
|
|
|
end
|
|
|
|
|
|
|
|
def digest
|
2016-06-16 23:09:34 +05:30
|
|
|
config['digest'] || config['blobSum']
|
2016-06-02 11:05:42 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def type
|
|
|
|
config['mediaType']
|
|
|
|
end
|
|
|
|
|
|
|
|
def size
|
|
|
|
config['size']
|
|
|
|
end
|
|
|
|
|
|
|
|
def revision
|
|
|
|
digest.split(':')[1]
|
|
|
|
end
|
|
|
|
|
|
|
|
def short_revision
|
|
|
|
revision[0..8]
|
|
|
|
end
|
|
|
|
|
|
|
|
def delete
|
|
|
|
client.delete_blob(repository.name, digest)
|
|
|
|
end
|
|
|
|
|
|
|
|
def data
|
|
|
|
@data ||= client.blob(repository.name, digest, type)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|