Originally created by @bvalyou on GitHub (Apr 5, 2024).
I'm working on migrating helm charts to Pkl and the way I've structured my shared code leverages a Listing<K8sResource> (pkl-k8s) that various pipe functions amend to add features, e.g. a database pipeline adds database env vars, ConfigMaps, and initContainers.
This works, but the Deployment object I'm amending doesn't know it's a Deployment object, so my IDE can only autocomplete the K8sResource attributes apiVersion and kind.
Requested feature
Subtype syntax - [[is Deployment]] {} or [[kind == "Deployment"] as Deployment] {} where the subtype is known in the following amend block.
It's definitely workable as is but it would be a nice quality of life enhancement.
Thanks for the great work on this!
Originally created by @bvalyou on GitHub (Apr 5, 2024).
I'm working on migrating helm charts to Pkl and the way I've structured my shared code leverages a `Listing<K8sResource>` (pkl-k8s) that various pipe functions amend to add features, e.g. a database pipeline adds database env vars, ConfigMaps, and initContainers.
# Summary
Quick pseudocode to show the general idea:
```
class Resources {
environment: Environment
k8sResources: Listing<K8sResource>
}
function getPostgresPipeline(databases: Listing<PostgresDatabase>) = (resources: Resources) -> (resources) {
local environment = resources.environment
k8sResources {
[[kind == "Deployment"]] {
spec {
template {
spec {
initContainers { ... }
}
}
}
}
}
}
new Resources { environment = getEnvironment(props) }
|> getPostgresPipeline(environment.postgresDatabases)
|> (resources: Resources) -> resources.k8sResources
```
This works, but the `Deployment` object I'm amending doesn't know it's a `Deployment` object, so my IDE can only autocomplete the `K8sResource` attributes `apiVersion` and `kind`.
# Requested feature
Subtype syntax - `[[is Deployment]] {}` or `[[kind == "Deployment"] as Deployment] {}` where the subtype is known in the following amend block.
It's definitely workable as is but it would be a nice quality of life enhancement.
Thanks for the great work on this!
Mostly, though I am seeing a gap within the predicate itself
[[this is ConfigMap && metadata.name == environment.resourceName("app-env")]] {
On that line there's a warning "Unresolved reference: metadata" but on the next line it autocompletes fine
@bvalyou commented on GitHub (Apr 5, 2024):
Mostly, though I am seeing a gap within the predicate itself
```
[[this is ConfigMap && metadata.name == environment.resourceName("app-env")]] {
```
On that line there's a warning "Unresolved reference: metadata" but on the next line it autocompletes fine
<img width="626" alt="image" src="https://github.com/apple/pkl/assets/16170157/a1e6455a-ea3b-42a3-9691-ad191ed7dadc">
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Originally created by @bvalyou on GitHub (Apr 5, 2024).
I'm working on migrating helm charts to Pkl and the way I've structured my shared code leverages a
Listing<K8sResource>(pkl-k8s) that various pipe functions amend to add features, e.g. a database pipeline adds database env vars, ConfigMaps, and initContainers.Summary
Quick pseudocode to show the general idea:
This works, but the
Deploymentobject I'm amending doesn't know it's aDeploymentobject, so my IDE can only autocomplete theK8sResourceattributesapiVersionandkind.Requested feature
Subtype syntax -
[[is Deployment]] {}or[[kind == "Deployment"] as Deployment] {}where the subtype is known in the following amend block.It's definitely workable as is but it would be a nice quality of life enhancement.
Thanks for the great work on this!
@odenix commented on GitHub (Apr 5, 2024):
Does
[[this is Deployment]]do the trick?@bvalyou commented on GitHub (Apr 5, 2024):
The one syntax variation I didn't think of! That does it. Thanks!
@odenix commented on GitHub (Apr 5, 2024):
Is it also understood by the IDE?
@bvalyou commented on GitHub (Apr 5, 2024):
Mostly, though I am seeing a gap within the predicate itself
On that line there's a warning "Unresolved reference: metadata" but on the next line it autocompletes fine
@odenix commented on GitHub (Apr 5, 2024):
Probably worth filing an issue in pkl-intellij.