Skip to content
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

fix: added prefix validation #213

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
10 changes: 10 additions & 0 deletions solutions/agents/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ variable "prefix" {
type = string
description = "The prefix for resources created by this solution."
default = null
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."
}
}
variable "provider_visibility" {
description = "Set the visibility value for the IBM terraform provider. Supported values are `public`, `private`, `public-and-private`. [Learn more](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/guides/custom-service-endpoints)."
Expand Down
10 changes: 10 additions & 0 deletions solutions/instances/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@ variable "prefix" {
type = string
description = "The prefix to add to all resources that this solution creates."
default = null
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."
}
}
variable "provider_visibility" {
description = "Set the visibility value for the IBM terraform provider. Supported values are `public`, `private`, `public-and-private`. [Learn more](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/guides/custom-service-endpoints)."
Expand Down
2 changes: 1 addition & 1 deletion tests/pr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func TestInstancesInSchematics(t *testing.T) {

options := testschematic.TestSchematicOptionsDefault(&testschematic.TestSchematicOptions{
Testing: t,
Prefix: "instance-da",
Prefix: "inst-da",
TarIncludePatterns: []string{
"*.tf",
solutionInstanceDADir + "/*.tf",
Expand Down