-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
CosmosDB: fixing the validation on the name field #263
Conversation
@@ -398,7 +398,7 @@ func resourceAzureRMCosmosDBAccountFailoverPolicyHash(v interface{}) int { | |||
func validateAzureRmCosmosDBAccountName(v interface{}, k string) (ws []string, errors []error) { | |||
value := v.(string) | |||
|
|||
r, _ := regexp.Compile("[a-z0-9-]") | |||
r, _ := regexp.Compile("^([a-z0-9\\-]+)$") |
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.
I can believe the escaping & quantifier (+
) is necessary, but are the control characters like brackets & ^
& $
too?
I mean, it applies to the whole string anyway and you don't need to capture anything via subgroup here?
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.
Running the tests it looks like we can remove the brackets but not the ^
&$
- updated
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.
Apparently I have still a lot to learn about regular expressions! 😅
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.
The expression does no harm and does what it's supposed to do, so LGTM, but can be less verbose, IMO.
Tests pass:
|
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 hashibot-feedback@hashicorp.com. Thanks! |
Following on from #262 - this fixes the validation to ensure upper-case characters are rejected in the
plan
phase rather than theapply
phase.