Skip to content

Commit 138bc44

Browse files
committed
Add -enable-pss flag to the init command, to be used for accessing experimental init logic
1 parent 8d37274 commit 138bc44

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

internal/command/arguments/init.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ type Init struct {
7373
PluginPath FlagStringSlice
7474

7575
Args []string
76+
77+
// The -enable-pss flag is used in control flow logic in the init command.
78+
// TODO(SarahFrench/radeksimko): Remove this once the feature is no longer
79+
// experimental
80+
EnablePssExperiment bool
7681
}
7782

7883
// ParseInit processes CLI arguments, returning an Init value and errors.
@@ -107,6 +112,9 @@ func ParseInit(args []string) (*Init, tfdiags.Diagnostics) {
107112
cmdFlags.Var(&init.BackendConfig, "backend-config", "")
108113
cmdFlags.Var(&init.PluginPath, "plugin-dir", "plugin directory")
109114

115+
// Used for enabling experimental code that's invoked before configuration is parsed.
116+
cmdFlags.BoolVar(&init.EnablePssExperiment, "enable-pss", false, "Enable the PSS experiment")
117+
110118
if err := cmdFlags.Parse(args); err != nil {
111119
diags = diags.Append(tfdiags.Sourceless(
112120
tfdiags.Error,

internal/command/init.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,16 @@ func (c *InitCommand) Run(args []string) int {
5050
view.Diagnostics(diags)
5151
return 1
5252
}
53+
54+
// The else condition below invokes the original logic of the init command.
55+
// An experimental version of the init code will be used if:
56+
// > The user uses an experimental version of TF (alpha or built from source)
57+
// > The flag -enable-pss is passed to the init command.
58+
if c.Meta.AllowExperimentalFeatures && initArgs.EnablePssExperiment {
59+
// TODO(SarahFrench/radeksimko): Remove forked init logic once feature is no longer experimental
60+
panic("pss: experimental init code hasn't been added yet")
61+
} else {
62+
}
5363
return c.run(initArgs, view)
5464
}
5565

0 commit comments

Comments
 (0)