Exemple #1
0
    def build(self):
        """
        Build the entire application

        Returns
        -------
        dict
            Returns the path to where each resource was built as a map of resource's LogicalId to the path string
        """

        result = {}

        for function in self._resources_to_build.functions:
            LOG.info("Building function '%s'", function.name)
            result[function.name] = self._build_function(
                function.name, function.codeuri, function.runtime,
                function.handler, function.metadata)
        for layer in self._resources_to_build.layers:
            LOG.info("Building layer '%s'", layer.name)
            if layer.build_method is None:
                raise MissingBuildMethodException(
                    f"Layer {layer.name} cannot be build without BuildMethod. Please provide BuildMethod in Metadata."
                )
            result[layer.name] = self._build_layer(layer.name, layer.codeuri,
                                                   layer.build_method,
                                                   layer.compatible_runtimes)

        return result
    def _collect_single_buildable_layer(
            self, resource_identifier: str,
            resource_collector: ResourcesToBuildCollector) -> None:
        """
        Populate resource_collector with layer with provided identifier.

        Parameters
        ----------
        resource_collector

        Returns
        -------

        """
        layer = self.layer_provider.get(resource_identifier)
        if not layer:
            # No layer found
            return
        if layer and layer.build_method is None:
            LOG.error("Layer %s is missing BuildMethod Metadata.",
                      self._function_provider)
            raise MissingBuildMethodException(
                f"Build method missing in layer {resource_identifier}.")

        resource_collector.add_layer(layer)
Exemple #3
0
    def build_single_layer_definition(
            self, layer_definition: LayerBuildDefinition) -> Dict[str, str]:
        """
        Build the unique definition and then copy the artifact to the corresponding layer folder
        """
        layer = layer_definition.layer
        LOG.info("Building layer '%s'", layer.full_path)
        if layer.build_method is None:
            raise MissingBuildMethodException(
                f"Layer {layer.full_path} cannot be build without BuildMethod. "
                f"Please provide BuildMethod in Metadata.")

        single_build_dir = layer.get_build_dir(self._build_dir)
        # when a layer is passed here, it is ZIP function, codeuri and runtime are not None
        # codeuri and compatible_runtimes are not None
        return {
            layer.full_path:
            self._build_layer(
                layer.name,
                layer.codeuri,  # type: ignore
                layer.build_method,
                layer.compatible_runtimes,  # type: ignore
                single_build_dir,
                layer_definition.env_vars,
            )
        }
 def build_single_layer_definition(self, layer_definition):
     """
     Build the unique definition and then copy the artifact to the corresponding layer folder
     """
     layer = layer_definition.layer
     LOG.info("Building layer '%s'", layer.name)
     if layer.build_method is None:
         raise MissingBuildMethodException(
             f"Layer {layer.name} cannot be build without BuildMethod. Please provide BuildMethod in Metadata.")
     return {layer.name: self._build_layer(layer.name,
                                           layer.codeuri,
                                           layer.build_method,
                                           layer.compatible_runtimes)}
    def build_single_layer_definition(self, layer_definition: LayerBuildDefinition) -> Dict[str, str]:
        """
        Build the unique definition and then copy the artifact to the corresponding layer folder
        """
        layer = layer_definition.layer
        LOG.info("Building layer '%s'", layer.full_path)
        if layer.build_method is None:
            raise MissingBuildMethodException(
                f"Layer {layer.full_path} cannot be build without BuildMethod. "
                f"Please provide BuildMethod in Metadata."
            )

        single_build_dir = layer.get_build_dir(self._build_dir)
        return {
            layer.full_path: self._build_layer(
                layer.name, layer.codeuri, layer.build_method, layer.compatible_runtimes, single_build_dir
            )
        }