allow language experiments for terraform show

pull/37389/head
Daniel Schmidt 10 months ago
parent ccd89c58b2
commit fb0445faf2

@ -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")
}

@ -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())
}

@ -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)

@ -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()
}

Loading…
Cancel
Save