Пример #1
0
def test_get_image_upload_filename(path, image_type, expected):
    metadata = {
        'path': path,
        'type': image_type,
    }
    if expected is None:
        with pytest.raises(ValueError):
            get_image_upload_filename(metadata, 'XXX', 'x86_64')
    else:
        assert get_image_upload_filename(metadata, 'XXX', 'x86_64') == expected
Пример #2
0
def test_get_image_upload_filename(path, image_type, expected):
    metadata = {
        'path': path,
        'type': image_type,
    }
    if expected is None:
        with pytest.raises(ValueError):
            get_image_upload_filename(metadata, 'XXX', 'x86_64')
    else:
        assert get_image_upload_filename(metadata, 'XXX', 'x86_64') == expected
    def get_image_output(self, arch):
        """
        Create the output for the image

        This is the Koji Content Generator metadata, along with the
        'docker save' output to upload.

        For metadata-only builds, an empty file is used instead of the
        output of 'docker save'.

        :param arch: str, architecture for this output
        :return: tuple, (metadata dict, Output instance)

        """

        saved_image = self.workflow.exported_image_sequence[-1].get('path')
        image_name = get_image_upload_filename(self.workflow.exported_image_sequence[-1],
                                               self.workflow.builder.image_id,
                                               arch)
        if self.metadata_only:
            metadata = self.get_output_metadata(os.path.devnull, image_name)
            output = Output(file=None, metadata=metadata)
        else:
            metadata = self.get_output_metadata(saved_image, image_name)
            output = Output(file=open(saved_image), metadata=metadata)

        return metadata, output
    def get_image_output(self, arch):
        """
        Create the output for the image

        This is the Koji Content Generator metadata, along with the
        'docker save' output to upload.

        For metadata-only builds, an empty file is used instead of the
        output of 'docker save'.

        :param arch: str, architecture for this output
        :return: tuple, (metadata dict, Output instance)

        """

        saved_image = self.workflow.exported_image_sequence[-1].get('path')
        image_name = get_image_upload_filename(
            self.workflow.exported_image_sequence[-1],
            self.workflow.builder.image_id, arch)
        if self.metadata_only:
            metadata = self.get_output_metadata(os.path.devnull, image_name)
            output = Output(file=None, metadata=metadata)
        else:
            metadata = self.get_output_metadata(saved_image, image_name)
            output = Output(file=open(saved_image), metadata=metadata)

        return metadata, output
Пример #5
0
def get_image_output(workflow, image_id, arch):
    """
    Create the output for the image

    This is the Koji Content Generator metadata, along with the
    'docker save' output to upload.

    :return: tuple, (metadata dict, Output instance)

    """
    saved_image = workflow.exported_image_sequence[-1].get('path')
    image_name = get_image_upload_filename(
        workflow.exported_image_sequence[-1], image_id, arch)

    metadata = get_output_metadata(saved_image, image_name)
    output = Output(file=open(saved_image), metadata=metadata)

    return metadata, output
    def get_image_output(self):
        """
        Create the output for the image

        This is the Koji Content Generator metadata, along with the
        'docker save' output to upload.

        :return: tuple, (metadata dict, Output instance)

        """

        saved_image = self.workflow.exported_image_sequence[-1].get('path')
        image_name = get_image_upload_filename(self.workflow.exported_image_sequence[-1],
                                               self.workflow.builder.image_id,
                                               self.platform)
        metadata = self.get_output_metadata(saved_image, image_name)
        output = Output(file=open(saved_image), metadata=metadata)

        return metadata, output
Пример #7
0
def get_image_output(image_type, image_id, arch, pullspec):
    """
    Create the output for the image

    This is the Koji Content Generator metadata, along with the
    'docker save' output to upload.

    :return: tuple, (metadata dict, Output instance)

    """
    # OSBS2 TBD exported_image_sequence will not work for multiple platform
    image_name = get_image_upload_filename(image_type, image_id, arch)

    readme_content = ('Archive is just a placeholder for the koji archive, if you need the '
                      f'content you can use pullspec of the built image: {pullspec}')
    archive_path = create_tar_gz_archive(file_name='README', file_content=readme_content)
    logger.info('Archive for metadata created: %s', archive_path)

    metadata = get_output_metadata(archive_path, image_name)
    output = Output(filename=archive_path, metadata=metadata)

    return metadata, output