mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
Merge pull request #30792 from hashicorp/alisdair/conclude-preconditions-postconditions-experiment
Conclude preconditions/postconditions experiment
This commit is contained in:
commit
6d03303b79
@ -1,7 +1,3 @@
|
|||||||
terraform {
|
|
||||||
experiments = [preconditions_postconditions]
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "ami" {
|
variable "ami" {
|
||||||
type = string
|
type = string
|
||||||
default = "ami-test"
|
default = "ami-test"
|
||||||
|
@ -209,55 +209,6 @@ func checkModuleExperiments(m *Module) hcl.Diagnostics {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !m.ActiveExperiments.Has(experiments.PreconditionsPostconditions) {
|
|
||||||
for _, r := range m.ManagedResources {
|
|
||||||
for _, c := range r.Preconditions {
|
|
||||||
diags = diags.Append(&hcl.Diagnostic{
|
|
||||||
Severity: hcl.DiagError,
|
|
||||||
Summary: "Preconditions are experimental",
|
|
||||||
Detail: "The resource preconditions 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 preconditions_postconditions to the list of active experiments.",
|
|
||||||
Subject: c.DeclRange.Ptr(),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
for _, c := range r.Postconditions {
|
|
||||||
diags = diags.Append(&hcl.Diagnostic{
|
|
||||||
Severity: hcl.DiagError,
|
|
||||||
Summary: "Postconditions are experimental",
|
|
||||||
Detail: "The resource preconditions 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 preconditions_postconditions to the list of active experiments.",
|
|
||||||
Subject: c.DeclRange.Ptr(),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for _, r := range m.DataResources {
|
|
||||||
for _, c := range r.Preconditions {
|
|
||||||
diags = diags.Append(&hcl.Diagnostic{
|
|
||||||
Severity: hcl.DiagError,
|
|
||||||
Summary: "Preconditions are experimental",
|
|
||||||
Detail: "The resource preconditions 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 preconditions_postconditions to the list of active experiments.",
|
|
||||||
Subject: c.DeclRange.Ptr(),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
for _, c := range r.Postconditions {
|
|
||||||
diags = diags.Append(&hcl.Diagnostic{
|
|
||||||
Severity: hcl.DiagError,
|
|
||||||
Summary: "Postconditions are experimental",
|
|
||||||
Detail: "The resource preconditions 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 preconditions_postconditions to the list of active experiments.",
|
|
||||||
Subject: c.DeclRange.Ptr(),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for _, o := range m.Outputs {
|
|
||||||
for _, c := range o.Preconditions {
|
|
||||||
diags = diags.Append(&hcl.Diagnostic{
|
|
||||||
Severity: hcl.DiagError,
|
|
||||||
Summary: "Preconditions are experimental",
|
|
||||||
Detail: "The output value preconditions 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 preconditions_postconditions to the list of active experiments.",
|
|
||||||
Subject: c.DeclRange.Ptr(),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return diags
|
return diags
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,34 +0,0 @@
|
|||||||
resource "test" "test" {
|
|
||||||
lifecycle {
|
|
||||||
precondition { # ERROR: Preconditions are experimental
|
|
||||||
condition = path.module != ""
|
|
||||||
error_message = "Must be true."
|
|
||||||
}
|
|
||||||
postcondition { # ERROR: Postconditions are experimental
|
|
||||||
condition = path.module != ""
|
|
||||||
error_message = "Must be true."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
data "test" "test" {
|
|
||||||
lifecycle {
|
|
||||||
precondition { # ERROR: Preconditions are experimental
|
|
||||||
condition = path.module != ""
|
|
||||||
error_message = "Must be true."
|
|
||||||
}
|
|
||||||
postcondition { # ERROR: Postconditions are experimental
|
|
||||||
condition = path.module != ""
|
|
||||||
error_message = "Must be true."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
output "test" {
|
|
||||||
value = ""
|
|
||||||
|
|
||||||
precondition { # ERROR: Preconditions are experimental
|
|
||||||
condition = path.module != ""
|
|
||||||
error_message = "Must be true."
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,7 +1,3 @@
|
|||||||
terraform {
|
|
||||||
experiments = [preconditions_postconditions] # WARNING: Experimental feature "preconditions_postconditions" is active
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "test" "test" {
|
resource "test" "test" {
|
||||||
lifecycle {
|
lifecycle {
|
||||||
precondition {
|
precondition {
|
@ -26,8 +26,8 @@ func init() {
|
|||||||
registerConcludedExperiment(VariableValidation, "Custom variable validation can now be used by default, without enabling an experiment.")
|
registerConcludedExperiment(VariableValidation, "Custom variable validation can now be used by default, without enabling an experiment.")
|
||||||
registerConcludedExperiment(SuppressProviderSensitiveAttrs, "Provider-defined sensitive attributes are now redacted by default, without enabling an experiment.")
|
registerConcludedExperiment(SuppressProviderSensitiveAttrs, "Provider-defined sensitive attributes are now redacted by default, without enabling an experiment.")
|
||||||
registerConcludedExperiment(ConfigDrivenMove, "Declarations of moved resource instances using \"moved\" blocks can now be used by default, without enabling an experiment.")
|
registerConcludedExperiment(ConfigDrivenMove, "Declarations of moved resource instances using \"moved\" blocks can now be used by default, without enabling an experiment.")
|
||||||
|
registerConcludedExperiment(PreconditionsPostconditions, "Condition blocks can now be used by default, without enabling an experiment.")
|
||||||
registerCurrentExperiment(ModuleVariableOptionalAttrs)
|
registerCurrentExperiment(ModuleVariableOptionalAttrs)
|
||||||
registerCurrentExperiment(PreconditionsPostconditions)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetCurrent takes an experiment name and returns the experiment value
|
// GetCurrent takes an experiment name and returns the experiment value
|
||||||
|
@ -741,10 +741,6 @@ resource "test_object" "b" {
|
|||||||
func TestContext2Apply_resourcePostcondition(t *testing.T) {
|
func TestContext2Apply_resourcePostcondition(t *testing.T) {
|
||||||
m := testModuleInline(t, map[string]string{
|
m := testModuleInline(t, map[string]string{
|
||||||
"main.tf": `
|
"main.tf": `
|
||||||
terraform {
|
|
||||||
experiments = [preconditions_postconditions]
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "boop" {
|
variable "boop" {
|
||||||
type = string
|
type = string
|
||||||
}
|
}
|
||||||
|
@ -2182,10 +2182,6 @@ func TestContext2Plan_moduleExpandOrphansResourceInstance(t *testing.T) {
|
|||||||
func TestContext2Plan_resourcePreconditionPostcondition(t *testing.T) {
|
func TestContext2Plan_resourcePreconditionPostcondition(t *testing.T) {
|
||||||
m := testModuleInline(t, map[string]string{
|
m := testModuleInline(t, map[string]string{
|
||||||
"main.tf": `
|
"main.tf": `
|
||||||
terraform {
|
|
||||||
experiments = [preconditions_postconditions]
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "boop" {
|
variable "boop" {
|
||||||
type = string
|
type = string
|
||||||
}
|
}
|
||||||
@ -2445,10 +2441,6 @@ resource "test_resource" "a" {
|
|||||||
func TestContext2Plan_dataSourcePreconditionPostcondition(t *testing.T) {
|
func TestContext2Plan_dataSourcePreconditionPostcondition(t *testing.T) {
|
||||||
m := testModuleInline(t, map[string]string{
|
m := testModuleInline(t, map[string]string{
|
||||||
"main.tf": `
|
"main.tf": `
|
||||||
terraform {
|
|
||||||
experiments = [preconditions_postconditions]
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "boop" {
|
variable "boop" {
|
||||||
type = string
|
type = string
|
||||||
}
|
}
|
||||||
@ -2714,10 +2706,6 @@ resource "test_resource" "a" {
|
|||||||
func TestContext2Plan_outputPrecondition(t *testing.T) {
|
func TestContext2Plan_outputPrecondition(t *testing.T) {
|
||||||
m := testModuleInline(t, map[string]string{
|
m := testModuleInline(t, map[string]string{
|
||||||
"main.tf": `
|
"main.tf": `
|
||||||
terraform {
|
|
||||||
experiments = [preconditions_postconditions]
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "boop" {
|
variable "boop" {
|
||||||
type = string
|
type = string
|
||||||
}
|
}
|
||||||
@ -2883,10 +2871,6 @@ func TestContext2Plan_preconditionErrors(t *testing.T) {
|
|||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
t.Run(tc.condition, func(t *testing.T) {
|
t.Run(tc.condition, func(t *testing.T) {
|
||||||
main := fmt.Sprintf(`
|
main := fmt.Sprintf(`
|
||||||
terraform {
|
|
||||||
experiments = [preconditions_postconditions]
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "test_resource" "a" {
|
resource "test_resource" "a" {
|
||||||
value = var.boop
|
value = var.boop
|
||||||
lifecycle {
|
lifecycle {
|
||||||
@ -2932,10 +2916,6 @@ func TestContext2Plan_preconditionSensitiveValues(t *testing.T) {
|
|||||||
|
|
||||||
m := testModuleInline(t, map[string]string{
|
m := testModuleInline(t, map[string]string{
|
||||||
"main.tf": `
|
"main.tf": `
|
||||||
terraform {
|
|
||||||
experiments = [preconditions_postconditions]
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "boop" {
|
variable "boop" {
|
||||||
sensitive = true
|
sensitive = true
|
||||||
type = string
|
type = string
|
||||||
|
@ -2109,10 +2109,6 @@ func TestContext2Validate_precondition_good(t *testing.T) {
|
|||||||
})
|
})
|
||||||
m := testModuleInline(t, map[string]string{
|
m := testModuleInline(t, map[string]string{
|
||||||
"main.tf": `
|
"main.tf": `
|
||||||
terraform {
|
|
||||||
experiments = [preconditions_postconditions]
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "input" {
|
variable "input" {
|
||||||
type = string
|
type = string
|
||||||
default = "foo"
|
default = "foo"
|
||||||
@ -2156,10 +2152,6 @@ func TestContext2Validate_precondition_badCondition(t *testing.T) {
|
|||||||
})
|
})
|
||||||
m := testModuleInline(t, map[string]string{
|
m := testModuleInline(t, map[string]string{
|
||||||
"main.tf": `
|
"main.tf": `
|
||||||
terraform {
|
|
||||||
experiments = [preconditions_postconditions]
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "input" {
|
variable "input" {
|
||||||
type = string
|
type = string
|
||||||
default = "foo"
|
default = "foo"
|
||||||
@ -2206,10 +2198,6 @@ func TestContext2Validate_precondition_badErrorMessage(t *testing.T) {
|
|||||||
})
|
})
|
||||||
m := testModuleInline(t, map[string]string{
|
m := testModuleInline(t, map[string]string{
|
||||||
"main.tf": `
|
"main.tf": `
|
||||||
terraform {
|
|
||||||
experiments = [preconditions_postconditions]
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "input" {
|
variable "input" {
|
||||||
type = string
|
type = string
|
||||||
default = "foo"
|
default = "foo"
|
||||||
@ -2256,10 +2244,6 @@ func TestContext2Validate_postcondition_good(t *testing.T) {
|
|||||||
})
|
})
|
||||||
m := testModuleInline(t, map[string]string{
|
m := testModuleInline(t, map[string]string{
|
||||||
"main.tf": `
|
"main.tf": `
|
||||||
terraform {
|
|
||||||
experiments = [preconditions_postconditions]
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "aws_instance" "test" {
|
resource "aws_instance" "test" {
|
||||||
foo = "foo"
|
foo = "foo"
|
||||||
|
|
||||||
@ -2304,10 +2288,6 @@ func TestContext2Validate_postcondition_badCondition(t *testing.T) {
|
|||||||
// an input variable.
|
// an input variable.
|
||||||
m := testModuleInline(t, map[string]string{
|
m := testModuleInline(t, map[string]string{
|
||||||
"main.tf": `
|
"main.tf": `
|
||||||
terraform {
|
|
||||||
experiments = [preconditions_postconditions]
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "input" {
|
variable "input" {
|
||||||
type = string
|
type = string
|
||||||
default = "foo"
|
default = "foo"
|
||||||
@ -2354,10 +2334,6 @@ func TestContext2Validate_postcondition_badErrorMessage(t *testing.T) {
|
|||||||
})
|
})
|
||||||
m := testModuleInline(t, map[string]string{
|
m := testModuleInline(t, map[string]string{
|
||||||
"main.tf": `
|
"main.tf": `
|
||||||
terraform {
|
|
||||||
experiments = [preconditions_postconditions]
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "aws_instance" "test" {
|
resource "aws_instance" "test" {
|
||||||
foo = "foo"
|
foo = "foo"
|
||||||
|
|
||||||
@ -2399,10 +2375,6 @@ func TestContext2Validate_precondition_count(t *testing.T) {
|
|||||||
})
|
})
|
||||||
m := testModuleInline(t, map[string]string{
|
m := testModuleInline(t, map[string]string{
|
||||||
"main.tf": `
|
"main.tf": `
|
||||||
terraform {
|
|
||||||
experiments = [preconditions_postconditions]
|
|
||||||
}
|
|
||||||
|
|
||||||
locals {
|
locals {
|
||||||
foos = ["bar", "baz"]
|
foos = ["bar", "baz"]
|
||||||
}
|
}
|
||||||
@ -2446,10 +2418,6 @@ func TestContext2Validate_postcondition_forEach(t *testing.T) {
|
|||||||
})
|
})
|
||||||
m := testModuleInline(t, map[string]string{
|
m := testModuleInline(t, map[string]string{
|
||||||
"main.tf": `
|
"main.tf": `
|
||||||
terraform {
|
|
||||||
experiments = [preconditions_postconditions]
|
|
||||||
}
|
|
||||||
|
|
||||||
locals {
|
locals {
|
||||||
foos = toset(["bar", "baz", "boop"])
|
foos = toset(["bar", "baz", "boop"])
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user