diff --git a/internal/command/arguments/init.go b/internal/command/arguments/init.go index e52d18325eef..36798cd49df6 100644 --- a/internal/command/arguments/init.go +++ b/internal/command/arguments/init.go @@ -75,11 +75,6 @@ type Init struct { Args []string - // The -enable-pluggable-state-storage-experiment flag is used in control flow logic in the init command. - // TODO(SarahFrench/radeksimko): Remove this once the feature is no longer - // experimental - EnablePssExperiment bool - // CreateDefaultWorkspace indicates whether the default workspace should be created by // Terraform when initializing a state store for the first time. CreateDefaultWorkspace bool @@ -118,9 +113,6 @@ func ParseInit(args []string, experimentsEnabled bool) (*Init, tfdiags.Diagnosti cmdFlags.Var(&init.PluginPath, "plugin-dir", "plugin directory") cmdFlags.BoolVar(&init.CreateDefaultWorkspace, "create-default-workspace", true, "when -input=false, use this flag to block creation of the default workspace") - // Used for enabling experimental code that's invoked before configuration is parsed. - cmdFlags.BoolVar(&init.EnablePssExperiment, "enable-pluggable-state-storage-experiment", false, "Enable the pluggable state storage experiment") - if err := cmdFlags.Parse(args); err != nil { diags = diags.Append(tfdiags.Sourceless( tfdiags.Error, @@ -129,10 +121,6 @@ func ParseInit(args []string, experimentsEnabled bool) (*Init, tfdiags.Diagnosti )) } - if v := os.Getenv("TF_ENABLE_PLUGGABLE_STATE_STORAGE"); v != "" { - init.EnablePssExperiment = true - } - if v := os.Getenv("TF_SKIP_CREATE_DEFAULT_WORKSPACE"); v != "" { // If TF_SKIP_CREATE_DEFAULT_WORKSPACE is set it will override // a -create-default-workspace=true flag that's set explicitly, @@ -142,13 +130,6 @@ func ParseInit(args []string, experimentsEnabled bool) (*Init, tfdiags.Diagnosti if !experimentsEnabled { // If experiments aren't enabled then these flags should not be used. - if init.EnablePssExperiment { - diags = diags.Append(tfdiags.Sourceless( - tfdiags.Error, - "Cannot use -enable-pluggable-state-storage-experiment flag without experiments enabled", - "Terraform cannot use the -enable-pluggable-state-storage-experiment flag (or TF_ENABLE_PLUGGABLE_STATE_STORAGE environment variable) unless experiments are enabled.", - )) - } if !init.CreateDefaultWorkspace { // Can only be set to false by using the flag // and we cannot identify if -create-default-workspace=true is set explicitly. @@ -158,15 +139,6 @@ func ParseInit(args []string, experimentsEnabled bool) (*Init, tfdiags.Diagnosti "Terraform cannot use the -create-default-workspace flag (or TF_SKIP_CREATE_DEFAULT_WORKSPACE environment variable) unless experiments are enabled.", )) } - } else { - // Errors using flags despite experiments being enabled. - if !init.CreateDefaultWorkspace && !init.EnablePssExperiment { - diags = diags.Append(tfdiags.Sourceless( - tfdiags.Error, - "Cannot use -create-default-workspace=false flag unless the pluggable state storage experiment is enabled", - "Terraform cannot use the -create-default-workspace=false flag (or TF_SKIP_CREATE_DEFAULT_WORKSPACE environment variable) unless you also supply the -enable-pluggable-state-storage-experiment flag (or set the TF_ENABLE_PLUGGABLE_STATE_STORAGE environment variable).", - )) - } } if init.MigrateState && init.Json { diff --git a/internal/command/arguments/init_test.go b/internal/command/arguments/init_test.go index e6df4a6faaee..4c0254cac80a 100644 --- a/internal/command/arguments/init_test.go +++ b/internal/command/arguments/init_test.go @@ -48,11 +48,13 @@ func TestParseInit_basicValid(t *testing.T) { }, }, "setting multiple options": { - []string{"-backend=false", "-force-copy=true", + []string{ + "-backend=false", "-force-copy=true", "-from-module=./main-dir", "-json", "-get=false", "-lock=false", "-lock-timeout=10s", "-reconfigure=true", "-upgrade=true", "-lockfile=readonly", "-compact-warnings=true", - "-ignore-remote-version=true", "-test-directory=./test-dir"}, + "-ignore-remote-version=true", "-test-directory=./test-dir", + }, &Init{ FromModule: "./main-dir", Lockfile: "readonly", @@ -182,18 +184,6 @@ func TestParseInit_experimentalFlags(t *testing.T) { wantErr string experimentsEnabled bool }{ - "error: -enable-pluggable-state-storage-experiment and experiments are disabled": { - args: []string{"-enable-pluggable-state-storage-experiment"}, - experimentsEnabled: false, - wantErr: "Cannot use -enable-pluggable-state-storage-experiment flag without experiments enabled", - }, - "error: TF_ENABLE_PLUGGABLE_STATE_STORAGE is set and experiments are disabled": { - envs: map[string]string{ - "TF_ENABLE_PLUGGABLE_STATE_STORAGE": "1", - }, - experimentsEnabled: false, - wantErr: "Cannot use -enable-pluggable-state-storage-experiment flag without experiments enabled", - }, "error: -create-default-workspace=false and experiments are disabled": { args: []string{"-create-default-workspace=false"}, experimentsEnabled: false, @@ -206,18 +196,6 @@ func TestParseInit_experimentalFlags(t *testing.T) { experimentsEnabled: false, wantErr: "Cannot use -create-default-workspace flag without experiments enabled", }, - "error: -create-default-workspace=false used without -enable-pluggable-state-storage-experiment, while experiments are enabled": { - args: []string{"-create-default-workspace=false"}, - experimentsEnabled: true, - wantErr: "Cannot use -create-default-workspace=false flag unless the pluggable state storage experiment is enabled", - }, - "error: TF_SKIP_CREATE_DEFAULT_WORKSPACE used without -enable-pluggable-state-storage-experiment, while experiments are enabled": { - envs: map[string]string{ - "TF_SKIP_CREATE_DEFAULT_WORKSPACE": "1", - }, - experimentsEnabled: true, - wantErr: "Cannot use -create-default-workspace=false flag unless the pluggable state storage experiment is enabled", - }, } for name, tc := range testCases { diff --git a/internal/command/e2etest/pluggable_state_store_test.go b/internal/command/e2etest/pluggable_state_store_test.go index 66865804c748..9fe1fb4cd471 100644 --- a/internal/command/e2etest/pluggable_state_store_test.go +++ b/internal/command/e2etest/pluggable_state_store_test.go @@ -106,7 +106,6 @@ func TestPrimary_stateStore_unmanaged_separatePlan(t *testing.T) { t.Chdir(tf.WorkDir()) //// INIT - t.Setenv("TF_ENABLE_PLUGGABLE_STATE_STORAGE", "1") stdout, stderr, err := tf.Run("init") if err != nil { t.Fatalf("unexpected init error: %s\nstderr:\n%s\nstdout:\n%s", err, stderr, stdout) @@ -207,7 +206,7 @@ func TestPrimary_stateStore_workspaceCmd(t *testing.T) { } //// Init - _, stderr, err := tf.Run("init", "-enable-pluggable-state-storage-experiment=true", "-plugin-dir=cache", "-no-color") + _, stderr, err := tf.Run("init", "-plugin-dir=cache", "-no-color") if err != nil { t.Fatalf("unexpected error: %s\nstderr:\n%s", err, stderr) } @@ -636,7 +635,7 @@ func TestPrimary_stateStore_providerCmds(t *testing.T) { } //// Init - _, stderr, err := tf.Run("init", "-enable-pluggable-state-storage-experiment=true", "-plugin-dir=cache", "-no-color") + _, stderr, err := tf.Run("init", "-plugin-dir=cache", "-no-color") if err != nil { t.Fatalf("unexpected error: %s\nstderr:\n%s", err, stderr) } diff --git a/internal/command/e2etest/primary_test.go b/internal/command/e2etest/primary_test.go index 583691c1107c..3e7ea83de5cf 100644 --- a/internal/command/e2etest/primary_test.go +++ b/internal/command/e2etest/primary_test.go @@ -146,7 +146,6 @@ func TestPrimarySeparatePlan(t *testing.T) { if len(stateResources) != 0 { t.Errorf("wrong resources in state after destroy; want none, but still have:%s", spew.Sdump(stateResources)) } - } func TestPrimaryChdirOption(t *testing.T) { @@ -236,7 +235,6 @@ func TestPrimaryChdirOption(t *testing.T) { } func TestPrimary_stateStore(t *testing.T) { - if !canRunGoBuild { // We're running in a separate-build-then-run context, so we can't // currently execute this test which depends on being able to build @@ -270,7 +268,7 @@ func TestPrimary_stateStore(t *testing.T) { } //// INIT - stdout, stderr, err := tf.Run("init", "-enable-pluggable-state-storage-experiment=true", "-plugin-dir=cache", "-no-color") + stdout, stderr, err := tf.Run("init", "-plugin-dir=cache", "-no-color") if err != nil { t.Fatalf("unexpected init error: %s\nstderr:\n%s", err, stderr) } @@ -315,7 +313,6 @@ func TestPrimary_stateStore(t *testing.T) { } func TestPrimary_stateStore_planFile(t *testing.T) { - if !canRunGoBuild { // We're running in a separate-build-then-run context, so we can't // currently execute this test which depends on being able to build @@ -348,7 +345,7 @@ func TestPrimary_stateStore_planFile(t *testing.T) { } //// INIT - stdout, stderr, err := tf.Run("init", "-enable-pluggable-state-storage-experiment=true", "-plugin-dir=cache", "-no-color") + stdout, stderr, err := tf.Run("init", "-plugin-dir=cache", "-no-color") if err != nil { t.Fatalf("unexpected init error: %s\nstderr:\n%s", err, stderr) } @@ -432,7 +429,7 @@ func TestPrimary_stateStore_inMem(t *testing.T) { // // Note - the inmem PSS implementation means that the default workspace state created during init // is lost as soon as the command completes. - stdout, stderr, err := tf.Run("init", "-enable-pluggable-state-storage-experiment=true", "-plugin-dir=cache", "-no-color") + stdout, stderr, err := tf.Run("init", "-plugin-dir=cache", "-no-color") if err != nil { t.Fatalf("unexpected init error: %s\nstderr:\n%s", err, stderr) } diff --git a/internal/command/init.go b/internal/command/init.go index 6bcb08c5ff7d..3f408151d7d4 100644 --- a/internal/command/init.go +++ b/internal/command/init.go @@ -561,7 +561,6 @@ func (c *InitCommand) getProvidersFromState(ctx context.Context, state *states.S // The calling code is expected to provide the previous locks (if any) and the two sets of locks determined from // configuration and state data. func (c *InitCommand) saveDependencyLockFile(previousLocks, configLocks, stateLocks *depsfile.Locks, flagLockfile string, view views.Init) (output bool, diags tfdiags.Diagnostics) { - // Get the combination of config and state locks newLocks := c.mergeLockedDependencies(configLocks, stateLocks) @@ -631,7 +630,6 @@ func (c *InitCommand) saveDependencyLockFile(previousLocks, configLocks, stateLo // when a specific type of event occurs during provider installation. // The calling code needs to provide a tfdiags.Diagnostics collection, so that provider installation code returns diags to the calling code using closures func (c *InitCommand) prepareInstallerEvents(ctx context.Context, reqs providerreqs.Requirements, diags *tfdiags.Diagnostics, inst *providercache.Installer, view views.Init, initMsg views.InitMessageCode, reuseMsg views.InitMessageCode) *providercache.InstallerEvents { - // Because we're currently just streaming a series of events sequentially // into the terminal, we're showing only a subset of the events to keep // things relatively concise. Later it'd be nice to have a progress UI @@ -758,7 +756,6 @@ func (c *InitCommand) prepareInstallerEvents(ctx context.Context, reqs providerr ), )) } - }, QueryPackagesWarning: func(provider addrs.Provider, warnings []string) { displayWarnings := make([]string, len(warnings)) @@ -1148,10 +1145,6 @@ Options: Use this option more than once to include more than one variables file. - -enable-pluggable-state-storage-experiment [EXPERIMENTAL] - A flag to enable an alternative init command that allows use of - pluggable state storage. Only usable with experiments enabled. - -create-default-workspace [EXPERIMENTAL] This flag must be used alongside the -enable-pluggable-state-storage- experiment flag with experiments enabled. This flag's value defaults diff --git a/internal/command/init_run.go b/internal/command/init_run.go index d63013f94eda..1b919b49ac7a 100644 --- a/internal/command/init_run.go +++ b/internal/command/init_run.go @@ -134,28 +134,17 @@ func (c *InitCommand) run(initArgs *arguments.Init, view views.Init) int { return 1 } - if !(c.Meta.AllowExperimentalFeatures && initArgs.EnablePssExperiment) && rootModEarly.StateStore != nil { + if !c.Meta.AllowExperimentalFeatures && rootModEarly.StateStore != nil { // TODO(SarahFrench/radeksimko) - remove when this feature isn't experimental. // This approach for making the feature experimental is required // to let us assert the feature is gated behind an experiment in tests. // See https://github.com/hashicorp/terraform/pull/37350#issuecomment-3168555619 - detail := "Pluggable state store is an experiment which requires" - if !c.Meta.AllowExperimentalFeatures { - detail += " an experimental build of terraform" - } - if !initArgs.EnablePssExperiment { - if !c.Meta.AllowExperimentalFeatures { - detail += " and" - } - detail += " -enable-pluggable-state-storage-experiment flag" - } - diags = diags.Append(earlyConfDiags) diags = diags.Append(&hcl.Diagnostic{ Severity: hcl.DiagError, Summary: "Pluggable state store experiment not supported", - Detail: detail, + Detail: "Pluggable state store is an experiment which requires an experimental build of terraform", Subject: &rootModEarly.StateStore.TypeRange, }) view.Diagnostics(diags) diff --git a/internal/command/init_test.go b/internal/command/init_test.go index 5216dcfb1e7d..3538eef7f566 100644 --- a/internal/command/init_test.go +++ b/internal/command/init_test.go @@ -232,8 +232,7 @@ func TestInit_two_step_provider_download(t *testing.T) { }, } - args := append(tc.flags, "-enable-pluggable-state-storage-experiment") // Needed to test init changes for PSS project - if code := c.Run(args); code != 0 { + if code := c.Run(tc.flags); code != 0 { t.Fatalf("bad: \n%s", done(t).All()) } @@ -3483,7 +3482,7 @@ func TestInit_stateStore_newWorkingDir(t *testing.T) { Meta: meta, } - args := []string{"-enable-pluggable-state-storage-experiment=true"} + args := []string{} code := c.Run(args) testOutput := done(t) if code != 0 { @@ -3536,7 +3535,7 @@ func TestInit_stateStore_newWorkingDir(t *testing.T) { Meta: meta, } - args := []string{"-enable-pluggable-state-storage-experiment=true"} + args := []string{} code := c.Run(args) testOutput := done(t) if code != 0 { @@ -3620,7 +3619,7 @@ func TestInit_stateStore_newWorkingDir(t *testing.T) { }, } - args := []string{"-enable-pluggable-state-storage-experiment=true", "-create-default-workspace=false"} + args := []string{"-create-default-workspace=false"} code := c.Run(args) testOutput := done(t) if code != 0 { @@ -3670,7 +3669,7 @@ func TestInit_stateStore_newWorkingDir(t *testing.T) { } t.Setenv("TF_SKIP_CREATE_DEFAULT_WORKSPACE", "1") // any value - args := []string{"-enable-pluggable-state-storage-experiment=true"} + args := []string{} code := c.Run(args) testOutput := done(t) if code != 0 { @@ -3725,7 +3724,7 @@ func TestInit_stateStore_newWorkingDir(t *testing.T) { Meta: meta, } - args := []string{"-enable-pluggable-state-storage-experiment=true"} + args := []string{} code := c.Run(args) testOutput := done(t) if code != 1 { @@ -3802,7 +3801,6 @@ func TestInit_stateStore_newWorkingDir(t *testing.T) { // If input is disabled users receive an error about the missing workspace args := []string{ - "-enable-pluggable-state-storage-experiment=true", "-input=false", } code := c.Run(args) @@ -3874,9 +3872,7 @@ func TestInit_stateStore_newWorkingDir(t *testing.T) { Meta: meta, } - args := []string{ - "-enable-pluggable-state-storage-experiment=true", - } + args := []string{} code := c.Run(args) testOutput := done(t) if code != 0 { @@ -3971,9 +3967,7 @@ func TestInit_stateStore_configUnchanged(t *testing.T) { } // Run init command - args := []string{ - "-enable-pluggable-state-storage-experiment=true", - } + args := []string{} code := c.Run(args) testOutput := done(t) if code != 0 { @@ -4043,7 +4037,6 @@ func TestInit_stateStore_configChanges(t *testing.T) { } args := []string{ - "-enable-pluggable-state-storage-experiment=true", "-reconfigure", } code := c.Run(args) @@ -4131,7 +4124,6 @@ func TestInit_stateStore_configChanges(t *testing.T) { } args := []string{ - "-enable-pluggable-state-storage-experiment=true", "-backend=false", } code := c.Run(args) @@ -4188,7 +4180,6 @@ func TestInit_stateStore_configChanges(t *testing.T) { } args := []string{ - "-enable-pluggable-state-storage-experiment=true", // missing -migrate-state flag } code := c.Run(args) @@ -4241,7 +4232,6 @@ func TestInit_stateStore_configChanges(t *testing.T) { } args := []string{ - "-enable-pluggable-state-storage-experiment=true", "-force-copy", } code := c.Run(args) @@ -4303,7 +4293,6 @@ func TestInit_stateStore_configChanges(t *testing.T) { } args := []string{ - "-enable-pluggable-state-storage-experiment=true", "-force-copy", } code := c.Run(args) @@ -4369,7 +4358,6 @@ func TestInit_stateStore_configChanges(t *testing.T) { } args := []string{ - "-enable-pluggable-state-storage-experiment=true", "-force-copy", } code := c.Run(args) @@ -4440,7 +4428,6 @@ func TestInit_stateStore_configChanges(t *testing.T) { } args := []string{ - "-enable-pluggable-state-storage-experiment=true", "-force-copy", } code := c.Run(args) @@ -4509,7 +4496,6 @@ func TestInit_stateStore_providerUpgrade(t *testing.T) { } args := []string{ - "-enable-pluggable-state-storage-experiment=true", "-migrate-state=true", "-upgrade", } @@ -4578,9 +4564,7 @@ func TestInit_stateStore_backendConfigFlagNoMigrate(t *testing.T) { } // Init - args := []string{ - "-enable-pluggable-state-storage-experiment=true", - } + args := []string{} code := c.Run(args) testOutput := done(t) if code != 0 { @@ -4629,7 +4613,6 @@ func TestInit_stateStore_backendConfigFlagNoMigrate(t *testing.T) { } args := []string{ - "-enable-pluggable-state-storage-experiment=true", "-backend-config=value=foobar", // value = foobar, matches the line removed from config } code := c.Run(args) @@ -4688,9 +4671,7 @@ func TestInit_stateStore_unset(t *testing.T) { } // Init - args := []string{ - "-enable-pluggable-state-storage-experiment=true", - } + args := []string{} code := c.Run(args) testOutput := done(t) if code != 0 { @@ -4730,7 +4711,6 @@ func TestInit_stateStore_unset(t *testing.T) { } args := []string{ - "-enable-pluggable-state-storage-experiment=true", "-force-copy", } code := c.Run(args) @@ -4789,9 +4769,7 @@ func TestInit_stateStore_unset_withoutProviderRequirements(t *testing.T) { } // Init - args := []string{ - "-enable-pluggable-state-storage-experiment=true", - } + args := []string{} code := c.Run(args) testOutput := done(t) if code != 0 { @@ -4832,7 +4810,6 @@ func TestInit_stateStore_unset_withoutProviderRequirements(t *testing.T) { } args := []string{ - "-enable-pluggable-state-storage-experiment=true", "-force-copy", } code := c.Run(args) @@ -4887,9 +4864,7 @@ func TestInit_stateStore_to_backend(t *testing.T) { AllowExperimentalFeatures: true, }, } - args := []string{ - "-enable-pluggable-state-storage-experiment=true", - } + args := []string{} code := c.Run(args) testOutput := done(t) if code != 0 { @@ -5005,7 +4980,6 @@ func TestInit_stateStore_to_backend(t *testing.T) { } args := []string{ - "-enable-pluggable-state-storage-experiment=true", "-migrate-state", "-force-copy", } @@ -5153,9 +5127,7 @@ func TestInit_backend_to_stateStore_singleWorkspace(t *testing.T) { AllowExperimentalFeatures: true, }, } - args := []string{ - "-enable-pluggable-state-storage-experiment=true", - } + args := []string{} code := c.Run(args) testOutput := done(t) if code != 0 { @@ -5259,7 +5231,6 @@ func TestInit_backend_to_stateStore_singleWorkspace(t *testing.T) { } args := []string{ - "-enable-pluggable-state-storage-experiment=true", "-force-copy", } code := c.Run(args) @@ -5353,9 +5324,7 @@ func TestInit_backend_to_stateStore_noState(t *testing.T) { AllowExperimentalFeatures: true, }, } - args := []string{ - "-enable-pluggable-state-storage-experiment=true", - } + args := []string{} code := c.Run(args) testOutput := done(t) if code != 0 { @@ -5404,7 +5373,6 @@ func TestInit_backend_to_stateStore_noState(t *testing.T) { } args := []string{ - "-enable-pluggable-state-storage-experiment=true", "-force-copy", } code := c.Run(args) @@ -5469,9 +5437,7 @@ func TestInit_localBackend_to_stateStore(t *testing.T) { AllowExperimentalFeatures: true, }, } - args := []string{ - "-enable-pluggable-state-storage-experiment=true", - } + args := []string{} code := c.Run(args) testOutput := done(t) if code != 0 { @@ -5567,7 +5533,6 @@ func TestInit_localBackend_to_stateStore(t *testing.T) { } args := []string{ - "-enable-pluggable-state-storage-experiment=true", "-force-copy", } code := c.Run(args) @@ -5657,9 +5622,7 @@ func TestInit_backend_to_stateStore_multipleWorkspaces(t *testing.T) { AllowExperimentalFeatures: true, }, } - args := []string{ - "-enable-pluggable-state-storage-experiment=true", - } + args := []string{} code := c.Run(args) testOutput := done(t) if code != 0 { @@ -5798,7 +5761,6 @@ func TestInit_backend_to_stateStore_multipleWorkspaces(t *testing.T) { } args := []string{ - "-enable-pluggable-state-storage-experiment=true", "-force-copy", "-migrate-state", } @@ -5942,9 +5904,7 @@ func TestInit_cloud_to_stateStore(t *testing.T) { AllowExperimentalFeatures: true, }, } - args := []string{ - "-enable-pluggable-state-storage-experiment=true", - } + args := []string{} code := c.Run(args) testOutput := done(t) if code != 0 { @@ -5986,9 +5946,7 @@ func TestInit_cloud_to_stateStore(t *testing.T) { }, } - args := []string{ - "-enable-pluggable-state-storage-experiment=true", - } + args := []string{} code := c.Run(args) testOutput := done(t) if code == 0 { @@ -6037,7 +5995,7 @@ func TestInit_configErrorsImpactingStateStore(t *testing.T) { } log.Printf("[TRACE] TestInit_configErrorsImpactingStateStore: init start") - args := []string{"-enable-pluggable-state-storage-experiment"} + args := []string{} code := initCmd.Run(args) testOutput := done(t) if code != 1 { diff --git a/internal/command/workspace_command_test.go b/internal/command/workspace_command_test.go index ca90168399f1..908d20c025d2 100644 --- a/internal/command/workspace_command_test.go +++ b/internal/command/workspace_command_test.go @@ -55,7 +55,7 @@ func TestWorkspace_allCommands_pluggableStateStore(t *testing.T) { intCmd := &InitCommand{ Meta: meta, } - args := []string{"-enable-pluggable-state-storage-experiment"} // Needed to test init changes for PSS project + args := []string{} code := intCmd.Run(args) if code != 0 { t.Fatalf("bad: %d\n\n%s\n%s", code, ui.ErrorWriter, ui.OutputWriter)