Add support for retargeting a tag to all schema 1 manifests
Schema version 1 manifests contain the tag name, and we have a check to ensure we don't point a tag at a manifest with the wrong name embedded. However, this also means that we cannot retarget to that manifest, which will break the UI once we get rid of legacy images. This change means we can retarget to those manifests, and the OCI model does the work of rewriting the manifest when necessary.
This commit is contained in:
parent
a1caefcabe
commit
570d974067
3 changed files with 56 additions and 0 deletions
|
@ -342,6 +342,30 @@ def test_retarget_tag_history(use_manifest, registry_model):
|
|||
assert len(new_history) == len(history) + 1
|
||||
|
||||
|
||||
def test_retarget_tag_schema1(oci_model):
|
||||
repository_ref = oci_model.lookup_repository('devtable', 'simple')
|
||||
latest_tag = oci_model.get_repo_tag(repository_ref, 'latest')
|
||||
manifest = oci_model.get_manifest_for_tag(latest_tag)
|
||||
|
||||
existing_parsed = manifest.get_parsed_manifest()
|
||||
|
||||
# Retarget a new tag to the manifest.
|
||||
updated_tag = oci_model.retarget_tag(repository_ref, 'somenewtag', manifest, storage)
|
||||
assert updated_tag
|
||||
assert updated_tag.name == 'somenewtag'
|
||||
|
||||
updated_manifest = oci_model.get_manifest_for_tag(updated_tag)
|
||||
parsed = updated_manifest.get_parsed_manifest()
|
||||
assert parsed.namespace == 'devtable'
|
||||
assert parsed.repo_name == 'simple'
|
||||
assert parsed.tag == 'somenewtag'
|
||||
|
||||
assert parsed.layers == existing_parsed.layers
|
||||
|
||||
# Ensure the tag has changed targets.
|
||||
assert oci_model.get_repo_tag(repository_ref, 'somenewtag') == updated_tag
|
||||
|
||||
|
||||
def test_change_repository_tag_expiration(registry_model):
|
||||
repository_ref = registry_model.lookup_repository('devtable', 'simple')
|
||||
tag = registry_model.get_repo_tag(repository_ref, 'latest')
|
||||
|
|
Reference in a new issue