Are there any patterns for splitting a configuration into multiple files? #421
Replies: 2 comments
-
One very common pattern is to use glob imports. It's a contrived example, but you might have a file structure like this:
And resources: Listing<K8sResource> = new {
for (_, resource in import*("configs/*.pkl")) {
resource
}
}
output {
renderer = new YamlRenderer {}
value = resources
} |
Beta Was this translation helpful? Give feedback.
-
@HT154's example is totally valid. Also, always remember that users can arbitrarily
Depending on what sort of config you're rolling, if it's "feature-based," you can also use the presence of certain files to signal a feature is being used, so
It depends very much on your wider context which patterns to pick. |
Beta Was this translation helpful? Give feedback.
-
I'm trying to puzzle my way through porting a helm chart to PKL. In Helm, it's very common to split the whole configuration into multiple files for readability purposes.
For a simple Helm chart, it would be pretty easy to squish all the objects into a single file and distribute that package and let people amend it. So my local config would amend the upstream file.
However, if I want to break apart my configuration to make it easier to manage into multiple files that would then require all users to create an amending module for each one of my files. I don't like this as it would effectively require all consumers of my chart to be exposed to the internal structure.
A somewhat more user-friendly way to do this would be to create an
amend
chain, so A amends B, amends C, amends D. Then the end-user would just need toamends "A"
to pull in the full item. It's better from a user-perspective but feels really awkward to build a long amends chain.Are there any other patterns for composing configuration over multiple files?
Beta Was this translation helpful? Give feedback.
All reactions