-
Notifications
You must be signed in to change notification settings - Fork 24
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
refactor: added additional prefix validation #776
base: main
Are you sure you want to change the base?
Conversation
/run pipeline |
/run pipeline |
/run pipeline |
/run pipeline |
/run pipeline |
/run pipeline |
/run pipeline |
@@ -8,6 +8,10 @@ variable "prefix" { | |||
type = string | |||
description = "(Optional) Prefix to append to all resources created by this solution." | |||
default = null | |||
validation { | |||
error_message = "Prefix must begin with a lowercase letter and contain only lowercase letters, numbers, and - characters. Prefixes must end with a lowercase letter or number and be 16 or fewer characters." | |||
condition = can(regex("^([a-z]|[a-z][-a-z0-9]*[a-z0-9])$", coalesce(var.prefix, "cos"))) && length(coalesce(var.prefix, "cos")) <= 16 |
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.
Would it be neater
condition = anytrue([
var.prefix == null,
can(regex("^([a-z]|[a-z][-a-z0-9]{0,14}[a-z0-9])$", var.prefix))
])
Either
null
the regex is
a single lower letter,
or,
a single lower letter, ending in letter or number with 0 to 14 characters (making 16 total) in the middle.
This avoids the coalesce commands with an arbitrary string and the need for a specific length validation
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.
Two adjacent '-'s are also not permitted.
validation {
condition = anytrue([
var.prefix == null,
alltrue([
can(regex("^([a-z]|[a-z][-a-z0-9]{0,14}[a-z0-9])$", var.prefix)),
length(regexall("^.*--.*", var.prefix)) == 0
])
])
error_message = "Prefix must begin with a lowercase letter, contain only lowercase letters, numbers, and - characters. Prefixes must end with a lowercase letter or number and be 16 or fewer characters."
}
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.
Very brief discussion in the standup today. Decided this should be a request changes response.
Description
Added additional prefix validation to check more than length.
GIT Issue: #770
Release required?
x.x.X
)x.X.x
)X.x.x
)Release notes content
Run the pipeline
If the CI pipeline doesn't run when you create the PR, the PR requires a user with GitHub collaborators access to run the pipeline.
Run the CI pipeline when the PR is ready for review and you expect tests to pass. Add a comment to the PR with the following text:
Checklist for reviewers
For mergers