Pain Point: Deeply Nested Amends (No Flat Member Syntax)
- Dominant language
- Java
- Stars
- 11.5k
- Forks
- 402
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 20
Description
I'm testing Pkl as a replacement for k8s tools like Kustomize/Helm. So far it's quite nice, but one pain point is modifying deeply nested properties.
As an example, say I have a HomeAssistant pkl package with a default volume claim of 1Gi, which I'd like to bump up to 2Gi.
``` Pkl
import "ha-app.pkl" as homeassistant // extends AppEnvCluster, sets isLeafModule() = true
// assume the above is a third-party package
// default HomeAssistant application, with one modified property
local ha_app = (homeassistant) {
statefulSets {
["core"] {
spec {
volumeClaimTemplates {
[[metadata.name == "homeassistant-config"]] {
spec {
resources {
requests {
["storage"] = "2Gi"
} // 9 lines of brackets :')
}
}
}
}
}
}
}
}
output {
files { // for use by argocd
["homeassistant.yaml"] = ha_app.output
}
}
```
18 LoC for a single deeply nested amendment seems a little excessive.
One way I've found to improve this is to remove some newlines, but I don't find this _ideal_.
``` Pkl
// I guess this is better?
local ha_app = (homeassistant) { statefulSets { ["core"] { spec { volumeClaimTemplates {
[[metadata.name == "homeassistant-config"]] { spec { resources { requests {
["storage"] = "2Gi"
}}}}
}}}}}
```
I could create late-binding variables in a new pkl module which extends `ha-app` further, but that seems like I'd just be moving the problem down the line.
---
Personally I'd like to see dot syntax supported for amendments. In my case, that might look something like:
``` Pkl
local ha_app = (homeassistant) {
statefulSets["core"].spec.volumeClaimTemplates {
[[metadata.name == "homeassistant-config"]] {
spec.resources.requests["storage"] = "2Gi"
}
}
}
```
Am I missing a more idiomatic solution?
Contributor guide
Research direction
Start by reviewing Pkl's amendment syntax and the deeply nested HomeAssistant example in the issue. Compare the current bracketed form with the proposed dot syntax, then determine how the requested syntax should behave for nested properties, keyed members, and predicates; done means the syntax and its semantics are specified clearly enough to implement and test.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100