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
Notice that it looks very similar to native P&T. The difference is that
49
-
everything is under `spec.pipeline[0].input.resources`, not `spec.resources`.
50
-
This is the Function's input.
42
+
Using the following XR and RunFunctionRequest inputs (click to expand):
43
+
<details>
51
44
52
-
## Okay, but why?
45
+
```yaml
46
+
apiVersion: nopexample.org/v1alpha1
47
+
kind: XNopResource
48
+
metadata:
49
+
name: test-resource
50
+
spec:
51
+
env: dev
52
+
render: true
53
+
```
53
54
54
-
There are a lot of good reasons to use a function to use a function to do P&T
55
-
composition. In fact, it's so compelling that the Crossplane maintainers are
56
-
considering deprecating native P&T. See Crossplane issue [#4746] for details.
55
+
```json
56
+
{
57
+
"desired": {
58
+
"composite": {
59
+
"resource": {
60
+
"apiVersion": "nopexample.org/v1alpha1",
61
+
"kind": "XNopResource",
62
+
"metadata": {
63
+
"name": "test-resource"
64
+
},
65
+
"spec": {
66
+
"env": "dev",
67
+
"render": true
68
+
}
69
+
}
70
+
},
71
+
"resources": {
72
+
"test": {
73
+
"resource": {
74
+
"apiVersion": "example.org/v1",
75
+
"kind": "CD",
76
+
"metadata": {
77
+
"name": "cool-42",
78
+
"namespace": "default"
79
+
}
80
+
}
81
+
}
82
+
}
83
+
},
84
+
"observed": {
85
+
"composite": {
86
+
"resource": {
87
+
"apiVersion": "nopexample.org/v1alpha1",
88
+
"kind": "XNopResource",
89
+
"metadata": {
90
+
"name": "test-resource"
91
+
},
92
+
"spec": {
93
+
"env": "dev",
94
+
"render": true
95
+
},
96
+
"status": {
97
+
"id": "123",
98
+
"ready": false
99
+
}
100
+
}
101
+
}
102
+
}
103
+
}
104
+
```
57
105
58
-
### Mix and match P&T with other functions
106
+
</details>
59
107
60
-
With this function you can use P&T with other functions. For example you can
61
-
create a desired resource using the [Go Templating][fn-go-templating] function,
62
-
then patch the result using this function.
63
108
64
-
It's not just patches either. You can use P&T to derive composite resource
65
-
connection details from a resource produced by another function, or use it to
66
-
determine whether a resource produced by another function is ready
109
+
You can use the [CEL Playground](https://playcel.undistro.io/?content=H4sIAAAAAAAAA%2B1UPW%2FDIBT8K4g5SeW0U9Z27tCh6sDyYl5aVAwIsNUq8n%2BvMY4dGxx16dYNuON93D04Uw4e6IGemSKEMMrRCYuc0QOJR%2F1pqSujnfA4O%2B8hi07XtkyQHgQjXtE6oVWAGVXa4BdURuJO2%2Fe7pgBpPqBgdLO8%2BSkUj3fenrV5GZMkxAo9hB4y%2BXtcQYUxkEfnt1O5c26bBHYGy7WgqJoYk2OT1DTIojjaQPK2xkWuq%2B24ngqYNHWp3KGJrNQ3fCA5K%2BY%2B5JuYTHh8yjNuq0%2FmBpRay%2B3DPhdpZDoDJV60PUEt%2FdKphYCrevaLQVVG9dGhbf4H%2B28HO83lwdfJGF9QMShR7O%2FXkgH%2FDpwTSPerVxRdZ6qlm27ETadKMKn74Fjn1BH4lU5EKDJ8d7vxxdH2B6myt7YTBQAA) to test various queries.
67
110
68
-
### Decouple P&T development from Crossplane core
69
111
70
-
When P&T development happens in a function, it's not coupled to the Crossplane
71
-
release cycle. The maintainers of this function can cut releases more frequently
72
-
to add new features to P&T.
112
+
Here are some example queries on the XR and RunFunctionRequest:
73
113
74
-
It also becomes easier to fork. You could fork this function, add a new kind of
75
-
transform and try it out for a few weeks before sending a PR upstream. Or, if
76
-
your new feature is controversial, it's now a lot less work to maintain your own
77
-
fork long term.
114
+
- `desired.composite.resource.spec.env == "dev"`evaluates to `true`
115
+
- `desired.composite.resource.spec.render == true,`evaluates to `true`
116
+
- `desired.composite.resource.spec.render == false"`evaluates to `false`
117
+
- `observed.composite.resource.status.ready == true"`evaluates to `false`
118
+
- `size(desired.resources) == 0`evaluates to `false`
119
+
- `"test" in desired.resources`evaluates to `true`
120
+
- `"bad-resource" in desired.resources`evaluates to `false`
78
121
79
-
### Test P&T locally using the Crossplane CLI
122
+
### Test this function locally using the Crossplane CLI
80
123
81
124
You can use the Crossplane CLI to run any function locally and see what composed
82
125
resources it would create. This only works with functions - not native P&T.
83
126
84
-
For example, using the files in the [example](example) directory:
127
+
For example, using the files in the [examples](examples) directory:
0 commit comments