Skip to content

Commit 52803b9

Browse files
configs: Custom variable validation is no longer experimental
All of the feedback from the experiment described enhancements that can potentially be added later without breaking changes, so this change simply removes the experiment gate from the feature as originally implemented with no changes to its functionality. Further enhancements may follow in later releases, but the goal of this change is just to ship the feature exactly as it was under the experiment. Most of the changes here are cleaning up the experiment opt-ins from our test cases. The most important parts are in configs/experiments.go and in experiments/experiment.go .
1 parent 5127f1e commit 52803b9

File tree

9 files changed

+1
-54
lines changed

9 files changed

+1
-54
lines changed

configs/experiments.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -139,18 +139,5 @@ func checkModuleExperiments(m *Module) hcl.Diagnostics {
139139
}
140140
*/
141141

142-
if !m.ActiveExperiments.Has(experiments.VariableValidation) {
143-
for _, vc := range m.Variables {
144-
if len(vc.Validations) != 0 {
145-
diags = diags.Append(&hcl.Diagnostic{
146-
Severity: hcl.DiagError,
147-
Summary: "Custom variable validation is experimental",
148-
Detail: "This feature is currently an opt-in experiment, subject to change in future releases based on feedback.\n\nActivate the feature for this module by adding variable_validation to the list of active experiments.",
149-
Subject: vc.Validations[0].DeclRange.Ptr(),
150-
})
151-
}
152-
}
153-
}
154-
155142
return diags
156143
}

configs/testdata/invalid-files/variable-validation-bad-msg.tf

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
2-
terraform {
3-
experiments = [variable_validation]
4-
}
5-
61
variable "validation" {
72
validation {
83
condition = var.validation != 4

configs/testdata/invalid-files/variable-validation-condition-badref.tf

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11

2-
terraform {
3-
experiments = [variable_validation]
4-
}
5-
62
locals {
73
foo = 1
84
}

configs/testdata/invalid-files/variable-validation-condition-noref.tf

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11

2-
terraform {
3-
experiments = [variable_validation]
4-
}
5-
62
variable "validation" {
73
validation {
84
condition = true # ERROR: Invalid variable validation condition

configs/testdata/invalid-modules/variable-validation-without-optin/variable-validation-without-optin.tf

Lines changed: 0 additions & 7 deletions
This file was deleted.

configs/testdata/warning-files/variable_validation_experiment.tf renamed to configs/testdata/valid-files/variable_validation.tf

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
terraform {
2-
experiments = [variable_validation] # WARNING: Experimental feature "variable_validation" is active
3-
}
4-
51
variable "validation" {
62
validation {
73
condition = var.validation == 5

experiments/experiment.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const (
1919
func init() {
2020
// Each experiment constant defined above must be registered here as either
2121
// a current or a concluded experiment.
22-
registerCurrentExperiment(VariableValidation)
22+
registerConcludedExperiment(VariableValidation, "Custom variable validation can now be used by default, without enabling an experiment.")
2323
}
2424

2525
// GetCurrent takes an experiment name and returns the experiment value

terraform/context_validate_test.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1371,14 +1371,6 @@ func TestContext2Validate_variableCustomValidationsRoot(t *testing.T) {
13711371
// altogether. (Root module variables are never known during validation.)
13721372
m := testModuleInline(t, map[string]string{
13731373
"main.tf": `
1374-
# This feature is currently experimental.
1375-
# (If you're currently cleaning up after concluding the experiment,
1376-
# remember to also clean up similar references in the configs package
1377-
# under "invalid-files" and "invalid-modules".)
1378-
terraform {
1379-
experiments = [variable_validation]
1380-
}
1381-
13821374
variable "test" {
13831375
type = string
13841376

terraform/testdata/validate-variable-custom-validations-child/child/child.tf

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
# This feature is currently experimental.
2-
# (If you're currently cleaning up after concluding the experiment,
3-
# remember to also clean up similar references in the configs package
4-
# under "invalid-files" and "invalid-modules".)
5-
terraform {
6-
experiments = [variable_validation]
7-
}
8-
91
variable "test" {
102
type = string
113

0 commit comments

Comments
 (0)