Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document MatchTrue, MatchFalse and MatchCondition readiness checks #513

Merged
merged 5 commits into from
Sep 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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