diff --git a/internal/command/show.go b/internal/command/show.go index 9e624a915d..d5b76163e0 100644 --- a/internal/command/show.go +++ b/internal/command/show.go @@ -267,7 +267,7 @@ func (c *ShowCommand) getPlanFromPath(path string) (*plans.Plan, *cloudplan.Remo } if lp, ok := pf.Local(); ok { - plan, stateFile, config, err = getDataFromPlanfileReader(lp) + plan, stateFile, config, err = getDataFromPlanfileReader(lp, c.Meta.AllowExperimentalFeatures) } else if cp, ok := pf.Cloud(); ok { redacted := c.viewType != arguments.ViewJSON jsonPlan, err = c.getDataFromCloudPlan(cp, redacted) @@ -297,7 +297,7 @@ func (c *ShowCommand) getDataFromCloudPlan(plan *cloudplan.SavedPlanBookmark, re } // getDataFromPlanfileReader returns a plan, statefile, and config, extracted from a local plan file. -func getDataFromPlanfileReader(planReader *planfile.Reader) (*plans.Plan, *statefile.File, *configs.Config, error) { +func getDataFromPlanfileReader(planReader *planfile.Reader, allowLanguageExperiments bool) (*plans.Plan, *statefile.File, *configs.Config, error) { // Get plan plan, err := planReader.ReadPlan() if err != nil { @@ -311,7 +311,7 @@ func getDataFromPlanfileReader(planReader *planfile.Reader) (*plans.Plan, *state } // Get config - config, diags := planReader.ReadConfig() + config, diags := planReader.ReadConfig(allowLanguageExperiments) if diags.HasErrors() { return nil, nil, nil, errUnusable(diags.Err(), "local plan") } diff --git a/internal/plans/planfile/planfile_test.go b/internal/plans/planfile/planfile_test.go index b2819be8d8..923ed3b0ba 100644 --- a/internal/plans/planfile/planfile_test.go +++ b/internal/plans/planfile/planfile_test.go @@ -159,7 +159,7 @@ func TestRoundtrip(t *testing.T) { // Reading from snapshots is tested in the configload package, so // here we'll just test that we can successfully do it, to see if the // glue code in _this_ package is correct. - _, diags := pr.ReadConfig() + _, diags := pr.ReadConfig(false) if diags.HasErrors() { t.Errorf("when reading config: %s", diags.Err()) } diff --git a/internal/plans/planfile/reader.go b/internal/plans/planfile/reader.go index f5aad59d11..1c8498b281 100644 --- a/internal/plans/planfile/reader.go +++ b/internal/plans/planfile/reader.go @@ -196,7 +196,7 @@ func (r *Reader) ReadConfigSnapshot() (*configload.Snapshot, error) { // Internally this function delegates to the configs/configload package to // parse the embedded configuration and so it returns diagnostics (rather than // a native Go error as with other methods on Reader). -func (r *Reader) ReadConfig() (*configs.Config, tfdiags.Diagnostics) { +func (r *Reader) ReadConfig(allowLanguageExperiments bool) (*configs.Config, tfdiags.Diagnostics) { var diags tfdiags.Diagnostics snap, err := r.ReadConfigSnapshot() @@ -210,6 +210,7 @@ func (r *Reader) ReadConfig() (*configs.Config, tfdiags.Diagnostics) { } loader := configload.NewLoaderFromSnapshot(snap) + loader.AllowLanguageExperiments(allowLanguageExperiments) rootDir := snap.Modules[""].Dir // Root module base directory config, configDiags := loader.LoadConfig(rootDir) diags = diags.Append(configDiags) diff --git a/internal/terraform/context_test.go b/internal/terraform/context_test.go index 358fb1e333..99075894df 100644 --- a/internal/terraform/context_test.go +++ b/internal/terraform/context_test.go @@ -807,7 +807,7 @@ func contextOptsForPlanViaFile(t *testing.T, configSnap *configload.Snapshot, pl return nil, nil, nil, err } - config, diags := pr.ReadConfig() + config, diags := pr.ReadConfig(false) if diags.HasErrors() { return nil, nil, nil, diags.Err() }