Static Evaluation Base, Module Sources, Backend Config (#1718)

Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
Signed-off-by: Christian Mesh <cristianmesh1@gmail.com>
Co-authored-by: James Humphries <James@james-humphries.co.uk>
Co-authored-by: Oleksandr Levchenkov <ollevche@gmail.com>
This commit is contained in:
Christian Mesh
2024-06-24 09:13:07 -04:00
committed by GitHub
parent ab289fc07c
commit 8f8e0aa4aa
88 changed files with 1556 additions and 404 deletions

View File

@@ -283,7 +283,9 @@ type Operation struct {
AutoApprove bool
Targets []addrs.Targetable
ForceReplace []addrs.AbsResourceInstance
Variables map[string]UnparsedVariableValue
// Injected by the command creating the operation (plan/apply/refresh/etc...)
Variables map[string]UnparsedVariableValue
RootCall configs.StaticModuleCall
// Some operations use root module variables only opportunistically or
// don't need them at all. If this flag is set, the backend must treat
@@ -326,15 +328,6 @@ func (o *Operation) HasConfig() bool {
return o.ConfigLoader.IsConfigDir(o.ConfigDir)
}
// Config loads the configuration that the operation applies to, using the
// ConfigDir and ConfigLoader fields within the receiving operation.
func (o *Operation) Config() (*configs.Config, tfdiags.Diagnostics) {
var diags tfdiags.Diagnostics
config, hclDiags := o.ConfigLoader.LoadConfig(o.ConfigDir)
diags = diags.Append(hclDiags)
return config, diags
}
// ReportResult is a helper for the common chore of setting the status of
// a running operation and showing any diagnostics produced during that
// operation.

View File

@@ -145,7 +145,7 @@ func (b *Local) localRunDirect(op *backend.Operation, run *backend.LocalRun, cor
var diags tfdiags.Diagnostics
// Load the configuration using the caller-provided configuration loader.
config, configSnap, configDiags := op.ConfigLoader.LoadConfigWithSnapshot(op.ConfigDir)
config, configSnap, configDiags := op.ConfigLoader.LoadConfigWithSnapshot(op.ConfigDir, op.RootCall)
diags = diags.Append(configDiags)
if configDiags.HasErrors() {
return nil, nil, diags
@@ -249,7 +249,7 @@ func (b *Local) localRunForPlanFile(op *backend.Operation, pf *planfile.Reader,
return nil, snap, diags
}
loader := configload.NewLoaderFromSnapshot(snap)
config, configDiags := loader.LoadConfig(snap.Modules[""].Dir)
config, configDiags := loader.LoadConfig(snap.Modules[""].Dir, op.RootCall)
diags = diags.Append(configDiags)
if configDiags.HasErrors() {
return nil, snap, diags

View File

@@ -223,7 +223,7 @@ func (b *Remote) waitForRun(stopCtx, cancelCtx context.Context, op *backend.Oper
// remote system's responsibility to do final validation of the input.
func (b *Remote) hasExplicitVariableValues(op *backend.Operation) bool {
// Load the configuration using the caller-provided configuration loader.
config, _, configDiags := op.ConfigLoader.LoadConfigWithSnapshot(op.ConfigDir)
config, _, configDiags := op.ConfigLoader.LoadConfigWithSnapshot(op.ConfigDir, op.RootCall)
if configDiags.HasErrors() {
// If we can't load the configuration then we'll assume no explicit
// variable values just to let the remote operation start and let

View File

@@ -81,7 +81,7 @@ func (b *Remote) LocalRun(op *backend.Operation) (*backend.LocalRun, statemgr.Fu
ret.InputState = stateMgr.State()
log.Printf("[TRACE] backend/remote: loading configuration for the current working directory")
config, configDiags := op.ConfigLoader.LoadConfig(op.ConfigDir)
config, configDiags := op.ConfigLoader.LoadConfig(op.ConfigDir, op.RootCall)
diags = diags.Append(configDiags)
if configDiags.HasErrors() {
return nil, nil, diags