|
|
|
|
@ -59,7 +59,8 @@ type ApplyOpts struct {
|
|
|
|
|
// as in test cases.
|
|
|
|
|
func (po *PlanOpts) ApplyOpts() *ApplyOpts {
|
|
|
|
|
return &ApplyOpts{
|
|
|
|
|
ExternalProviders: po.ExternalProviders,
|
|
|
|
|
ExternalProviders: po.ExternalProviders,
|
|
|
|
|
AllowRootEphemeralOutputs: po.AllowRootEphemeralOutputs,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -299,6 +300,10 @@ func checkApplyTimeVariables(needed collections.Set[string], gotValues InputValu
|
|
|
|
|
func (c *Context) applyGraph(plan *plans.Plan, config *configs.Config, opts *ApplyOpts, validate bool) (*Graph, walkOperation, tfdiags.Diagnostics) {
|
|
|
|
|
var diags tfdiags.Diagnostics
|
|
|
|
|
|
|
|
|
|
if opts == nil {
|
|
|
|
|
opts = new(ApplyOpts)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
variables := InputValues{}
|
|
|
|
|
for name, dyVal := range plan.VariableValues {
|
|
|
|
|
val, err := dyVal.Decode(cty.DynamicPseudoType)
|
|
|
|
|
@ -323,10 +328,8 @@ func (c *Context) applyGraph(plan *plans.Plan, config *configs.Config, opts *App
|
|
|
|
|
// FIXME: We should check that all of these match declared variables and
|
|
|
|
|
// that all of them are declared as ephemeral, because all non-ephemeral
|
|
|
|
|
// variables are supposed to come exclusively from plan.VariableValues.
|
|
|
|
|
if opts != nil {
|
|
|
|
|
for n, vv := range opts.SetVariables {
|
|
|
|
|
variables[n] = vv
|
|
|
|
|
}
|
|
|
|
|
for n, vv := range opts.SetVariables {
|
|
|
|
|
variables[n] = vv
|
|
|
|
|
}
|
|
|
|
|
if diags.HasErrors() {
|
|
|
|
|
return nil, walkApply, diags
|
|
|
|
|
@ -359,26 +362,22 @@ func (c *Context) applyGraph(plan *plans.Plan, config *configs.Config, opts *App
|
|
|
|
|
operation = walkDestroy
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var externalProviderConfigs map[addrs.RootProviderConfig]providers.Interface
|
|
|
|
|
if opts != nil {
|
|
|
|
|
externalProviderConfigs = opts.ExternalProviders
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
graph, moreDiags := (&ApplyGraphBuilder{
|
|
|
|
|
Config: config,
|
|
|
|
|
Changes: plan.Changes,
|
|
|
|
|
DeferredChanges: plan.DeferredResources,
|
|
|
|
|
State: plan.PriorState,
|
|
|
|
|
RootVariableValues: variables,
|
|
|
|
|
ExternalProviderConfigs: externalProviderConfigs,
|
|
|
|
|
Plugins: c.plugins,
|
|
|
|
|
Targets: plan.TargetAddrs,
|
|
|
|
|
ActionTargets: plan.ActionTargetAddrs,
|
|
|
|
|
ForceReplace: plan.ForceReplaceAddrs,
|
|
|
|
|
Operation: operation,
|
|
|
|
|
ExternalReferences: plan.ExternalReferences,
|
|
|
|
|
Overrides: plan.Overrides,
|
|
|
|
|
SkipGraphValidation: c.graphOpts.SkipGraphValidation,
|
|
|
|
|
Config: config,
|
|
|
|
|
Changes: plan.Changes,
|
|
|
|
|
DeferredChanges: plan.DeferredResources,
|
|
|
|
|
State: plan.PriorState,
|
|
|
|
|
RootVariableValues: variables,
|
|
|
|
|
ExternalProviderConfigs: opts.ExternalProviders,
|
|
|
|
|
Plugins: c.plugins,
|
|
|
|
|
Targets: plan.TargetAddrs,
|
|
|
|
|
ActionTargets: plan.ActionTargetAddrs,
|
|
|
|
|
ForceReplace: plan.ForceReplaceAddrs,
|
|
|
|
|
Operation: operation,
|
|
|
|
|
ExternalReferences: plan.ExternalReferences,
|
|
|
|
|
Overrides: plan.Overrides,
|
|
|
|
|
SkipGraphValidation: c.graphOpts.SkipGraphValidation,
|
|
|
|
|
AllowRootEphemeralOutputs: opts.AllowRootEphemeralOutputs,
|
|
|
|
|
}).Build(addrs.RootModuleInstance)
|
|
|
|
|
diags = diags.Append(moreDiags)
|
|
|
|
|
if moreDiags.HasErrors() {
|
|
|
|
|
|