From 94cbc8fb5d19edee9f86dd12a3d787f2a73497f3 Mon Sep 17 00:00:00 2001 From: Martin Atkins Date: Fri, 29 Oct 2021 14:48:23 -0700 Subject: [PATCH] experiments: config_driven_move has concluded Based on feedback during earlier alpha releases, we've decided to move forward with the current design for the first phase of config-driven refactoring. Therefore here we've marked the experiment as concluded with no changes to the most recent incarnation of the functionality. The other changes here are all just updating test fixtures to no longer declare that they are using experimental features. --- .../command/testdata/show-json/moved-drift/main.tf | 4 ---- internal/command/testdata/show-json/moved/main.tf | 4 ---- internal/configs/experiments.go | 11 ----------- .../config-driven-move-experiment.tf | 7 ------- .../valid-modules/moved-blocks/moved-blocks-1.tf | 5 ----- internal/experiments/experiment.go | 2 +- internal/refactoring/move_statement_test.go | 12 ++++++------ .../move-statement-implied/move-statement-implied.tf | 4 ---- internal/terraform/context_plan2_test.go | 12 ------------ 9 files changed, 7 insertions(+), 54 deletions(-) delete mode 100644 internal/configs/testdata/invalid-modules/config-driven-move-experiment/config-driven-move-experiment.tf diff --git a/internal/command/testdata/show-json/moved-drift/main.tf b/internal/command/testdata/show-json/moved-drift/main.tf index afdf9fe668..9f93a109f8 100644 --- a/internal/command/testdata/show-json/moved-drift/main.tf +++ b/internal/command/testdata/show-json/moved-drift/main.tf @@ -12,10 +12,6 @@ resource "test_instance" "should_refresh_with_move" { ami = "baz" } -terraform { - experiments = [ config_driven_move ] -} - moved { from = test_instance.should_refresh to = test_instance.should_refresh_with_move diff --git a/internal/command/testdata/show-json/moved/main.tf b/internal/command/testdata/show-json/moved/main.tf index 0be803cbc9..0f11c2c0a4 100644 --- a/internal/command/testdata/show-json/moved/main.tf +++ b/internal/command/testdata/show-json/moved/main.tf @@ -2,10 +2,6 @@ resource "test_instance" "baz" { ami = "baz" } -terraform { - experiments = [ config_driven_move ] -} - moved { from = test_instance.foo to = test_instance.baz diff --git a/internal/configs/experiments.go b/internal/configs/experiments.go index 4b8f10c412..2ebf2d7006 100644 --- a/internal/configs/experiments.go +++ b/internal/configs/experiments.go @@ -209,17 +209,6 @@ func checkModuleExperiments(m *Module) hcl.Diagnostics { } } - if !m.ActiveExperiments.Has(experiments.ConfigDrivenMove) { - for _, mc := range m.Moved { - diags = diags.Append(&hcl.Diagnostic{ - Severity: hcl.DiagError, - Summary: "Config-driven move is experimental", - Detail: "This feature is currently under development and is not yet fully-functional.\n\nIf you'd like to try the partial implementation that exists so far, add config_driven_move to the set of active experiments for this module.", - Subject: mc.DeclRange.Ptr(), - }) - } - } - return diags } diff --git a/internal/configs/testdata/invalid-modules/config-driven-move-experiment/config-driven-move-experiment.tf b/internal/configs/testdata/invalid-modules/config-driven-move-experiment/config-driven-move-experiment.tf deleted file mode 100644 index 03a65c99e0..0000000000 --- a/internal/configs/testdata/invalid-modules/config-driven-move-experiment/config-driven-move-experiment.tf +++ /dev/null @@ -1,7 +0,0 @@ -# This is currently invalid alone because config-driven move requires the -# "config_driven_move" experiment. We can remove this test case altogther -# if moved blocks of this sort graduate to being stable. -moved { - from = a.b - to = c.d -} diff --git a/internal/configs/testdata/valid-modules/moved-blocks/moved-blocks-1.tf b/internal/configs/testdata/valid-modules/moved-blocks/moved-blocks-1.tf index 928b1c10b4..fab882d7f4 100644 --- a/internal/configs/testdata/valid-modules/moved-blocks/moved-blocks-1.tf +++ b/internal/configs/testdata/valid-modules/moved-blocks/moved-blocks-1.tf @@ -1,8 +1,3 @@ -terraform { - # For the moment this is experimental - experiments = [config_driven_move] -} - moved { from = test.foo to = test.bar diff --git a/internal/experiments/experiment.go b/internal/experiments/experiment.go index 5bc337b844..747e9adc93 100644 --- a/internal/experiments/experiment.go +++ b/internal/experiments/experiment.go @@ -24,8 +24,8 @@ func init() { // a current or a concluded 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(ConfigDrivenMove, "Declarations of moved resource instances using \"moved\" blocks can now be used by default, without enabling an experiment.") registerCurrentExperiment(ModuleVariableOptionalAttrs) - registerCurrentExperiment(ConfigDrivenMove) } // GetCurrent takes an experiment name and returns the experiment value diff --git a/internal/refactoring/move_statement_test.go b/internal/refactoring/move_statement_test.go index 9724b1fe1c..c6f7c2d79d 100644 --- a/internal/refactoring/move_statement_test.go +++ b/internal/refactoring/move_statement_test.go @@ -97,8 +97,8 @@ func TestImpliedMoveStatements(t *testing.T) { Implied: true, DeclRange: tfdiags.SourceRange{ Filename: "testdata/move-statement-implied/move-statement-implied.tf", - Start: tfdiags.SourcePos{Line: 9, Column: 1, Byte: 232}, - End: tfdiags.SourcePos{Line: 9, Column: 32, Byte: 263}, + Start: tfdiags.SourcePos{Line: 5, Column: 1, Byte: 180}, + End: tfdiags.SourcePos{Line: 5, Column: 32, Byte: 211}, }, }, { @@ -107,8 +107,8 @@ func TestImpliedMoveStatements(t *testing.T) { Implied: true, DeclRange: tfdiags.SourceRange{ Filename: "testdata/move-statement-implied/move-statement-implied.tf", - Start: tfdiags.SourcePos{Line: 14, Column: 11, Byte: 334}, - End: tfdiags.SourcePos{Line: 14, Column: 12, Byte: 335}, + Start: tfdiags.SourcePos{Line: 10, Column: 11, Byte: 282}, + End: tfdiags.SourcePos{Line: 10, Column: 12, Byte: 283}, }, }, @@ -123,8 +123,8 @@ func TestImpliedMoveStatements(t *testing.T) { Implied: true, DeclRange: tfdiags.SourceRange{ Filename: "testdata/move-statement-implied/move-statement-implied.tf", - Start: tfdiags.SourcePos{Line: 50, Column: 1, Byte: 858}, - End: tfdiags.SourcePos{Line: 50, Column: 27, Byte: 884}, + Start: tfdiags.SourcePos{Line: 46, Column: 1, Byte: 806}, + End: tfdiags.SourcePos{Line: 46, Column: 27, Byte: 832}, }, }, } diff --git a/internal/refactoring/testdata/move-statement-implied/move-statement-implied.tf b/internal/refactoring/testdata/move-statement-implied/move-statement-implied.tf index 142ffe702a..498ead3059 100644 --- a/internal/refactoring/testdata/move-statement-implied/move-statement-implied.tf +++ b/internal/refactoring/testdata/move-statement-implied/move-statement-implied.tf @@ -2,10 +2,6 @@ # conforms to the statements encoded in the resource names. It's for # TestImpliedMoveStatements only. -terraform { - experiments = [config_driven_move] -} - resource "foo" "formerly_count" { # but not count anymore } diff --git a/internal/terraform/context_plan2_test.go b/internal/terraform/context_plan2_test.go index 9552a3ca72..85872ac533 100644 --- a/internal/terraform/context_plan2_test.go +++ b/internal/terraform/context_plan2_test.go @@ -740,10 +740,6 @@ func TestContext2Plan_movedResourceBasic(t *testing.T) { from = test_object.a to = test_object.b } - - terraform { - experiments = [config_driven_move] - } `, }) @@ -1026,10 +1022,6 @@ func TestContext2Plan_movedResourceUntargeted(t *testing.T) { from = test_object.a to = test_object.b } - - terraform { - experiments = [config_driven_move] - } `, }) @@ -1222,10 +1214,6 @@ func TestContext2Plan_movedResourceRefreshOnly(t *testing.T) { from = test_object.a to = test_object.b } - - terraform { - experiments = [config_driven_move] - } `, })