d598e4fd93
Enables frozen for the following: * lib/*.rb * lib/banzai/**/*.rb * lib/bitbucket/**/*.rb * lib/constraints/**/*.rb * lib/container_registry/**/*.rb * lib/declarative_policy/**/*.rb Partially addresses #47424.
50 lines
799 B
Ruby
50 lines
799 B
Ruby
# frozen_string_literal: true
|
|
|
|
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
|
|
config['digest'] || config['blobSum']
|
|
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.path, digest)
|
|
end
|
|
|
|
def data
|
|
@data ||= client.blob(repository.path, digest, type)
|
|
end
|
|
end
|
|
end
|