Skip to content

Commit d688dd9

Browse files
committed
feat: update stack validation, relax regexes, enforce SCM exclusivity, add CI
- Update stack validation: remove EOL scalingo-18, add scalingo-24 - Extend TLD max length to 63 chars for domain and domain_aliases validation - Simplify domain_aliases validation logic - Support + in email local part for collaborators validation - Simplify ELK log drain URL validation to accept auth, ports, and paths - Add lifecycle precondition to enforce github/gitlab mutual exclusivity - Add CI workflow with terraform fmt, init, and validate
1 parent 05b763e commit d688dd9

3 files changed

Lines changed: 28 additions & 7 deletions

File tree

.github/workflows/ci.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: CI
2+
on:
3+
pull_request:
4+
push:
5+
branches: [main]
6+
jobs:
7+
terraform:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v4
11+
- uses: hashicorp/setup-terraform@v3
12+
- run: terraform fmt -check -recursive
13+
- run: terraform init -backend=false
14+
- run: terraform validate

app.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ resource "scalingo_app" "app" {
1212

1313
sticky_session = var.sticky_session
1414
router_logs = var.router_logs
15+
16+
lifecycle {
17+
precondition {
18+
condition = !(var.github_integration != null && var.gitlab_integration != null)
19+
error_message = "Only one of github_integration or gitlab_integration can be set, not both."
20+
}
21+
}
1522
}
1623

1724
resource "scalingo_container_type" "containers" {

variables.tf

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ variable "stack" {
99
default = "scalingo-22"
1010

1111
validation {
12-
condition = contains(["scalingo-18", "scalingo-20", "scalingo-22"], var.stack)
13-
error_message = "The stack value must be one of the following: scalingo-18, scalingo-20, scalingo-22"
12+
condition = contains(["scalingo-20", "scalingo-22", "scalingo-24"], var.stack)
13+
error_message = "The stack value must be one of the following: scalingo-20, scalingo-22, scalingo-24"
1414
}
1515
}
1616

@@ -102,7 +102,7 @@ variable "additionnal_collaborators" {
102102
validation {
103103
condition = length([
104104
for email in var.additionnal_collaborators :
105-
email if regex("^([a-zA-Z0-9_\\-\\.]+)@([a-zA-Z0-9_\\-\\.]+)\\.([a-zA-Z]{2,5})$", email) == false
105+
email if regex("^([a-zA-Z0-9_\\-\\.\\+]+)@([a-zA-Z0-9_\\-\\.]+)\\.([a-zA-Z]{2,63})$", email) == false
106106
]) == 0
107107
error_message = "The list of emails must contain only valid emails."
108108
}
@@ -163,7 +163,7 @@ variable "domain" {
163163
nullable = true
164164

165165
validation {
166-
condition = var.domain == null || can(length(regex("^([a-zA-Z0-9_\\-\\.]+)\\.([a-zA-Z]{2,5})$", var.domain)) > 0)
166+
condition = var.domain == null || can(length(regex("^([a-zA-Z0-9_\\-\\.]+)\\.([a-zA-Z]{2,63})$", var.domain)) > 0)
167167
error_message = "The domain name must be a valid domain name."
168168
}
169169
}
@@ -177,7 +177,7 @@ variable "domain_aliases" {
177177
validation {
178178
condition = length([
179179
for domain in var.domain_aliases :
180-
domain if !can(length(regex("^([a-zA-Z0-9_\\-\\.]+)\\.([a-zA-Z]{2,6})$", domain)) == 0)
180+
domain if !can(regex("^([a-zA-Z0-9_\\-\\.]+)\\.([a-zA-Z]{2,63})$", domain))
181181
]) == 0
182182
error_message = "The list of domain names must contain only valid domain names."
183183
}
@@ -207,8 +207,8 @@ variable "log_drains" {
207207
validation {
208208
condition = length([
209209
for drain in var.log_drains :
210-
drain if drain.type == "elk" && can(length(regex("^https?://([a-zA-Z0-9_\\-\\.]+)\\.([a-zA-Z]{2,5})$", drain.url)) == 0)
210+
drain if drain.type == "elk" && !can(regex("^https?://.+", drain.url))
211211
]) == 0
212-
error_message = "Log drains of type \"elk\" must have a valid url."
212+
error_message = "Log drains of type \"elk\" must have a valid url (starting with http:// or https://)."
213213
}
214214
}

0 commit comments

Comments
 (0)