-
Pkl 0.28.2 (macOS 14.7.2, native) (installed with homebrew) I've defined a bash script #!/bin/bash
# Check if the correct number of arguments are provided
if [ "$#" -ne 2 ]; then
echo "Usage: $0 <service_name> <component>"
exit 1
fi
# Set environment variables
export SERVICE_NAME=$1
export COMPONENT=$2
# Run the pkl command
pkl eval -f json -e SERVICE_NAME -e COMPONENT ./pkl-templates/my-template.pkl and in the pkl file COMPONENT = read("env:COMPONENT")
SERVICE_NAME = read("env:SERVICE_NAME")
...
Tags = new Dynamic {
component = List(
"${COMPONENT}"
)
}
...
but it is not rendering it correctly here's what I get: {
...
"Tags": {
"component": [
"${COMPONENT}"
]
}
}
Any help? The docs were not very clear that I could find about how to fit the cli and the pkl files together. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Your syntax for variable interpolation is incorrect: -"${COMPONENT}"
+"\(COMPONENT)" You actually don't even need interpolation here, because In case you aren't already, I highly recommend using one of our editor plugins for writing Pkl, because it they will provide feedback about this to you. Some other notes:
|
Beta Was this translation helpful? Give feedback.
-
@bioball I do have to interpolate it into a string somewhere else I omitted : PolicyName = "my-github-org-${SERVICE_NAME}-deploy" So I assume that is not how I should interpolate it. Updated: I found the doc say |
Beta Was this translation helpful? Give feedback.
Your syntax for variable interpolation is incorrect:
You actually don't even need interpolation here, because
COMPONENT
is already a string. So it can just becomponent = List(COMPONENT)
.In case you aren't already, I highly recommend using one of our editor plugins for writing Pkl, because it they will provide feedback about this to you.
Some other notes:
List
is a data type that's meant for in-language operations (map/flatmap/filter/etc). If you want to describe data, you should useListing
.If your module only makes sense as JSON, you should go ahead and set the
output.renderer
. Then, you don't need to add-f json
anymore as a CLI flag.