data/registry_model/manifestbuilder.py
def start_layer(
        self, layer_id, v1_metadata_string, location_name, calling_user, temp_tag_expiration
    ):
        """
        Starts a new layer with the given ID to be placed into a manifest.

        Returns the layer started or None if an error occurred.
        """
        # Ensure the repository still exists.
        repository = model.repository.lookup_repository(self._repository_ref._db_id)
        if repository is None:
            return None

        namespace_name = repository.namespace_user.username
        repo_name = repository.name

        try:
            v1_metadata = json.loads(v1_metadata_string)
        except ValueError:
            logger.exception(
                "Exception when trying to parse V1 metadata JSON for layer %s", layer_id
            )
            return None
        except TypeError:
            logger.exception(
                "Exception when trying to parse V1 metadata JSON for layer %s", layer_id
            )
            return None

        # Sanity check that the ID matches the v1 metadata.
        if layer_id != v1_metadata["id"]:
            return None

        # Ensure the parent already exists in the repository.
        parent_id = v1_metadata.get("parent", None)
        parent_image = None

        if parent_id is not None:
            parent_image = model.image.get_repo_image(namespace_name, repo_name, parent_id)
            if parent_image is None:
                return None

        # Check to see if this layer already exists in the repository. If so, we can skip the creation.
        existing_image = registry_model.get_legacy_image(self._repository_ref, layer_id)
        if existing_image is not None:
            self._builder_state.images[layer_id] = existing_image.id
            self._save_to_session()
            return ManifestLayer(layer_id, v1_metadata_string, existing_image.id)

        with db_transaction():
            # Otherwise, create a new legacy image and point a temporary tag at it.
            created = model.image.find_create_or_link_image(
                layer_id, repository, calling_user, {}, location_name
            )
            temp_tag_name = model.tag.create_temporary_hidden_tag(
                repository, created, temp_tag_expiration
            )
            if temp_tag_name is None:
                return None

            # Save its V1 metadata.
            command_list = v1_metadata.get("container_config", {}).get("Cmd", None)
            command = json.dumps(command_list) if command_list else None

            model.image.set_image_metadata(
                layer_id,
                namespace_name,
                repo_name,
                v1_metadata.get("created"),
                v1_metadata.get("comment"),
                command,
                v1_metadata_string,
                parent=parent_image,
            )

        # Save the changes to the builder.
        self._builder_state.images[layer_id] = created.id
        self._save_to_session()

        return ManifestLayer(layer_id, v1_metadata_string, created.id)

        Starts a new layer with the given ID to be placed into a manifest.

        Returns the layer started or None if an error occurred.
        
Starts a new layer with the given ID to be placed into a manifest.
Returns the layer started or None if an error occurred.
Starts a new layer with the given ID to be placed into a manifest . Returns the layer started or None if an error occurred .
def start_layer(
        self, layer_id, v1_metadata_string, location_name, calling_user, temp_tag_expiration
    ):
        repository = model.repository.lookup_repository(self._repository_ref._db_id)
        if repository is None:
            return None
        namespace_name = repository.namespace_user.username
        repo_name = repository.name
        try:
            v1_metadata = json.loads(v1_metadata_string)
        except ValueError:
            logger.exception(
                "Exception when trying to parse V1 metadata JSON for layer %s", layer_id
            )
            return None
        except TypeError:
            logger.exception(
                "Exception when trying to parse V1 metadata JSON for layer %s", layer_id
            )
            return None
        if layer_id != v1_metadata["id"]:
            return None
        parent_id = v1_metadata.get("parent", None)
        parent_image = None
        if parent_id is not None:
            parent_image = model.image.get_repo_image(namespace_name, repo_name, parent_id)
            if parent_image is None:
                return None
        existing_image = registry_model.get_legacy_image(self._repository_ref, layer_id)
        if existing_image is not None:
            self._builder_state.images[layer_id] = existing_image.id
            self._save_to_session()
            return ManifestLayer(layer_id, v1_metadata_string, existing_image.id)
        with db_transaction():
            created = model.image.find_create_or_link_image(
                layer_id, repository, calling_user, {}, location_name
            )
            temp_tag_name = model.tag.create_temporary_hidden_tag(
                repository, created, temp_tag_expiration
            )
            if temp_tag_name is None:
                return None
            command_list = v1_metadata.get("container_config", {}).get("Cmd", None)
            command = json.dumps(command_list) if command_list else None
            model.image.set_image_metadata(
                layer_id,
                namespace_name,
                repo_name,
                v1_metadata.get("created"),
                v1_metadata.get("comment"),
                command,
                v1_metadata_string,
                parent=parent_image,
            )
        self._builder_state.images[layer_id] = created.id
        self._save_to_session()
        return ManifestLayer(layer_id, v1_metadata_string, created.id)
def start_layer ( self , layer_id , v1_metadata_string , location_name , calling_user , temp_tag_expiration ) : repository = model . repository . lookup_repository ( self . _repository_ref . _db_id ) if repository is None : return None namespace_name = repository . namespace_user . username repo_name = repository . name try : v1_metadata = json . loads ( v1_metadata_string ) except ValueError : logger . exception ( "Exception when trying to parse V1 metadata JSON for layer %s" , layer_id ) return None except TypeError : logger . exception ( "Exception when trying to parse V1 metadata JSON for layer %s" , layer_id ) return None if layer_id != v1_metadata [ "id" ] : return None parent_id = v1_metadata . get ( "parent" , None ) parent_image = None if parent_id is not None : parent_image = model . image . get_repo_image ( namespace_name , repo_name , parent_id ) if parent_image is None : return None existing_image = registry_model . get_legacy_image ( self . _repository_ref , layer_id ) if existing_image is not None : self . _builder_state . images [ layer_id ] = existing_image . id self . _save_to_session ( ) return ManifestLayer ( layer_id , v1_metadata_string , existing_image . id ) with db_transaction ( ) : created = model . image . find_create_or_link_image ( layer_id , repository , calling_user , { } , location_name ) temp_tag_name = model . tag . create_temporary_hidden_tag ( repository , created , temp_tag_expiration ) if temp_tag_name is None : return None command_list = v1_metadata . get ( "container_config" , { } ) . get ( "Cmd" , None ) command = json . dumps ( command_list ) if command_list else None model . image . set_image_metadata ( layer_id , namespace_name , repo_name , v1_metadata . get ( "created" ) , v1_metadata . get ( "comment" ) , command , v1_metadata_string , parent = parent_image , ) self . _builder_state . images [ layer_id ] = created . id self . _save_to_session ( ) return ManifestLayer ( layer_id , v1_metadata_string , created . id )
Starts a new layer with the given ID to be placed into a manifest.
Starts a new layer with the given ID to be placed into a manifest .
"""
        Starts a new layer with the given ID to be placed into a manifest.

        Returns the layer started or None if an error occurred.
        """ # Ensure the repository still exists. # Sanity check that the ID matches the v1 metadata. # Ensure the parent already exists in the repository. # Check to see if this layer already exists in the repository. If so, we can skip the creation. # Otherwise, create a new legacy image and point a temporary tag at it. # Save its V1 metadata. # Save the changes to the builder.
self
layer_id
v1_metadata_string
location_name
calling_user
temp_tag_expiration