Skip to content

How to structure multiple layers of configuration? #332

Answered by bioball
edward3h asked this question in Q&A
Discussion options

You must be logged in to vote

One way to do this is to structure everything in as a mixin. A mixin is a way to have a multiple inheritance model in Pkl.

Here's a gist to demonstrate this: https://gist.github.com/bioball/8fcc848cffdf11fcbce68e420647aa1e. This example uses external properties to control what profiles and modifiers to include.

Use pkl eval AppConfig.pkl to get rendered results. Use external properties to determine what to include. For example:

pkl eval AppConfig.pkl -p modifier=ci -p profile=prod

This example will also import ../local/config.pkl, but only if that file exists.

On the Java side, you can similarly set external properties when building your evaluator.

public AppConfig loadAppConfig() {
  try (

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@edward3h
Comment options

Answer selected by edward3h
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants