|
| 1 | +# Example multistep pipeline |
| 2 | + |
| 3 | +Example Functions Pipeline with the 3 steps: |
| 4 | + |
| 5 | + |
| 6 | +1. function-patch-and-transform |
| 7 | +2. function-go-templating |
| 8 | +3. function-patch-and-transform again |
| 9 | + |
| 10 | +The more details mechanics of each step described below |
| 11 | + |
| 12 | +1. function-patch-and-transform creates `bucket` |
| 13 | +2. function-go-templating creates `bucketACL` and uses the data from the |
| 14 | + previous pipelines step to compose the resource spec |
| 15 | +``` |
| 16 | + region: {{ .desired.resources.bucket.resource.spec.forProvider.region }} |
| 17 | +``` |
| 18 | +3. function-patch-and-transform is used again to patch the `bucketACL` with the |
| 19 | + data from XR spec. Notice that `base` is omitted and resource `name` is |
| 20 | +matching the one that is set by the function-go-templating with `{{ setResourceNameAnnotation "bucketACL" }}` |
| 21 | + |
| 22 | +To render `make render` target is available: |
| 23 | + |
| 24 | +``` |
| 25 | +crossplane beta render xr.yaml composition.yaml functions.yaml -r |
| 26 | +--- |
| 27 | +apiVersion: example.crossplane.io/v1 |
| 28 | +kind: XR |
| 29 | +metadata: |
| 30 | + name: example-xr |
| 31 | +status: |
| 32 | + conditions: |
| 33 | + - lastTransitionTime: "2024-01-01T00:00:00Z" |
| 34 | + message: 'Unready resources: bucket, bucketACL' |
| 35 | + reason: Creating |
| 36 | + status: "False" |
| 37 | + type: Ready |
| 38 | +--- |
| 39 | +apiVersion: s3.aws.upbound.io/v1beta1 |
| 40 | +kind: Bucket |
| 41 | +metadata: |
| 42 | + annotations: |
| 43 | + crossplane.io/composition-resource-name: bucket |
| 44 | + generateName: example-xr- |
| 45 | + labels: |
| 46 | + crossplane.io/composite: example-xr |
| 47 | + ownerReferences: |
| 48 | + - apiVersion: example.crossplane.io/v1 |
| 49 | + blockOwnerDeletion: true |
| 50 | + controller: true |
| 51 | + kind: XR |
| 52 | + name: example-xr |
| 53 | + uid: "" |
| 54 | +spec: |
| 55 | + forProvider: |
| 56 | + region: eu-north-1 |
| 57 | +--- |
| 58 | +apiVersion: s3.aws.upbound.io/v1beta1 |
| 59 | +kind: BucketACL |
| 60 | +metadata: |
| 61 | + annotations: |
| 62 | + crossplane.io/composition-resource-name: bucketACL |
| 63 | + generateName: example-xr- |
| 64 | + labels: |
| 65 | + crossplane.io/composite: example-xr |
| 66 | + ownerReferences: |
| 67 | + - apiVersion: example.crossplane.io/v1 |
| 68 | + blockOwnerDeletion: true |
| 69 | + controller: true |
| 70 | + kind: XR |
| 71 | + name: example-xr |
| 72 | + uid: "" |
| 73 | +spec: |
| 74 | + forProvider: |
| 75 | + acl: private |
| 76 | + bucketSelector: |
| 77 | + matchControllerRef: true |
| 78 | + region: eu-north-1 |
| 79 | +``` |
| 80 | + |
| 81 | +Notice that `BucketACL` is patched as expected |
| 82 | + |
| 83 | +``` |
| 84 | +spec: |
| 85 | + forProvider: |
| 86 | + acl: private # acl value that is set on 3rd pipeline step is in place |
| 87 | + bucketSelector: |
| 88 | + matchControllerRef: true |
| 89 | + region: eu-north-1 # region value that is set on 2nd pipeline step is in place |
| 90 | +``` |
0 commit comments