XRDs can be created directly in Pkl or imported from Yaml.
Either can be converted to a Pkl Module.
When Creating a Pkl file ensure it amends CompositeResourceDefinition
amends "package://pkg.pkl-lang.org/github.com/crossplane-contrib/function-pkl/crospslane.contrib.xrd@<version>#/CompositeResourceDefinition.pkl"
view xrds/ExampleXR.pkl for more details on how to Build it.
running pkl eval xrds/ExampleXR.pkl
renders the XRD in its Yaml manifest format.
Modules can be generated by creating a file like xrds/xrd2module.pkl
and running pkl eval <filename> -m <outputDir>
.
This will create the Module in the Output directory. e.g. crds/XR.pkl was created by running:
pkl eval xrds/xrd2module.pkl -m crds
yaml manifests can be converted in the same way.
Managed Resources and any other CRDs can be converted similarly to XRDs by creating a file like crds/crd2module.pkl
pkl eval crds/crd2module.pkl -m crds
The Pkl file referenced in the Composition must amend CompositionResponse.pkl
.
The example at full.pkl gives an overview of what can be done.
CompositionResponse.pkl contains documentation on what the individual fields do.
The Observed State and other Parameters can be used to add Logic to the generated Response.
import "@crossplane.contrib/crossplane.pkl"
import "crds/XR.pkl"
local request = new crossplane {
customResourceTemplates = new {
["XR"] {
["example.crossplane.io/v1"] = XR
}
}
}.Request
To Parse the Request into Pkl Language the XRD and all Managed Resources used must be declared in customResourceTemplates.
The Composition itself can be created in yaml or in pkl. The latter is especially useful, if the the function is used with an inline Pkl file.
PklProject contains the dependencies of the Project as well as Metadata on where it will be Published, version and name.
Running pkl project resolve
will download the Project dependencies
Note: When having multiple Projects in a Repository, which have dependencies among each other use
pkl project resolve ./*/
from the parent directory
Run pkl project package
to create releasable package artifacts.
Note: When having multiple Projects in a Repository, which have dependencies among each other use
pkl project package ./*/
from the parent directory
Pkl Packages can be released to any https server.
This Project uses the GitHub to store the artifacts within releases. Using pkg.pkl-lang.org as the domain helps with redirecting the requests from
- https://pkg.pkl-lang.org/github.com/crossplane-contrib/function-pkl/[email protected]
to - https://github.com/crossplane-contrib/function-pkl/releases/download/[email protected]/[email protected]
When the Package is released it can be used in the Composition. See example/full/composition.yaml