I would like users to be able to pass a list of objects as a parameter in waypoint.hcl for a plugin I am building.
The configuration should look something like this:
deploy {
use "appengine" {
# ...other parameters
# How to make handlers work ?
handlers = [
{
url = "/.*"
script = "auto"
secure = "always"
}
]
}
}
The DeployConfig struct in Go looks like this:
type DeployConfig struct {
// Other config fields...
Handlers []Handler `hcl:"handlers,optional"`
}
type Handler struct {
URL string `hcl:"url"`
Script string `hcl:"script"`
Secure string `hcl:"secure"`
}
This generates the following error: Validating required plugins...panic: unsuitable DecodeExpression target: no cty.Type for struct { URL string "hcl:\"url\""; Script string "hcl:\"script\""; Secure string "hcl:\"secure\"" } (no cty field tags)
Note: When you use block HCL will not validate that there are elements in the array, or that no handlers were defined. You would need to validate this yourself.
Great thank you so much, I was able to make the syntax with the repeated blocks work with your suggestion. Unfortunately, the following syntax triggers the error below.
Triggers the following error: waypoint.hcl:106,7-15: Unsupported argument; An argument named "handlers" is not expected here. Did you mean to define a block of type "handlers"?