add extra-resources to cli

Signed-off-by: Steven Borrelli <steve@borrelli.org>
This commit is contained in:
Steven Borrelli 2024-09-27 18:41:03 +02:00
parent 9492e023dc
commit 060fb97f5b
2 changed files with 134 additions and 108 deletions

View File

@ -12,13 +12,16 @@ Read the [Crossplane CLI overview]({{<ref "../cli">}}) page for information on
installing `crossplane`.
## Global flags
The following flags are available for all commands.
{{< table "table table-sm table-striped">}}
| Short flag | Long flag | Description |
|------------|-------------|------------------------------|
| `-h` | `--help` | Show context sensitive help. |
| | `--verbose` | Print verbose output. |
{{< /table >}}
## version
@ -28,8 +31,8 @@ and the control plane.
```shell
crossplane version
Client Version: v1.16.0
Server Version: v1.16.0
Client Version: v1.17.0
Server Version: v1.17.0
```
## render
@ -59,6 +62,7 @@ The output includes the original composite resource followed by the generated
managed resources.
{{<expand "An example render output" >}}
```yaml
---
apiVersion: nopexample.org/v1
@ -87,28 +91,30 @@ spec:
forProvider:
region: us-east-2
```
{{< /expand >}}
### Flags
{{< table "table table-sm table-striped">}}
| Short flag | Long flag | Description |
| ------------ | ------------- | ------------------------------ |
| | `--context-files=<key>=<file>,<key>=<file>` | A comma separated list of files to load for function "contexts." |
| | `--context-values=<key>=<value>,<key>=<value>` | A comma separated list of key-value pairs to load for function "contexts." |
| `-r` | `--include-function-results` | Include the "results" or events from the function. |
| `-o` | `--observed-resources=<directory or file>` |
Provide artificial managed resource data to the function.
|
| `-o` | `--observed-resources=<directory or file>` | Provide artificial managed resource data to the function. |
| `-e` | `--extra-resources=PATH` | A YAML file or directory of YAML files specifying extra resources to pass to the Function pipeline. |
| `-c` | `--include-context` | Include the context in the rendered output as a resource of kind: Context. |
| `-x` | `--include-full-xr` | Include a copy of the input Composite Resource spec and metadata fields in the rendered output. |
| | `--timeout=` | Amount of time to wait for a function to finish. (Default 1 minute) |
{{< /table >}}
The `crossplane render` command relies on standard
[Docker environmental variables](https://docs.docker.com/engine/reference/commandline/cli/#environment-variables)
to connect to the local Docker Engine and run composition functions.
### Provide function context
The `--context-files` and `--context-values` flags can provide data
@ -161,6 +167,14 @@ spec:
The schema of the resource isn't validated and may contain any data.
### Mock Extra Resources
Extra Resources allow a Composition to request Crossplane Objects on the cluster that are not
part of the Composition. The `--extra-resources` option can be pointed at a directory containing
YAML manifests of resources to mock, and can be used in combination with a function like
[function-extra-resources](https://github.com/crossplane-contrib/function-extra-resources) or the
built-in support in [function-go-templating](https://github.com/crossplane-contrib/function-go-templating?tab=readme-ov-file#extraresources).
## xpkg
The `crossplane xpkg` commands create, install and update Crossplane
@ -183,9 +197,10 @@ The `crossplane` CLI supports building
[function]({{<ref "../concepts/compositions">}}) and
[provider]({{<ref "../concepts/providers" >}}) package types.
#### Flags
{{< table "table table-sm table-striped">}}
| Short flag | Long flag | Description |
| ------------ | ------------- | ------------------------------ |
| | `--embed-runtime-image-name=NAME` | The image name and tag of an image to include in the package. Only for provider and function packages. |
@ -972,7 +987,6 @@ crossplane beta validate provider.yaml managedResource.yaml
Total 1 resources: 0 missing schemas, 1 success case, 0 failure cases
```
#### Validate render command output
You can pipe the output of `crossplane render` into
@ -994,8 +1008,8 @@ crossplane render xr.yaml composition.yaml function.yaml --include-full-xr | cro
Total 5 resources: 0 missing schemas, 4 success cases, 1 failure cases
```
#### Validate Common Expression Language rules
XRDs can define [validation rules](https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/#validation-rules) expressed in the Common Expression Language
([CEL](https://kubernetes.io/docs/reference/using-api/cel/)).
@ -1054,7 +1068,6 @@ error.
Total 1 resources: 0 missing schemas, 0 success cases, 1 failure cases
```
#### Validate against a directory of schemas
The `crossplane render` command can validate a directory of YAML files.

View File

@ -12,13 +12,16 @@ Read the [Crossplane CLI overview]({{<ref "../cli">}}) page for information on
installing `crossplane`.
## Global flags
The following flags are available for all commands.
{{< table "table table-sm table-striped">}}
| Short flag | Long flag | Description |
|------------|-------------|------------------------------|
| `-h` | `--help` | Show context sensitive help. |
| | `--verbose` | Print verbose output. |
{{< /table >}}
## version
@ -28,8 +31,8 @@ and the control plane.
```shell
crossplane version
Client Version: v1.16.0
Server Version: v1.16.0
Client Version: v1.17.0
Server Version: v1.17.0
```
## render
@ -59,6 +62,7 @@ The output includes the original composite resource followed by the generated
managed resources.
{{<expand "An example render output" >}}
```yaml
---
apiVersion: nopexample.org/v1
@ -87,28 +91,30 @@ spec:
forProvider:
region: us-east-2
```
{{< /expand >}}
### Flags
{{< table "table table-sm table-striped">}}
| Short flag | Long flag | Description |
| ------------ | ------------- | ------------------------------ |
| | `--context-files=<key>=<file>,<key>=<file>` | A comma separated list of files to load for function "contexts." |
| | `--context-values=<key>=<value>,<key>=<value>` | A comma separated list of key-value pairs to load for function "contexts." |
| `-r` | `--include-function-results` | Include the "results" or events from the function. |
| `-o` | `--observed-resources=<directory or file>` |
Provide artificial managed resource data to the function.
|
| `-o` | `--observed-resources=<directory or file>` | Provide artificial managed resource data to the function. |
| `-e` | `--extra-resources=PATH` | A YAML file or directory of YAML files specifying extra resources to pass to the Function pipeline. |
| `-c` | `--include-context` | Include the context in the rendered output as a resource of kind: Context. |
| `-x` | `--include-full-xr` | Include a copy of the input Composite Resource spec and metadata fields in the rendered output. |
| | `--timeout=` | Amount of time to wait for a function to finish. (Default 1 minute) |
{{< /table >}}
The `crossplane render` command relies on standard
[Docker environmental variables](https://docs.docker.com/engine/reference/commandline/cli/#environment-variables)
to connect to the local Docker Engine and run composition functions.
### Provide function context
The `--context-files` and `--context-values` flags can provide data
@ -161,6 +167,14 @@ spec:
The schema of the resource isn't validated and may contain any data.
### Mock Extra Resources
Extra Resources allow a Composition to request Crossplane Objects on the cluster that are not
part of the Composition. The `--extra-resources` option can be pointed at a directory containing
YAML manifests of resources to mock, and can be used in combination with a function like
[function-extra-resources](https://github.com/crossplane-contrib/function-extra-resources) or the
built-in support in [function-go-templating](https://github.com/crossplane-contrib/function-go-templating?tab=readme-ov-file#extraresources).
## xpkg
The `crossplane xpkg` commands create, install and update Crossplane
@ -183,9 +197,10 @@ The `crossplane` CLI supports building
[function]({{<ref "../concepts/compositions">}}) and
[provider]({{<ref "../concepts/providers" >}}) package types.
#### Flags
{{< table "table table-sm table-striped">}}
| Short flag | Long flag | Description |
| ------------ | ------------- | ------------------------------ |
| | `--embed-runtime-image-name=NAME` | The image name and tag of an image to include in the package. Only for provider and function packages. |
@ -972,7 +987,6 @@ crossplane beta validate provider.yaml managedResource.yaml
Total 1 resources: 0 missing schemas, 1 success case, 0 failure cases
```
#### Validate render command output
You can pipe the output of `crossplane render` into
@ -994,8 +1008,8 @@ crossplane render xr.yaml composition.yaml function.yaml --include-full-xr | cro
Total 5 resources: 0 missing schemas, 4 success cases, 1 failure cases
```
#### Validate Common Expression Language rules
XRDs can define [validation rules](https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/#validation-rules) expressed in the Common Expression Language
([CEL](https://kubernetes.io/docs/reference/using-api/cel/)).
@ -1054,7 +1068,6 @@ error.
Total 1 resources: 0 missing schemas, 0 success cases, 1 failure cases
```
#### Validate against a directory of schemas
The `crossplane render` command can validate a directory of YAML files.