Commit e1c8663a authored by Kamil Trzcinski's avatar Kamil Trzcinski

Allow to copy all manifests from one container repository to another

parent 7168493e
......@@ -43,5 +43,9 @@ module ImageRegistry
return @data if defined?(@data)
@data ||= client.blob(repository.name, digest, type)
end
def mount_to(to_repository)
client.repository_mount_blob(to_repository.name, digest, repository.name)
end
end
end
......@@ -39,7 +39,7 @@ module ImageRegistry
end
def repository_mount_blob(name, digest, from)
@faraday.post("/v2/#{name}/blobls/uploads/?mount=#{digest}&from=#{from}").status == 201
@faraday.post("/v2/#{name}/blobs/uploads/?mount=#{digest}&from=#{from}").status == 201
end
def repository_tag_digest(name, reference)
......
......@@ -29,11 +29,27 @@ module ImageRegistry
@tags = manifest['tags'].map do |tag|
ImageRegistry::Tag.new(self, tag)
end
@tags ||= []
end
def delete_tags
return unless tags
tags.each(:delete)
end
def mount_blob(blob)
return unless blob
client.repository_mount_blob(name, blob.digest, blob.repository.name)
end
def mount_manifest(tag, manifest)
client.put_repository_manifest(name, tag, manifest)
end
def copy_to(other_repository)
tags.all? do |tag|
tag.copy_to(other_repository)
end
end
end
end
......@@ -25,11 +25,15 @@ module ImageRegistry
@digest = client.repository_tag_digest(repository.name, name)
end
def config
return @config if defined?(@config)
def config_blob
return @config_blob if defined?(@config_blob)
return unless manifest && manifest['config']
blob = ImageRegistry::Blob.new(repository, manifest['config'])
@config = ImageRegistry::Config.new(self, blob)
@config_blob = ImageRegistry::Blob.new(repository, manifest['config'])
end
def config
return unless config_blob
@config ||= ImageRegistry::Config.new(self, config_blob)
end
def created_at
......@@ -55,6 +59,15 @@ module ImageRegistry
client.delete_repository_tag(repository.name, digest)
end
def copy_to(repository)
return unless manifest
layers.each do |blob|
repository.mount_blob(blob)
end
repository.mount_blob(config_blob)
repository.mount_manifest(name, manifest.to_json)
end
def client
@client ||= repository.client
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment