-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathcomposition-pipeline-context.yaml
100 lines (100 loc) · 3.23 KB
/
composition-pipeline-context.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
apiVersion: apiextensions.crossplane.io/v1
kind: Composition
metadata:
name: xcidrs.platform.upbound.io
spec:
compositeTypeRef:
apiVersion: platform.upbound.io/v1alpha1
kind: XCIDR
mode: Pipeline
pipeline:
- step: pull-extra-resources
functionRef:
name: function-extra-resources
input:
apiVersion: extra-resources.fn.crossplane.io/v1beta1
kind: Input
spec:
extraResources:
- kind: XCluster
into: XCluster
apiVersion: example.crossplane.io/v1
type: Selector
selector:
maxMatch: 2
minMatch: 1
matchLabels:
- key: type
type: Value
value: cluster
- step: debug-context
functionRef:
name: function-go-templating
input:
apiVersion: gotemplate.fn.crossplane.io/v1beta1
kind: GoTemplate
source: Inline
inline:
template: |
apiVersion: test.my-domain.com/v1alpha1
kind: DebugContext
metadata:
annotations:
gotemplating.fn.crossplane.io/composition-resource-name: debug-context
debug:
{{ . | toYaml | nindent 2 }}
- step: cidr-subnets-partitions
functionRef:
name: upbound-function-cidr
input:
apiVersion: cidr.fn.crossplane.io/v1beta1
kind: Parameters
cidrFunc: cidrsubnets
prefixField: context.apiextensions\.crossplane\.io/extra-resources.XCluster.0.spec.cidrBlock
newBits:
- 1
- 1
outputField: status.atFunction.cidr.partitions
- step: cidr-subnets-private
functionRef:
name: upbound-function-cidr
input:
apiVersion: cidr.fn.crossplane.io/v1beta1
kind: Parameters
cidrFunc: cidrsubnets
prefixField: desired.composite.resource.status.atFunction.cidr.partitions[0]
newBits:
- 1
- 1
outputField: status.atFunction.cidr.private.subnets
- step: cidr-subnets-public
functionRef:
name: upbound-function-cidr
input:
apiVersion: cidr.fn.crossplane.io/v1beta1
kind: Parameters
cidrFunc: cidrsubnets
prefixField: desired.composite.resource.status.atFunction.cidr.partitions[1]
newBits:
- 1
- 1
outputField: status.atFunction.cidr.public.subnets
# To debug the pipeline output you can generate a new resource which contains all attributes. Make sure to add function-go-templating to functions.yaml.
- step: render-templates
functionRef:
name: function-go-templating
input:
apiVersion: gotemplate.fn.crossplane.io/v1beta1
kind: GoTemplate
source: Inline
inline:
template: |
apiVersion: test.my-domain.com/v1alpha1
kind: DebugResource
metadata:
annotations:
gotemplating.fn.crossplane.io/composition-resource-name: debug
debug:
{{ . | toYaml | nindent 2 }}
debugValue:
{{ index .desired.composite.resource.status.atFunction.cidr.public.subnets 0 | nindent 2 }}