Exemplo n.º 1
0
    def get(self, namespace, repository, tag, parsed_args):
        """
        List the images for the specified repository tag.
        """
        repo_ref = registry_model.lookup_repository(namespace, repository)
        if repo_ref is None:
            raise NotFound()

        tag_ref = registry_model.get_repo_tag(repo_ref,
                                              tag,
                                              include_legacy_image=True)
        if tag_ref is None:
            raise NotFound()

        if tag_ref.legacy_image_if_present is None:
            return {"images": []}

        image_id = tag_ref.legacy_image.docker_image_id

        all_images = None
        if parsed_args["owned"]:
            # TODO: Remove the `owned` image concept once we are fully on V2_2.
            all_images = registry_model.get_legacy_images_owned_by_tag(tag_ref)
        else:
            image_with_parents = registry_model.get_legacy_image(
                repo_ref, image_id, include_parents=True)
            if image_with_parents is None:
                raise NotFound()

            all_images = [image_with_parents] + image_with_parents.parents

        return {
            "images": [image_dict(image) for image in all_images],
        }
Exemplo n.º 2
0
def _manifest_dict(manifest):
    image = None
    if manifest.legacy_image_if_present is not None:
        image = image_dict(manifest.legacy_image, with_history=True)

    layers = None
    if not manifest.is_manifest_list:
        layers = registry_model.list_manifest_layers(manifest, storage)
        if layers is None:
            logger.debug('Missing layers for manifest `%s`', manifest.digest)
            abort(404)

    return {
        'digest':
        manifest.digest,
        'is_manifest_list':
        manifest.is_manifest_list,
        'manifest_data':
        manifest.internal_manifest_bytes.as_unicode(),
        'image':
        image,
        'layers':
        ([_layer_dict(lyr.layer_info, idx)
          for idx, lyr in enumerate(layers)] if layers else None),
    }