Document MatchTrue, MatchFalse and MatchCondition readiness checks (#513)

Co-authored-by: Pete Lumbis <pete@upbound.io>
This commit is contained in:
Lucas Caparelli 2023-09-05 12:41:54 -03:00 committed by GitHub
parent 480b7e9232
commit 02c676f6eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 126 additions and 2 deletions

View File

@ -1000,6 +1000,8 @@ Compositions support matching resource fields by:
* [integer match](#match-an-integer)
* [non-empty match](#match-that-a-field-exists)
* [always ready](#always-consider-a-resource-ready)
* [condition match](#match-a-condition)
* [boolean match](#match-a-boolean)
#### Match a string
@ -1100,7 +1102,7 @@ spec:
{{<hint "tip" >}}
Checking {{<hover label="NonEmpty" line="11">}}NonEmpty{{</hover>}} doesn't
require a `match` field.
require setting any other fields.
{{< /hint >}}
#### Always consider a resource ready
@ -1127,6 +1129,99 @@ spec:
- type: None
```
#### Match a condition
{{<hover label="condition" line="11">}}Condition{{</hover>}} considers the composed
resource to be ready when it finds the expected condition type, with the
expected status for it in its `status.conditions`.
For example, consider
{{<hover label="condition" line="7">}}my-resource{{</hover>}}, which is
ready if there is a condition of type
{{<hover label="condition" line="13">}}MyType{{</hover>}} with a status of
{{<hover label="condition" line="14">}}Success{{</hover>}}.
```yaml {label="condition",copy-lines="none"}
apiVersion: apiextensions.crossplane.io/v1
kind: Composition
# Removed for Brevity
spec:
resources:
# Removed for Brevity
- name: my-resource
base:
# Removed for brevity
readinessChecks:
- type: MatchCondition
matchCondition:
type: MyType
status: Success
```
#### Match a boolean
Two types of checks exist for matching boolean fields:
* `MatchTrue`
* `MatchFalse`
`MatchTrue` considers the composed resource to be ready when the value of a
field inside that resource is `true`.
`MatchFalse` considers the composed resource to be ready when the value of a
field inside that resource is `false`.
For example, consider
{{<hover label="matchTrue" line="7">}}my-resource{{</hover>}}, which is
ready if
{{<hover label="matchTrue" line="12">}} status.atProvider.manifest.status.ready{{</hover>}}
is {{<hover label="matchTrue" line="11">}}true{{</hover>}}.
```yaml {label="matchTrue",copy-lines="none"}
apiVersion: apiextensions.crossplane.io/v1
kind: Composition
# Removed for Brevity
spec:
resources:
# Removed for Brevity
- name: my-resource
base:
# Removed for brevity
readinessChecks:
- type: MatchTrue
fieldPath: status.atProvider.manifest.status.ready
```
{{<hint "tip" >}}
Checking {{<hover label="matchTrue" line="11">}}MatchTrue{{</hover>}} doesn't
require setting any other fields.
{{< /hint >}}
`MatchFalse` matches fields that express readiness with the value `false`.
For example, consider
{{<hover label="matchFalse" line="7">}}my-resource{{</hover>}}, is
ready if
{{<hover label="matchFalse" line="12">}} status.atProvider.manifest.status.pending{{</hover>}}
is {{<hover label="matchFalse" line="11">}}false{{</hover>}}.
```yaml {label="matchFalse",copy-lines="none"}
apiVersion: apiextensions.crossplane.io/v1
kind: Composition
# Removed for Brevity
spec:
resources:
# Removed for Brevity
- name: my-resource
base:
# Removed for brevity
readinessChecks:
- type: MatchFalse
fieldPath: status.atProvider.manifest.status.pending
```
{{<hint "tip" >}}
Checking {{<hover label="matchFalse" line="11">}}MatchFalse{{</hover>}} doesn't
require setting any other fields.
{{< /hint >}}
## Verify a Composition
View all available Compositions with `kubectl get composition`.

View File

@ -1003,6 +1003,7 @@ Compositions support matching resource fields by:
* [integer match](#match-an-integer)
* [non-empty match](#match-that-a-field-exists)
* [always ready](#always-consider-a-resource-ready)
* [condition match](#match-a-condition)
#### Match a string
@ -1103,7 +1104,7 @@ spec:
{{<hint "tip" >}}
Checking {{<hover label="NonEmpty" line="11">}}NonEmpty{{</hover>}} doesn't
require a `match` field.
require setting any other fields.
{{< /hint >}}
#### Always consider a resource ready
@ -1130,6 +1131,34 @@ spec:
- type: None
```
#### Match a condition
{{<hover label="condition" line="11">}}Condition{{</hover>}} considers the composed
resource to be ready when it finds the expected condition type, with the
expected status for it in its `status.conditions`.
For example, consider
{{<hover label="condition" line="7">}}my-resource{{</hover>}}, which is
ready if there is a condition of type
{{<hover label="condition" line="13">}}MyType{{</hover>}} with a status of
{{<hover label="condition" line="14">}}Success{{</hover>}}.
```yaml {label="condition",copy-lines="none"}
apiVersion: apiextensions.crossplane.io/v1
kind: Composition
# Removed for Brevity
spec:
resources:
# Removed for Brevity
- name: my-resource
base:
# Removed for brevity
readinessChecks:
- type: MatchCondition
matchCondition:
type: MyType
status: Success
```
## Verify a Composition
View all available Compositions with `kubectl get composition`.