|
|
|
|
@ -3545,6 +3545,119 @@ func TestApply_RemovedBlocks(t *testing.T) {
|
|
|
|
|
},
|
|
|
|
|
wantApplyDiags: []expectedDiagnostic{},
|
|
|
|
|
},
|
|
|
|
|
"forgotten component": {
|
|
|
|
|
source: filepath.Join("with-single-input", "forgotten-component"),
|
|
|
|
|
initialState: stackstate.NewStateBuilder().
|
|
|
|
|
AddComponentInstance(stackstate.NewComponentInstanceBuilder(mustAbsComponentInstance("component.self")).
|
|
|
|
|
AddInputVariable("id", cty.StringVal("removed")).
|
|
|
|
|
AddInputVariable("input", cty.StringVal("removed"))).
|
|
|
|
|
AddResourceInstance(stackstate.NewResourceInstanceBuilder().
|
|
|
|
|
SetAddr(mustAbsResourceInstanceObject("component.self.testing_resource.data")).
|
|
|
|
|
SetProviderAddr(mustDefaultRootProvider("testing")).
|
|
|
|
|
SetResourceInstanceObjectSrc(states.ResourceInstanceObjectSrc{
|
|
|
|
|
Status: states.ObjectReady,
|
|
|
|
|
AttrsJSON: mustMarshalJSONAttrs(map[string]any{
|
|
|
|
|
"id": "removed",
|
|
|
|
|
"value": "removed",
|
|
|
|
|
}),
|
|
|
|
|
})).
|
|
|
|
|
Build(),
|
|
|
|
|
store: stacks_testing_provider.NewResourceStoreBuilder().
|
|
|
|
|
AddResource("removed", cty.ObjectVal(map[string]cty.Value{
|
|
|
|
|
"id": cty.StringVal("removed"),
|
|
|
|
|
"value": cty.StringVal("removed"),
|
|
|
|
|
})).
|
|
|
|
|
Build(),
|
|
|
|
|
inputs: map[string]cty.Value{
|
|
|
|
|
"destroy": cty.BoolVal(false),
|
|
|
|
|
},
|
|
|
|
|
wantPlanChanges: []stackplan.PlannedChange{
|
|
|
|
|
&stackplan.PlannedChangeApplyable{
|
|
|
|
|
Applyable: true,
|
|
|
|
|
},
|
|
|
|
|
&stackplan.PlannedChangeComponentInstance{
|
|
|
|
|
Addr: mustAbsComponentInstance("component.self"),
|
|
|
|
|
PlanComplete: true,
|
|
|
|
|
PlanApplyable: true,
|
|
|
|
|
Mode: plans.DestroyMode,
|
|
|
|
|
Action: plans.Forget,
|
|
|
|
|
PlannedInputValues: map[string]plans.DynamicValue{
|
|
|
|
|
"id": mustPlanDynamicValueDynamicType(cty.StringVal("removed")),
|
|
|
|
|
"input": mustPlanDynamicValueDynamicType(cty.StringVal("removed")),
|
|
|
|
|
},
|
|
|
|
|
PlannedInputValueMarks: map[string][]cty.PathValueMarks{
|
|
|
|
|
"input": nil,
|
|
|
|
|
"id": nil,
|
|
|
|
|
},
|
|
|
|
|
PlannedOutputValues: make(map[string]cty.Value),
|
|
|
|
|
PlannedCheckResults: &states.CheckResults{},
|
|
|
|
|
PlanTimestamp: fakePlanTimestamp,
|
|
|
|
|
},
|
|
|
|
|
&stackplan.PlannedChangeResourceInstancePlanned{
|
|
|
|
|
ResourceInstanceObjectAddr: mustAbsResourceInstanceObject("component.self.testing_resource.data"),
|
|
|
|
|
ChangeSrc: &plans.ResourceInstanceChangeSrc{
|
|
|
|
|
Addr: mustAbsResourceInstance("testing_resource.data"),
|
|
|
|
|
PrevRunAddr: mustAbsResourceInstance("testing_resource.data"),
|
|
|
|
|
ChangeSrc: plans.ChangeSrc{
|
|
|
|
|
Action: plans.Forget,
|
|
|
|
|
Before: mustPlanDynamicValue(cty.ObjectVal(map[string]cty.Value{
|
|
|
|
|
"id": cty.StringVal("removed"),
|
|
|
|
|
"value": cty.StringVal("removed"),
|
|
|
|
|
})),
|
|
|
|
|
After: mustPlanDynamicValue(cty.NullVal(cty.Object(map[string]cty.Type{
|
|
|
|
|
"id": cty.String,
|
|
|
|
|
"value": cty.String,
|
|
|
|
|
}))),
|
|
|
|
|
},
|
|
|
|
|
ProviderAddr: mustDefaultRootProvider("testing"),
|
|
|
|
|
},
|
|
|
|
|
PriorStateSrc: &states.ResourceInstanceObjectSrc{
|
|
|
|
|
AttrsJSON: mustMarshalJSONAttrs(map[string]any{
|
|
|
|
|
"id": "removed",
|
|
|
|
|
"value": "removed",
|
|
|
|
|
}),
|
|
|
|
|
Dependencies: make([]addrs.ConfigResource, 0),
|
|
|
|
|
Status: states.ObjectReady,
|
|
|
|
|
},
|
|
|
|
|
ProviderConfigAddr: mustDefaultRootProvider("testing"),
|
|
|
|
|
Schema: stacks_testing_provider.TestingResourceSchema,
|
|
|
|
|
},
|
|
|
|
|
&stackplan.PlannedChangeHeader{
|
|
|
|
|
TerraformVersion: version.SemVer,
|
|
|
|
|
},
|
|
|
|
|
&stackplan.PlannedChangePlannedTimestamp{
|
|
|
|
|
PlannedTimestamp: fakePlanTimestamp,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
wantPlanDiags: []expectedDiagnostic{
|
|
|
|
|
{
|
|
|
|
|
severity: tfdiags.Warning,
|
|
|
|
|
summary: "Some objects will no longer be managed by Terraform",
|
|
|
|
|
detail: `If you apply this plan, Terraform will discard its tracking information for the following objects, but it will not delete them:
|
|
|
|
|
- testing_resource.data
|
|
|
|
|
|
|
|
|
|
After applying this plan, Terraform will no longer manage these objects. You will need to import them into Terraform to manage them again.`,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
wantApplyChanges: []stackstate.AppliedChange{
|
|
|
|
|
&stackstate.AppliedChangeComponentInstance{
|
|
|
|
|
ComponentAddr: mustAbsComponent("component.self"),
|
|
|
|
|
ComponentInstanceAddr: mustAbsComponentInstance("component.self"),
|
|
|
|
|
OutputValues: make(map[addrs.OutputValue]cty.Value),
|
|
|
|
|
InputVariables: map[addrs.InputVariable]cty.Value{
|
|
|
|
|
mustInputVariable("id"): cty.StringVal("removed"),
|
|
|
|
|
mustInputVariable("input"): cty.StringVal("removed"),
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
&stackstate.AppliedChangeResourceInstanceObject{
|
|
|
|
|
ResourceInstanceObjectAddr: mustAbsResourceInstanceObject("component.self.testing_resource.data"),
|
|
|
|
|
ProviderConfigAddr: mustDefaultRootProvider("testing"),
|
|
|
|
|
NewStateSrc: nil,
|
|
|
|
|
Schema: nil,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
wantApplyDiags: []expectedDiagnostic{},
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for name, tc := range tcs {
|
|
|
|
|
|