You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/guides/commands.md
+4-2
Original file line number
Diff line number
Diff line change
@@ -6,16 +6,18 @@ Creates a new Function project at _`path`_. If _`path`_ is unspecified, assumes
6
6
7
7
Function name must consist of lower case alphanumeric characters or '-', and must start and end with an alphanumeric character (e.g. 'my-name', or '123-abc', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?').
8
8
9
+
The files written upon create include an example Function of the specified language runtime, example tests, and a metadata file `func.yaml`. Together, these are referred to as a Template. Included are the templates 'http' and 'events' (default is 'http') for each language runtime. A template can be pulled from a specific Git repository by providing the `--repository` flag, or from a locally installed repository using the repository's name as a prefix. See the [Templates Guide](templates.md) for more information.
A Language Pack is the mechanism by which the Functions binary can be extended to support additional runtimes, function signatures, even operating systems and installed tooling for a function. A Language Pack includes
4
+
- a .builders.yaml file containing a reference to a builder OCI image reference, which conforms to the buildpack builder specification, and contains references to buildpacks supporting this Language Pack
5
+
- one or more template directories illustrating the Language Pack's recognized function signatures
6
+
- tests and documentation for the templates
7
+
8
+
Built in to the Functions library is a basic language pack for each supported language.
9
+
10
+
For an example external language pack, see [https://github.com/lance/gcf-kn/tree/main/ruby]
When a Function is created, an example implementation and a Function metadata file are written into the new Function's working directory. Together, these files are referred to as the Function's Template. Included are the templates 'http' and 'events' for each supported language runtime.
4
+
5
+
These embedded templates are minimal by design. The Function contains a minimum of external dependencies, and the 'func.yaml' defines a final environment within which the Funciton will execute that is devoid of any extraneous packages or services.
6
+
7
+
To make use of more complex inital Function implementions, or to define runtime environments with arbitrarily complex requirements, the templates system is fully pluggable.
8
+
9
+
## External Git Repositories
10
+
11
+
When creating a new Function, a Git repository can be specified as the source for the template files. For example, the Boson Project maintains a set of example Functions at https://github.com/boson-project/templates which can be used during project creation.
12
+
13
+
For example, the Boson Project Templates repository contains an example "Hello World" Function implementation in each of the officially supported languages. To use this template via the CLI, use the flags:
Template Repositories can also be installed locally by placing them in the Functions configuration directory.
20
+
21
+
To install the Boson Project templates locally, for example, clone the repository and name it `boson` using `git clone https://github.com/boson-project/templats ~/.config/func/repositories/boson`
22
+
23
+
Once installed, the Boson Hello World template can be specified:
24
+
25
+
func create <name> --template boson/hello-world
26
+
27
+
## Language Packs
28
+
29
+
In addition to example implementations, a template includes a `func.yaml` which includes metadata about the Function. By default this is populated with things like the new Function's name. It also includes a reference to the specific tooling which compiles and packages the Function into its deployable form. This is called the Builder. By customizing this metadata, it is more than just a template; it is referred to as a Language Pack. See [Project Configuration with func.yaml](func_yaml.md).
30
+
31
+
A Language Pack can support additional function signatures and can fully customize the environment of the final running Function. For more information see the [Language Pack Guide](language-packs.md).
0 commit comments