Skip to content

Commit

Permalink
generate more files from pkl
Browse files Browse the repository at this point in the history
Signed-off-by: Tim <[email protected]>
  • Loading branch information
Avarei committed Jul 6, 2024
1 parent a72ba4c commit 9cc3192
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 13 deletions.
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,15 @@ pkl-release: check-tag pkl-package

PROJECT_DIR := $(dir $(firstword $(MAKEFILE_LIST)))
.PHONY: generate
generate: pkl-resolve pkl-resolve-hack
generate: pkl-resolve-hack
go generate ./...
pkl eval --working-dir $(PROJECT_DIR)hack/pklcrd -m ../../pkl/crossplane.contrib crd2module.pkl
pkl eval --working-dir $(PROJECT_DIR)hack/pklcrd -m ../../pkl/crossplane.contrib crd2module-composition-fix.pkl
pkl eval --working-dir $(PROJECT_DIR)pkl/crossplane.contrib.example -m crds xrds/ExampleXR.pkl
pkl eval --working-dir $(PROJECT_DIR)pkl/crossplane.contrib.example compositions/inline.pkl > $(PROJECT_DIR)example/inline/composition.yaml
pkl eval --working-dir $(PROJECT_DIR)pkl/crossplane.contrib.example compositions/uri.pkl > $(PROJECT_DIR)example/full/composition.yaml
pkl eval --working-dir $(PROJECT_DIR)pkl/crossplane.contrib.example xrs/inline.pkl > $(PROJECT_DIR)example/inline/xr.yaml
pkl eval --working-dir $(PROJECT_DIR)pkl/crossplane.contrib.example xrs/uri.pkl > $(PROJECT_DIR)example/full/xr.yaml

.PHONY: build-image
build-image:
Expand Down
9 changes: 4 additions & 5 deletions example/full/composition.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
apiVersion: apiextensions.crossplane.io/v1
kind: Composition
metadata:
name: function-pkl
name: pkl-uri-example
spec:
compositeTypeRef:
apiVersion: example.crossplane.io/v1
kind: XR
mode: Pipeline
pipeline:
- step: run-the-template
functionRef:
- functionRef:
name: function-pkl
input:
apiVersion: pkl.fn.crossplane.io/v1beta1
kind: Pkl
spec:
type: uri
# This pkl file is at `pkl/crossplane.contrib.example/compositions/steps/full.pkl` in this repo
uri: "package://pkg.pkl-lang.org/github.com/crossplane-contrib/function-pkl/[email protected]#/compositions/steps/full.pkl"
uri: package://pkg.pkl-lang.org/github.com/crossplane-contrib/function-pkl/crossplane.contrib.example@0.0.0#/compositions/steps/full.pkl
step: pkl-template
7 changes: 4 additions & 3 deletions example/full/xr.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Replace this with your XR!
apiVersion: example.crossplane.io/v1
kind: XR
spec:
compositionRef:
name: pkl-uri-example
metadata:
name: example-xr
spec: {}
name: uri-example
7 changes: 4 additions & 3 deletions example/inline/xr.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Replace this with your XR!
apiVersion: example.crossplane.io/v1
kind: XR
spec:
compositionRef:
name: inline-example
metadata:
name: example-xr
spec: {}
name: inline-example
2 changes: 1 addition & 1 deletion pkl/crossplane.contrib.example/DEPLOY.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Deploying this Example

## Prerequirements
* pkl cli
* [pkl cli](https://pkl-lang.org/main/current/pkl-cli/index.html#installation)
* crossplane in a cluster
* function-pkl deployed (see [here](../../README.md))
* provider-kubernetes deployed
Expand Down
3 changes: 3 additions & 0 deletions pkl/crossplane.contrib.example/xrds/ExampleXR.pkl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ spec {
kind = "XR"
plural = "xrs"
}
defaultCompositionRef {
name = import("../compositions/uri.pkl").metadata.name!!
}
versions {
new {
name = "v1"
Expand Down
11 changes: 11 additions & 0 deletions pkl/crossplane.contrib.example/xrs/inline.pkl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
amends "../crds/XR.pkl"

metadata {
name = "inline-example"
}

spec {
compositionRef {
name = import("../compositions/inline.pkl").metadata.name!!
}
}
11 changes: 11 additions & 0 deletions pkl/crossplane.contrib.example/xrs/uri.pkl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
amends "../crds/XR.pkl"

metadata {
name = "uri-example"
}

spec {
compositionRef {
name = import("../compositions/uri.pkl").metadata.name!!
}
}

0 comments on commit 9cc3192

Please sign in to comment.