-
Notifications
You must be signed in to change notification settings - Fork 510
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bakefile: mark variables as required #1346
Comments
Having something as suggested in #491 (comment) with type constraints and validation like terraform does would be more aligned I think: variable "slugs" {
type = list(string)
default = [
"crazymax/diun",
"ghcr.io/crazy-max/diun"
]
validation {
condition = length(var.slugs) > 0
error_message = "At least one slug is required."
}
} |
💯 that would be a nicer, more general approach! |
We'll move forward with this issue as-is, likely with the suggested modifications from @crazy-max, but we'll keep the work scoped to addressing the required case. Other work items will cover additional cases such as validation and typing. |
Current
There seems to be no way in current hcl bakefile syntax to mark a variable as required. There is a way to specify defaults:
Or without explicit default the variable defaults to empty:
Proposed Enhancement
I'm trying to define a variable that is required to be set by the caller (i.e. through environment variable). Something like:
Where the user needs to specify the tag when executing
buildx bake
through either env-var or by passing multiple bake files (where the variable needs to be set to a value in at least one of the bake files).Expectation:
The text was updated successfully, but these errors were encountered: