mirror of
https://github.com/apple/pkl.git
synced 2026-01-13 15:13:38 +01:00
Support kind: kustomization #41
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @ichoosetoaccept on GitHub (Feb 6, 2024).
We use kustomize to manage our Kubernetes configuration. Currently the pkl CLI fails when I feed it such a file to transform to YAML.
Here's what a kustomization file is: https://kubectl.docs.kubernetes.io/references/kustomize/kustomization/
Here's the output of an attempt to convert a kustomization file:
pkl eval -p input=overlays/t1/kustomization.yaml -o overlays/t1/kustomization.pkl package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib@1.0.0#/convert.pkl –– Pkl Error –– Cannot find a template for resource of kindKustomization`.91 | throw("Cannot find a template for resource of kind
\(kind).")^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
at k8s.contrib.convert#getResourceTemplate.<function#2> (https://github.com/apple/pkl-pantry/blob/k8s.contrib@1.0.0/packages/k8s.contrib/convert.pkl#L91-91)
88 | let (apiVersion = resource["apiVersion"])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
at k8s.contrib.convert#getResourceTemplate.<function#1> (https://github.com/apple/pkl-pantry/blob/k8s.contrib@1.0.0/packages/k8s.contrib/convert.pkl#L88-91)
87 | let (kind = resource["kind"])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
at k8s.contrib.convert#getResourceTemplate (https://github.com/apple/pkl-pantry/blob/k8s.contrib@1.0.0/packages/k8s.contrib/convert.pkl#L87-91)
65 | let (template = getResourceTemplate(resource))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
at k8s.contrib.convert#resourceConverters["convert resource to conform to Pkl template"].<function#1> (https://github.com/apple/pkl-pantry/blob/k8s.contrib@1.0.0/packages/k8s.contrib/convert.pkl#L65-65)
106 | resourceConverters.fold(resource, (acc, _, f) -> f.apply(acc))
^^^^^^^^^^^^
at k8s.contrib.convert#resourceConverterFn.<function#1> (https://github.com/apple/pkl-pantry/blob/k8s.contrib@1.0.0/packages/k8s.contrib/convert.pkl#L106-106)
106 | resourceConverters.fold(resource, (acc, _, f) -> f.apply(acc))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
at k8s.contrib.convert#resourceConverterFn (https://github.com/apple/pkl-pantry/blob/k8s.contrib@1.0.0/packages/k8s.contrib/convert.pkl#L106-106)
286 | for (lineIdx, line in renderConvertedValue(resourceConverterFn(resource)).split("\n")) {
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
at k8s.contrib.convert#output.textBuffer (https://github.com/apple/pkl-pantry/blob/k8s.contrib@1.0.0/packages/k8s.contrib/convert.pkl#L286-286)
304 | text = textBuffer.toList().join("")
^^^^^^^^^^
at k8s.contrib.convert#output.text (https://github.com/apple/pkl-pantry/blob/k8s.contrib@1.0.0/packages/k8s.contrib/convert.pkl#L304-304)`
@bioball commented on GitHub (Feb 7, 2024):
It makes sense to have Kustomize templates, since Kustomize support ships with
kubectl.For what it's worth, Kustomize and Pkl both serve the same purpose; to produce Kubernetes YAML to get applied. Using Pkl to generate Kustomization feels like a bit of an anti-pattern; you're using Pkl but not using it for what it's best at.
Can you re-file this issue in https://github.com/apple/pkl-k8s?
@ichoosetoaccept commented on GitHub (Feb 12, 2024):
I can and I did, including some additional background and motivation: https://github.com/apple/pkl-k8s/issues/1.
Thanks for suggesting it!