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
Change variable validation error message type from string to expression #28044
Conversation
Codecov Report
|
terraform/eval_variable.go
Outdated
@@ -25,7 +26,7 @@ func evalVariableValidations(addr addrs.AbsInputVariableInstance, config *config | |||
} | |||
|
|||
// Variable nodes evaluate in the parent module to where they were declared | |||
// because the value expression (n.Expr, if set) comes from the calling | |||
// because the value expression (expr, if set) comes from the calling |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
n.Expr
appears to have been changed to expr
a while back so this is just fixing the docstring since I noticed it when fixing the merge conflicts from the original PR
Hey @joeaawad, glad to see others have the same language requests. My PR was waiting on a review, but if you're able to get the required +1s you need on this I'll go ahead and close mine. Thanks! |
Sounds good, thanks @cgetzen. Didn't mean to step on any toes, just saw the merge conflicts and lack of activity so was hoping to try to push this through in time for 0.15.0. Maintainers - is 0.15.0 a possibility or is that already locked? Happy to help in any way that I can to push this through in time. |
@pkolyvas Does https://discuss.hashicorp.com/t/terraform-0-15-0-beta2-released/21368 mean that it is too late to get this change in for |
@jbardin Sorry to ping but this is causing active pain so trying to get some 👀 since this update has been open for ~3 weeks and you were assigned to the original PR |
8ec8faa
to
c23fb9e
Compare
@apparentlymart @alisdair this was pretty skewered by #30401 refactor that lost the EvalContext so I'm pretty out of my depth here on how to get a string out of Please advise on if there is a path forwards for me to do this or if it would be best handled by the HashiCorp team, but I do feel that there is a ton of value in pushing this forward, especially now that you are looking at pre and post conditions which could also benefit from being able to explain exactly what variable caused the error. |
Hi @joeaawad! Thanks for working on this, and I'm sorry I hadn't noticed it until now. I agree with your assessment of the value in evaluating error messages as expressions, especially if we move forward with pre/postconditions or something similar. I had actually been working on a separate implementation of the same concept myself, as I hadn't seen this branch or PR. I'll be opening a pull request for that shortly, and if it's approved then I hope we'll have error message expressions in the 1.2 release. I'm going to close this for now in favour of the other branch, rather than as you to do further work on this one. Thanks again for pushing this forward! |
@alisdair awesome, glad to hear it, thanks a lot |
I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions. |
Submitted on behalf of a third-party: @cgetzen
All credit goes to @cgetzen for #25028 which originally made this change almost 10 months ago. I just updated it to resolve the merge conflicts since the original PR appears to be abandoned and I think this is a vital PR that would make a huge quality of life improvement for users and save me a lot of time answering questions from less experienced Terraform users.
Resolves #24407.
Resolves #24160.
This PR changes configs.VariableValidation.ErrorMessage from a string to an expression.
One consequence of this is that some of the validations on the error message (nilstring and lookslikesentence) are moved from the configs package to the terraform package and checked during Eval.
Tests
Template
This file is used as a template for the results below
Results
error_message
"Input '${var.x}' must be more than 5 characters."
[4, 3]
"Your string ${var.x} isn't long enough."
"not a sentence"