Implement the new OCI-based registry data model
Note that this change does *not* enable the new data model by default, but does allow it to be used when a special environment variable is specified.
This commit is contained in:
parent
924b386437
commit
fdcb8bad23
23 changed files with 1847 additions and 209 deletions
31
initdb.py
31
initdb.py
|
@ -21,10 +21,11 @@ from data.database import (db, all_models, Role, TeamRole, Visibility, LoginServ
|
|||
ServiceKeyApprovalType, MediaType, LabelSourceType, UserPromptKind,
|
||||
RepositoryKind, User, DisableReason, DeletedNamespace, appr_classes,
|
||||
ApprTagKind, ApprBlobPlacementLocation, Repository, TagKind,
|
||||
ManifestChild)
|
||||
ManifestChild, TagToRepositoryTag, get_epoch_timestamp_ms)
|
||||
from data import model
|
||||
from data.queue import WorkQueue
|
||||
from data.registry_model import registry_model
|
||||
from data.registry_model.registry_pre_oci_model import pre_oci_model
|
||||
from app import app, storage as store, tf
|
||||
from storage.basestorage import StoragePaths
|
||||
from image.docker.schema1 import DOCKER_SCHEMA1_CONTENT_TYPES
|
||||
|
@ -136,23 +137,25 @@ def __create_subtree(with_storage, repo, structure, creator_username, parent, ta
|
|||
|
||||
repo_ref = registry_model.lookup_repository(repo.namespace_user.username, repo.name)
|
||||
for tag_name in last_node_tags:
|
||||
new_tag = model.tag.create_or_update_tag(repo.namespace_user.username, repo.name, tag_name,
|
||||
new_image.docker_image_id)
|
||||
adjusted_tag_name = tag_name
|
||||
now_ms = None
|
||||
if tag_name[0] == '#':
|
||||
adjusted_tag_name = tag_name[1:]
|
||||
now_ms = get_epoch_timestamp_ms() - 1000
|
||||
|
||||
new_tag = model.tag.create_or_update_tag(repo.namespace_user.username, repo.name,
|
||||
adjusted_tag_name,
|
||||
new_image.docker_image_id,
|
||||
now_ms=now_ms)
|
||||
|
||||
derived = model.image.find_or_create_derived_storage(new_tag, 'squash', 'local_us')
|
||||
model.storage.find_or_create_storage_signature(derived, 'gpg2')
|
||||
|
||||
tag = registry_model.get_repo_tag(repo_ref, tag_name)
|
||||
registry_model.backfill_manifest_for_tag(tag)
|
||||
tag = pre_oci_model.get_repo_tag(repo_ref, adjusted_tag_name)
|
||||
assert tag._db_id == new_tag.id
|
||||
assert pre_oci_model.backfill_manifest_for_tag(tag)
|
||||
tag_map[tag_name] = new_tag
|
||||
|
||||
for tag_name in last_node_tags:
|
||||
if tag_name[0] == '#':
|
||||
found_tag = tag_map[tag_name]
|
||||
found_tag.name = tag_name[1:]
|
||||
found_tag.lifetime_end_ts = tag_map[tag_name[1:]].lifetime_start_ts
|
||||
found_tag.lifetime_start_ts = found_tag.lifetime_end_ts - 10
|
||||
found_tag.save()
|
||||
|
||||
for subtree in subtrees:
|
||||
__create_subtree(with_storage, repo, subtree, creator_username, new_image, tag_map)
|
||||
|
||||
|
@ -592,7 +595,7 @@ def populate_database(minimal=False, with_storage=False):
|
|||
(1, [], None)], None)], None))
|
||||
|
||||
__generate_repository(with_storage, new_user_1, 'history', 'Historical repository.', False,
|
||||
[], (4, [(2, [], 'latest'), (3, [], '#latest')], None))
|
||||
[], (4, [(2, [], '#latest'), (3, [], 'latest')], None))
|
||||
|
||||
__generate_repository(with_storage, new_user_1, 'complex',
|
||||
'Complex repository with many branches and tags.',
|
||||
|
|
Reference in a new issue