Skip to content

Commit 764650f

Browse files
committed
Change how we make PSS experimental - avoid relying on a package level variable that causes tests to interact.
1 parent 5dbf2f6 commit 764650f

File tree

2 files changed

+21
-11
lines changed

2 files changed

+21
-11
lines changed

internal/command/init_run.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"fmt"
99
"strings"
1010

11+
"github.com/hashicorp/hcl/v2"
1112
"github.com/hashicorp/terraform/internal/backend"
1213
"github.com/hashicorp/terraform/internal/cloud"
1314
"github.com/hashicorp/terraform/internal/command/arguments"
@@ -141,6 +142,22 @@ func (c *InitCommand) run(initArgs *arguments.Init, view views.Init) int {
141142

142143
return 1
143144
}
145+
if !c.Meta.AllowExperimentalFeatures && rootModEarly.StateStore != nil {
146+
// TODO(SarahFrench/radeksimko) - remove when this feature isn't experimental.
147+
// This approach for making the feature experimental is required
148+
// to let us assert the feature is gated behind an experiment in tests.
149+
// See https://github.com/hashicorp/terraform/pull/37350#issuecomment-3168555619
150+
diags = diags.Append(earlyConfDiags)
151+
diags = diags.Append(&hcl.Diagnostic{
152+
Severity: hcl.DiagError,
153+
Summary: "Unsupported block type",
154+
Detail: "Blocks of type \"state_store\" are not expected here.",
155+
Subject: &rootModEarly.StateStore.TypeRange,
156+
})
157+
view.Diagnostics(diags)
158+
159+
return 1
160+
}
144161

145162
var back backend.Backend
146163

internal/configs/parser_config.go

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,6 @@ func parseConfigFile(body hcl.Body, diags hcl.Diagnostics, override, allowExperi
104104
switch block.Type {
105105

106106
case "terraform":
107-
// TODO: Update once pluggable state store is out of experimental phase
108-
if allowExperiments {
109-
terraformBlockSchema.Blocks = append(terraformBlockSchema.Blocks,
110-
hcl.BlockHeaderSchema{
111-
Type: "state_store",
112-
LabelNames: []string{"type"},
113-
})
114-
}
115107
content, contentDiags := block.Body.Content(terraformBlockSchema)
116108
diags = append(diags, contentDiags...)
117109

@@ -394,9 +386,10 @@ var terraformBlockSchema = &hcl.BodySchema{
394386
{
395387
Type: "required_providers",
396388
},
397-
// NOTE: An entry for state_store is not present here
398-
// because we conditionally add it in the calling code
399-
// depending on whether experiments are enabled or not.
389+
{
390+
Type: "state_store",
391+
LabelNames: []string{"type"},
392+
},
400393
{
401394
Type: "provider_meta",
402395
LabelNames: []string{"provider"},

0 commit comments

Comments
 (0)