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
def test_container_not_implemented(self): with raises(KiwiContainerSetupError): ContainerSetup('foo', 'root_dir')
def test_container_oci(self, mock_oci): ContainerSetup('oci', 'root_dir') mock_oci.assert_called_once_with('root_dir', None)
def test_container_docker(self, mock_docker): ContainerSetup('docker', 'root_dir') mock_docker.assert_called_once_with('root_dir', None)
def test_container_not_implemented(self): ContainerSetup('foo', 'root_dir')
def test_container_appx(self, mock_appx): ContainerSetup('appx', 'root_dir') mock_appx.assert_called_once_with('root_dir', None)