File tree Expand file tree Collapse file tree 2 files changed +35
-1
lines changed
examples/conditional-resources Expand file tree Collapse file tree 2 files changed +35
-1
lines changed Original file line number Diff line number Diff line change @@ -118,6 +118,40 @@ Here are some example queries on the XR and RunFunctionRequest:
118118- ` "test" in desired.resources` evaluates to `true`
119119- ` "bad-resource" in desired.resources` evaluates to `false`
120120
121+ # ## Conditionally Rendering Managed Resources
122+
123+ In a similar manner, individual Managed Resources can also
124+ be rendered conditionally, see the example at [examples/conditional-resources](examples/conditional-resources/).
125+
126+ Each resource can have a `condition`.
127+
128+ ` ` ` yaml
129+ resources:
130+ - name: blue-resource
131+ condition: observed.composite.resource.spec.deployment.blue == true
132+ base:
133+ apiVersion: nop.crossplane.io/v1alpha1
134+ kind: NopResource
135+ spec:
136+ forProvider:
137+ ` ` `
138+
139+ If this condition is set in the Claim/XR, the resource will be rendered :
140+
141+ ` ` ` yaml
142+ apiVersion: nop.example.org/v1alpha1
143+ kind: XNopConditional
144+ metadata:
145+ name: test-resource
146+ spec:
147+ env: dev
148+ render: true
149+ deployment:
150+ blue: true
151+ green: false
152+
153+ ` ` `
154+
121155# ## Test this function locally using the Crossplane CLI
122156
123157You can use the Crossplane CLI to run any function locally and see what composed
Original file line number Diff line number Diff line change @@ -38,4 +38,4 @@ In our Composition both the `blue-resource` and the `green-resource` have a
3838- Install the XRD & Composition in `kubectl apply -f definition.yaml -f composition.yaml`
3939- Install the Function `kubectl apply -f functions.yaml`
4040
41- Finally install the xr : ` kubectl apply -f xr`
41+ Finally install the xr : ` kubectl apply -f xr`
You can’t perform that action at this time.
0 commit comments