Skip to content

Commit

Permalink
add CompositeResourceDefinition.pkl as helper
Browse files Browse the repository at this point in the history
make getExtraResources return Listing<Resource> instead of Listing<Resource?>
  • Loading branch information
Avarei committed Jun 17, 2024
1 parent 238fb63 commit d4198b2
Show file tree
Hide file tree
Showing 5 changed files with 408 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ BRANCH := $(shell git branch --show-current)
PKL_BASE_URI := package://pkg.pkl-lang.org

PKL_CORE_NAME := crossplane
PKL_CORE_VERSION := 0.0.28
PKL_CORE_VERSION := 0.0.29
PKL_CORE_REF := ${PKL_CORE_NAME}@${PKL_CORE_VERSION}
PKL_CORE_URI := ${PKL_BASE_URI}/${REPO}/${PKL_CORE_REF}

Expand Down
6 changes: 3 additions & 3 deletions example/inline/composition.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ spec:
type: inline
# This pkl file is at `pkl/crossplane-example/full.pkl` in this repo
inline: |
amends "package://pkg.pkl-lang.org/github.com/avarei/function-pkl/[email protected].28#/CompositionResponse.pkl"
import "package://pkg.pkl-lang.org/github.com/avarei/function-pkl/[email protected].28#/Resource.pkl"
import "package://pkg.pkl-lang.org/github.com/avarei/function-pkl/[email protected].28#/Crossplane.pkl"
amends "package://pkg.pkl-lang.org/github.com/avarei/function-pkl/[email protected].29#/CompositionResponse.pkl"
import "package://pkg.pkl-lang.org/github.com/avarei/function-pkl/[email protected].29#/Resource.pkl"
import "package://pkg.pkl-lang.org/github.com/avarei/function-pkl/[email protected].29#/Crossplane.pkl"
import "package://pkg.pkl-lang.org/github.com/avarei/function-pkl/[email protected]#/crds/XR.pkl"
import "package://pkg.pkl-lang.org/github.com/avarei/function-pkl/[email protected]#/crds/Object.pkl"
Expand Down
5 changes: 3 additions & 2 deletions pkl/crossplane/CompositionRequest.pkl
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ class Resources {
items: Listing<Resource?>
}

function getExtraResources(name: String): Listing<Resource?> =
extraResources.getOrNull(name).ifNonNull((it: Resources) -> it.items) ?? new Listing<Resource?> {}
function getExtraResources(name: String): Listing<Resource> =
let (listingWithNil = extraResources.getOrNull(name).ifNonNull((it: Resources) -> it.items) ?? new Listing<Resource?> {})
listingWithNil.toList().filter((n) -> n != null).toListing() as Listing<Resource>

function getExtraResource(name: String, index: Int):Resource? =
getExtraResources(name).toList().getOrNull(index)
5 changes: 4 additions & 1 deletion pkl/crossplane/PklProject
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ package {
authors {
"Tim Geimer <[email protected]>"
}
version = "0.0.28"
version = "0.0.29"
baseUri = "package://pkg.pkl-lang.org/github.com/avarei/function-pkl/\(name)"
packageZipUrl = "https://github.com/Avarei/function-pkl/releases/download/\(name)@\(version)/\(name)@\(version).zip"
sourceCode = "https://github.com/Avarei/function-pkl"
Expand All @@ -38,4 +38,7 @@ dependencies {
["k8s.contrib"] {
uri = "package://pkg.pkl-lang.org/pkl-pantry/[email protected]"
}
["openapiv3"] {
uri = "package://pkg.pkl-lang.org/pkl-pantry/[email protected]"
}
}
Loading

0 comments on commit d4198b2

Please sign in to comment.