Skip to content

Commit

Permalink
chore: review
Browse files Browse the repository at this point in the history
Co-authored-by: Pete Lumbis <pete@upbound.io>
Signed-off-by: Philippe Scorsolini <p.scorsolini@gmail.com>
  • Loading branch information
phisco and plumbis committed Oct 28, 2023
1 parent a41a192 commit 1c69e3a
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 31 deletions.
40 changes: 24 additions & 16 deletions content/master/concepts/compositions.md
Original file line number Diff line number Diff line change
Expand Up @@ -1310,49 +1310,57 @@ checking that the Composition is well formed, for example:

### Composition schema aware validation

On top of the preceding integrity checks, Crossplane performs schema aware
validation of Compositions, checking that `patches`, `readinessChecks` and
`connectionDetails` are valid according to the involved resources' schemas, for
example checking that the source/destination field of a patch is a valid field
according to the source/destination resource's schema and that types match, if
defined, taking into account transforms.
Crossplane also performs schema aware
validation of Compositions. Schema validation checks that `patches`,
`readinessChecks` and `connectionDetails` are valid according to the resource
schemas. For example, checking that the source and destination fields of a patch
are valid according to the source and destination resource schema.

{{<hint "note" >}}
Composition schema aware validation is a beta feature, so Crossplane
enables it by default. You can disable it by setting the
Composition schema aware validation is a beta feature. Crossplane enables
beta features by default.

Disable schema aware validation by setting the
`--enable-composition-webhook-schema-validation=false` flag on the Crossplane
pod.
pod.

The [Crossplane Pods]({{<ref "./pods#edit-the-deployment">}}) page has
more information on enabling Crossplane flags.
{{< /hint >}}

#### Schema aware validation modes

Integrity validation errors always result in a rejection of the Composition.

You can configure how Crossplane should handle both missing involved resources'
schemas and actual schema aware validation errors.
<!-- vale alex.ProfanityUnlikely = NO -->
Crossplane always rejects Compositions in case of integrity errors.
<!-- vale alex.ProfanityUnlikely = Yes -->
Set the schema aware validation mode to configure how Crossplane handles both
missing resource schemas and schema aware validation errors.

{{<hint "note" >}}
In case of any involved resource schema missing, Crossplane skips schema aware
validation altogether.
If a resource schema is missing, Crossplane skips schema aware validation
but still returns an error for integrity errors and a warning or an error
for the missing schemas.
{{< /hint >}}

The following modes are available:

{{< table "table table-sm table-striped" >}}
| Mode | Missing Schema | Schema Aware Error | Integrity Error |
| -------- | -------------- |--------------------|-----------------|
| `warn` | Warning | Warning | Error |
| `loose` | Warning | Error | Error |
| `strict` | Error | Error | Error |
{{< /table >}}

Change the validation mode for a Composition with the
{{<hover label="mode" line="5">}}crossplane.io/composition-schema-aware-validation-mode{{</hover>}}
annotation.

If not specified, the default mode is `warn`.

For example, to enable `loose` mode checking:
For example, to enable `loose` mode checking set the annotation value to
{{<hover label="mode" line="5">}}loose{{</hover>}}.

```yaml {copy-lines="none",label="mode"}
apiVersion: apiextensions.crossplane.io/v1
Expand Down
37 changes: 22 additions & 15 deletions content/v1.13/concepts/compositions.md
Original file line number Diff line number Diff line change
Expand Up @@ -1244,49 +1244,56 @@ checking that the Composition is well formed, for example:

### Composition schema aware validation

On top of the preceding integrity checks, you can configure Crossplane to
perform schema aware validation on the resources in a Composition, checking
that `patches`, `readinessChecks` and `connectionDetails` are valid according to
the involved resources' schemas, for example checking that the
source/destination field of a patch is a valid field according to the
source/destination resource's schema and that types match, if defined, taking
into account transforms.
Crossplane also performs schema aware
validation of Compositions. Schema validation checks that `patches`,
`readinessChecks` and `connectionDetails` are valid according to the resource
schemas. For example, checking that the source and destination fields of a patch
are valid according to the source and destination resource schema.

{{<hint "note" >}}
Composition schema aware validation is an alpha feature, so Crossplane doesn't
enable it by default. You can enable it by setting the
Composition schema aware validation is an alpha feature. Crossplane doesn't
enable alpha features by default.

Enable schema aware validation by setting the
`--enable-composition-webhook-schema-validation=true` flag on the Crossplane
pod.

The [Crossplane Pods]({{<ref "./pods#edit-the-deployment">}}) page has
more information on enabling Crossplane flags.
{{< /hint >}}

#### Schema aware validation modes

Integrity validation errors always result in a rejection of the Composition.
<!-- vale alex.ProfanityUnlikely = NO -->
Crossplane always rejects Compositions in case of integrity errors.
<!-- vale alex.ProfanityUnlikely = Yes -->

You can configure how Crossplane should handle both missing involved resources'
schemas and actual schema aware validation errors.
Set the schema aware validation mode to configure how Crossplane handles both
missing resource schemas and schema aware validation errors.

{{<hint "note" >}}
In case of any involved resource schema missing, Crossplane skips schema aware
validation altogether.
If a resource schema is missing, Crossplane skips schema aware validation
but still returns an error for integrity errors and a warning or an error
for the missing schemas.
{{< /hint >}}

The following modes are available:

{{< table "table table-sm table-striped" >}}
| Mode | Missing Schema | Schema Aware Error | Integrity Error |
| -------- | -------------- |--------------------|-----------------|
| `loose` | Warning | Error | Error |
| `strict` | Error | Error | Error |
{{< /table >}}

Change the validation mode for a Composition with the
{{<hover label="mode" line="5">}}crossplane.io/composition-validation-mode{{</hover>}}
annotation.

If not specified, the default mode is `loose`.

For example, to enable `strict` mode checking:
For example, to enable `strict` mode checking set the annotation value to
{{<hover label="mode" line="5">}}strict{{</hover>}}.

```yaml {copy-lines="none",label="mode"}
apiVersion: apiextensions.crossplane.io/v1
Expand Down

0 comments on commit 1c69e3a

Please sign in to comment.