Beispiel #1
0
    def create(self):
        """
        Builds a container image which is usually a data archive
        including container specific metadata.

        Image types which triggers this builder are:

        * image="docker"
        * image="oci"
        * image="appx"

        :return: result

        :rtype: instance of :class:`Result`
        """
        if not self.base_image:
            log.info('Setting up %s container', self.requested_container_type)
            container_setup = ContainerSetup(self.requested_container_type,
                                             self.root_dir,
                                             self.container_config)
            container_setup.setup()
        else:
            checksum = Checksum(self.base_image)
            if not checksum.matches(checksum.md5(), self.base_image_md5):
                raise KiwiContainerBuilderError(
                    'base image file {0} checksum validation failed'.format(
                        self.base_image))

        log.info('--> Creating container image')
        container_image = ContainerImage(self.requested_container_type,
                                         self.root_dir, self.container_config)
        self.filename = container_image.create(self.filename, self.base_image)
        self.result.verify_image_size(
            self.runtime_config.get_max_size_constraint(), self.filename)
        self.result.add(key='container',
                        filename=self.filename,
                        use_for_bundle=True,
                        compress=False,
                        shasum=True)
        self.result.add(key='image_packages',
                        filename=self.system_setup.export_package_list(
                            self.target_dir),
                        use_for_bundle=True,
                        compress=False,
                        shasum=False)
        self.result.add(key='image_changes',
                        filename=self.system_setup.export_package_changes(
                            self.target_dir),
                        use_for_bundle=True,
                        compress=True,
                        shasum=False)
        self.result.add(key='image_verified',
                        filename=self.system_setup.export_package_verification(
                            self.target_dir),
                        use_for_bundle=True,
                        compress=False,
                        shasum=False)
        return self.result
Beispiel #2
0
    def create(self):
        """
        Builds a container image which is usually a tarball including
        container specific metadata.

        Image types which triggers this builder are:

        * image="docker"

        :return: result

        :rtype: instance of :class:`Result`
        """
        if not self.base_image:
            log.info(
                'Setting up %s container', self.requested_container_type
            )
            container_setup = ContainerSetup(
                self.requested_container_type, self.root_dir,
                self.container_config
            )
            container_setup.setup()
        else:
            checksum = Checksum(self.base_image)
            if not checksum.matches(checksum.md5(), self.base_image_md5):
                raise KiwiContainerBuilderError(
                    'base image file {0} checksum validation failed'.format(
                        self.base_image
                    )
                )

        log.info(
            '--> Creating container image'
        )
        container_image = ContainerImage(
            self.requested_container_type, self.root_dir, self.container_config
        )
        self.filename = container_image.create(
            self.filename, self.base_image
        )
        self.result.verify_image_size(
            self.runtime_config.get_max_size_constraint(),
            self.filename
        )
        self.result.add(
            key='container',
            filename=self.filename,
            use_for_bundle=True,
            compress=False,
            shasum=True
        )
        self.result.add(
            key='image_packages',
            filename=self.system_setup.export_package_list(
                self.target_dir
            ),
            use_for_bundle=True,
            compress=False,
            shasum=False
        )
        self.result.add(
            key='image_verified',
            filename=self.system_setup.export_package_verification(
                self.target_dir
            ),
            use_for_bundle=True,
            compress=False,
            shasum=False
        )
        return self.result
 def test_container_image_oci(self, mock_oci):
     ContainerImage('oci', 'root_dir')
     mock_oci.assert_called_once_with('root_dir', None)
 def test_container_image_docker(self, mock_docker):
     ContainerImage('docker', 'root_dir')
     mock_docker.assert_called_once_with('root_dir', None)
 def test_container_image_not_implemented(self):
     ContainerImage('foo', 'root_dir')
Beispiel #6
0
 def test_container_image_not_implemented(self):
     with raises(KiwiContainerImageSetupError):
         ContainerImage('foo', 'root_dir')
Beispiel #7
0
 def test_container_image_oci(self, mock_oci):
     ContainerImage('oci', 'root_dir')
     mock_oci.assert_called_once_with(
         'root_dir', 'oci-archive', custom_args=None
     )
Beispiel #8
0
 def test_container_image_docker(self, mock_docker):
     ContainerImage('docker', 'root_dir')
     mock_docker.assert_called_once_with(
         'root_dir', 'docker-archive', custom_args=None
     )
Beispiel #9
0
 def test_container_image_appx(self, mock_appx):
     ContainerImage.new('appx', 'root_dir')
     mock_appx.assert_called_once_with('root_dir', None)
Beispiel #10
0
 def test_container_image_appx(self, mock_appx):
     ContainerImage('appx', 'root_dir')
     mock_appx.assert_called_once_with('root_dir', custom_args=None)