@@ -62,20 +62,21 @@ func (c *InitCommand) Run(args []string) int {
6262 view .Diagnostics (diags )
6363 return 1
6464 }
65- rootMod , _ := c .loadSingleModuleWithTests (path , initArgs .TestsDirectory )
66- // We purposefully ignore any diagnostics returned here. They will be encountered downstream,
67- // when the 'run' logic below is executed. If we return early due to error diagnostics here we
68- // will break the order that errors are expected to be raised in.
65+ rootMod , rootModDiags := c .loadSingleModuleWithTests (path , initArgs .TestsDirectory )
66+ // We purposefully don't exit early if there are error diagnostics returned here; there are errors related to the Terraform version
67+ // that have precedence and are detected downstream.
68+ // We pass the configuration and diagnostic values from here into downstream code, replacing where the files are parsed there.
69+ // This prevents the diagnostics being lost, as re-parsing the same config results in lost diagnostics.
6970
7071 // The else condition below invokes the original logic of the init command.
7172 // An experimental version of the init code will be used if:
7273 // > The user uses an experimental version of TF (alpha or built from source).
7374 // > The terraform block in the configuration lists the `pluggable_state_stores` experiment.
7475 if c .Meta .AllowExperimentalFeatures && rootMod .ActiveExperiments .Has (experiments .PluggableStateStores ) {
7576 // TODO(SarahFrench/radeksimko): Remove forked init logic once feature is no longer experimental
76- return c .runPssInit (initArgs , view )
77+ return c .runPssInit (initArgs , view , rootMod , rootModDiags )
7778 } else {
78- return c .run (initArgs , view )
79+ return c .run (initArgs , view , rootMod , rootModDiags )
7980 }
8081}
8182
@@ -1488,10 +1489,11 @@ Options:
14881489 -test-directory=path Set the Terraform test directory, defaults to "tests".
14891490
14901491 -create-default-workspace [EXPERIMENTAL]
1491- This flag must be used alongside the -enable-pluggable-state-storage-
1492- experiment flag with experiments enabled. This flag's value defaults
1493- to true, which allows the default workspace to be created if it does
1494- not exist. Use -create-default-workspace=false to disable this behavior.
1492+ This flag must be used alongside naming the pluggable_state_stores
1493+ experiment in your configuration and using an experimental build of
1494+ Terraform. This flag's value defaults to true, which allows the default
1495+ workspace to be created if it does not exist.
1496+ Use -create-default-workspace=false to disable this behavior.
14951497
14961498`
14971499 return strings .TrimSpace (helpText )
0 commit comments