2016-05-09 15:14:46 -04:00
|
|
|
module ContainerRegistry
|
2016-05-04 08:22:54 -04:00
|
|
|
class Blob
|
|
|
|
attr_reader :repository, :config
|
|
|
|
|
2016-05-17 14:20:11 -04:00
|
|
|
delegate :registry, :client, to: :repository
|
|
|
|
|
2016-05-04 08:22:54 -04:00
|
|
|
def initialize(repository, config)
|
|
|
|
@repository = repository
|
|
|
|
@config = config || {}
|
|
|
|
end
|
|
|
|
|
|
|
|
def valid?
|
|
|
|
digest.present?
|
|
|
|
end
|
|
|
|
|
2016-05-09 15:27:06 -04:00
|
|
|
def path
|
|
|
|
"#{repository.path}@#{digest}"
|
|
|
|
end
|
|
|
|
|
2016-05-04 08:22:54 -04:00
|
|
|
def digest
|
|
|
|
config['digest']
|
|
|
|
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
|