diff --git a/content/master/cli/command-reference.md b/content/master/cli/command-reference.md index 932d5865..6fca3d5a 100644 --- a/content/master/cli/command-reference.md +++ b/content/master/cli/command-reference.md @@ -32,6 +32,135 @@ Client Version: v1.16.0 Server Version: v1.16.0 ``` +## render + +The `crossplane render` command previews the output of a +[composite resource]({{}}) after applying +any [composition functions]({{}}). + +{{< hint "important" >}} +The `crossplane render` requires you to use composition functions. +{{< /hint >}} + +The `crossplane render` command connects to the locally running Docker +Engine to pull and run composition functions. + +{{}} +Running `crossplane render` requires [Docker](https://www.docker.com/). +{{< /hint >}} + +Provide a composite resource, composition and composition function YAML +definition with the command to render the output locally. + +For example, +`crossplane render xr.yaml composition.yaml function.yaml` + +The output includes the original composite resource followed by the generated +managed resources. + +{{}} +```yaml +--- +apiVersion: nopexample.org/v1 +kind: XBucket +metadata: + name: test-xrender +status: + bucketRegion: us-east-2 +--- +apiVersion: s3.aws.upbound.io/v1beta1 +kind: Bucket +metadata: + annotations: + crossplane.io/composition-resource-name: my-bucket + generateName: test-xrender- + labels: + crossplane.io/composite: test-xrender + ownerReferences: + - apiVersion: nopexample.org/v1 + blockOwnerDeletion: true + controller: true + kind: XBucket + name: test-xrender + uid: "" +spec: + forProvider: + region: us-east-2 +``` +{{< /expand >}} + +### Flags + +{{< table "table table-sm table-striped">}} +| Short flag | Long flag | Description | +| ------------ | ------------- | ------------------------------ | +| | `--context-files==,=` | A comma separated list of files to load for function "contexts." | +| | `--context-values==,=` | 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=` | +Provide artificial managed resource data to the function. +| +| `-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. | +{{< /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 +to a function's `context`. +The context is JSON formatted data. + +### Include function results + +If a function produces Kubernetes events with statuses use the +`--include-function-results` to print them along with the managed resource +outputs. + +### Include the composite resource + +Composition functions can only change the `status` field of a composite +resource. By default, the `crossplane render` command only prints the +`status` field with `metadata.name`. + +Use `--include-full-xr` to print the full composite resource, +including the `spec` and `metadata` fields. + +### Mock managed resources + +Provide mocked, or artificial data representing a managed resource with +`--observed-resources`. The `crossplane render` command treats the +provided inputs as if they were resources in a Crossplane cluster. + +A function can reference and manipulate the included resource as part of +running the function. + +The `observed-resources` may be a single YAML file with multiple resources or a +directory of YAML files representing multiple resources. + +Inside the YAML file include an +{{}}apiVersion{{}}, +{{}}kind{{}}, +{{}}metadata{{}} and +{{}}spec{{}}. + +```yaml {label="apiVersion"} +apiVersion: example.org/v1alpha1 +kind: ComposedResource +metadata: + name: test-render-b + annotations: + crossplane.io/composition-resource-name: resource-b +spec: + coolerField: "I'm cooler!" +``` + +The schema of the resource isn't validated and may contain any data. + ## xpkg The `crossplane xpkg` commands create, install and update Crossplane @@ -51,7 +180,7 @@ The CLI applies the required annotations and values to meet the The `crossplane` CLI supports building [configuration]({{< ref "../concepts/packages" >}}), -[function]({{}}) and +[function]({{}}) and [provider]({{}}) package types. @@ -117,6 +246,52 @@ Use `docker pull` to download a missing image. The `--embed-runtime-image-tarball` flag includes a local OCI image tarball inside the function or provider package. +### xpkg init + +The `crossplane xpkg init` command populates the current directory with +files to build a package. + +Provide a name to use for the package and the package template to start from +with the command +`crossplane xpkg init