Update Composition Functions content to v1beta1

This updates all current documentation of Composition Functions in the
master directory to reflect the new v1beta1 implementation.

Signed-off-by: Nic Cope <nicc@rk0n.org>
This commit is contained in:
Nic Cope 2023-10-24 23:10:04 -07:00
parent 2370e5bbc1
commit 9179d8c030
1 changed files with 50 additions and 27 deletions

View File

@ -41,8 +41,8 @@ Optionally, Compositions also support:
* [Modifying and patching](#changing-resource-fields) resource settings. * [Modifying and patching](#changing-resource-fields) resource settings.
* [Storing connection details](#storing-connection-details) and secrets * [Storing connection details](#storing-connection-details) and secrets
generated by the managed resources. generated by the managed resources.
* Using [Composition functions](#composition-functions) to allow custom * Using [Composition Functions](#use-composition-functions) to template
programs to run alongside the Composition. resources using custom programs.
* Creating a * Creating a
[custom check of when a resource is ready](#resource-readiness-checks) [custom check of when a resource is ready](#resource-readiness-checks)
to use. to use.
@ -664,40 +664,59 @@ spec:
The [EnvironmentConfigs]({{<ref "./environment-configs" >}}) page has The [EnvironmentConfigs]({{<ref "./environment-configs" >}}) page has
more information on EnvironmentConfigs options and usage. more information on EnvironmentConfigs options and usage.
### Composition functions ### Use Composition Functions
Composition functions (`XFNs`) are containers executing any code you define. Composition functions (or just Functions, for short) are custom programs that
Composition functions can read and write to any resource in the Composition template Crossplane resources. You can write a Function to template resources
they're attached to. This allows composition functions to perform complex using a general purpose programming language like Go or Python. Using a general
operations to patch fields, determine if a resource is ready for use or notify purpose programming language allows a Function to use more advanced logic to
an external system about the details of resource. template resources, like loops and conditionals.
{{<hint "important" >}} {{<hint "important" >}}
Composition functions are an alpha feature. Alpha features aren't enabled by Composition functions are a beta feature.
default.
{{< /hint >}} {{< /hint >}}
To attach a composition function to a Composition define a To use composition functions define a {{<hover label="xfn"
{{<hover label="xfn" line="7">}}function{{</hover>}} inside the Composition line="7">}}pipeline{{</hover>}} of steps inside the Composition {{<hover
{{<hover label="xfn" line="4">}}spec{{</hover>}}. label="xfn" line="4">}}spec{{</hover>}}. Each {{<hover label="xfn"
line="8">}}step{{</hover>}} calls a Function. You can't specify resource
templates using the `resources` field when you specify a pipeline of Functions.
You must set the Composition {{<hover label="xfn" line="6">}}mode{{</hover>}} to
`Pipeline` to use Functions.
Provide a {{<hover label="xfn" line="8">}}name{{</hover>}} for the function. Each {{<hover label="xfn" line="8">}}step{{</hover>}} must specify the {{<hover
The {{<hover label="xfn" line="9">}}type{{</hover>}} is always `Container`. label="xfn" line="10">}}name{{</hover>}} of the Function to call. Some Functions
The {{<hover label="xfn" line="11">}}container.image{{</hover>}} is the also allow you to specify an {{<hover label="xfn" line="11">}}input{{</hover>}}.
location of the composition function container image. Different Functions each have a different {{<hover label="xfn"
line="13">}}kind{{</hover>}} of input.
This example uses Function Patch and Transform. Function Patch and Transform is
a Function that implements Crossplane resource templates. You can use Function
Patch and Transform to specify resource templates in a pipeline with other
Functions.
```yaml {label="xfn",copy-lines="none"} ```yaml {label="xfn",copy-lines="none"}
apiVersion: apiextensions.crossplane.io/v1 apiVersion: apiextensions.crossplane.io/v1
kind: Composition kind: Composition
# Removed for Brevity # Removed for Brevity
spec: spec:
resources:
# Removed for Brevity # Removed for Brevity
functions: mode: Pipeline
- name: rds-instance-password pipeline:
type: Container - step: patch-and-transform
container: functionRef:
image: xpkg.upbound.io/provider-aws-xfns/random-rds-password:v0.1.0 name: function-patch-and-transform
input:
apiVersion: pt.fn.crossplane.io/v1beta1
kind: Resources
resources:
- name: storage-bucket
base:
apiVersion: s3.aws.upbound.io/v1beta1
kind: Bucket
spec:
forProvider:
region: "us-east-2"
``` ```
Read the [composition functions]({{<ref "./composition-functions">}}) page for Read the [composition functions]({{<ref "./composition-functions">}}) page for
@ -1293,6 +1312,9 @@ Composition.
When creating a Composition Crossplane automatically validates specific When creating a Composition Crossplane automatically validates specific
parameters in the Composition. parameters in the Composition.
If using `mode: Resources`:
* The `resources` field isn't empty.
* All resources either use a `name` or don't. Compositions can't use both named * All resources either use a `name` or don't. Compositions can't use both named
and unnamed resources. and unnamed resources.
* No duplicate resource names. * No duplicate resource names.
@ -1303,10 +1325,11 @@ parameters in the Composition.
* Readiness checks using `matchString` aren't empty. * Readiness checks using `matchString` aren't empty.
* Readiness checks using `matchInteger` isn't `0`. * Readiness checks using `matchInteger` isn't `0`.
* Readiness checks requiring a `fieldPath` value provide it. * Readiness checks requiring a `fieldPath` value provide it.
* If using composition functions, all resources must have names.
* Composition function container field isn't empty. If using `mode: Pipeline` (Composition Functions):
* Composition function `type` is `container`.
* Composition function names are unique. * The `pipeline` field isn't empty.
* No duplicate step names.
### Resource schema validation ### Resource schema validation
<!-- vale write-good.TooWordy = NO --> <!-- vale write-good.TooWordy = NO -->