Skip to content

Commit

Permalink
Document MatchTrue, MatchFalse and MatchCondition readiness checks (#513
Browse files Browse the repository at this point in the history
)

Co-authored-by: Pete Lumbis <pete@upbound.io>
  • Loading branch information
LCaparelli and plumbis authored Sep 5, 2023
1 parent 480b7e9 commit 02c676f
Show file tree
Hide file tree
Showing 2 changed files with 126 additions and 2 deletions.
97 changes: 96 additions & 1 deletion content/master/concepts/compositions.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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`.
Expand Down
31 changes: 30 additions & 1 deletion content/v1.13/concepts/compositions.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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`.
Expand Down

0 comments on commit 02c676f

Please sign in to comment.