mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-24 16:10:46 -06:00
Merge pull request #33238 from hashicorp/radditude/import-plan-plumbing
plannable import: correct plumbing when using a plan output file
This commit is contained in:
commit
258bdbe89f
@ -427,6 +427,13 @@ func changeFromTfplan(rawChange *planproto.Change) (*plans.ChangeSrc, error) {
|
||||
}
|
||||
}
|
||||
|
||||
if rawChange.Importing != nil {
|
||||
ret.Importing = &plans.ImportingSrc{
|
||||
ID: rawChange.Importing.Id,
|
||||
}
|
||||
}
|
||||
ret.GeneratedConfig = rawChange.GeneratedConfig
|
||||
|
||||
sensitive := cty.NewValueMarks(marks.Sensitive)
|
||||
beforeValMarks, err := pathValueMarksFromTfplan(rawChange.BeforeSensitivePaths, sensitive)
|
||||
if err != nil {
|
||||
@ -759,6 +766,14 @@ func changeToTfplan(change *plans.ChangeSrc) (*planproto.Change, error) {
|
||||
ret.BeforeSensitivePaths = beforeSensitivePaths
|
||||
ret.AfterSensitivePaths = afterSensitivePaths
|
||||
|
||||
if change.Importing != nil {
|
||||
ret.Importing = &planproto.Importing{
|
||||
Id: change.Importing.ID,
|
||||
}
|
||||
|
||||
}
|
||||
ret.GeneratedConfig = change.GeneratedConfig
|
||||
|
||||
switch change.Action {
|
||||
case plans.NoOp:
|
||||
ret.Action = planproto.Action_NOOP
|
||||
|
@ -122,6 +122,33 @@ func TestTFPlanRoundTrip(t *testing.T) {
|
||||
}), objTy),
|
||||
},
|
||||
},
|
||||
{
|
||||
Addr: addrs.Resource{
|
||||
Mode: addrs.ManagedResourceMode,
|
||||
Type: "test_thing",
|
||||
Name: "importing",
|
||||
}.Instance(addrs.IntKey(1)).Absolute(addrs.RootModuleInstance),
|
||||
PrevRunAddr: addrs.Resource{
|
||||
Mode: addrs.ManagedResourceMode,
|
||||
Type: "test_thing",
|
||||
Name: "importing",
|
||||
}.Instance(addrs.IntKey(1)).Absolute(addrs.RootModuleInstance),
|
||||
ProviderAddr: addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewDefaultProvider("test"),
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
ChangeSrc: plans.ChangeSrc{
|
||||
Action: plans.NoOp,
|
||||
Before: mustNewDynamicValue(cty.ObjectVal(map[string]cty.Value{
|
||||
"id": cty.StringVal("testing"),
|
||||
}), objTy),
|
||||
After: mustNewDynamicValue(cty.ObjectVal(map[string]cty.Value{
|
||||
"id": cty.StringVal("testing"),
|
||||
}), objTy),
|
||||
Importing: &plans.ImportingSrc{ID: "testing"},
|
||||
GeneratedConfig: "resource \\\"test_thing\\\" \\\"importing\\\" {}",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
DriftedResources: []*plans.ResourceInstanceChangeSrc{
|
||||
|
Loading…
Reference in New Issue
Block a user