From 0c005ce4846f6181d6a26f8fa55331f3a6ed7ab8 Mon Sep 17 00:00:00 2001 From: James Bardin Date: Fri, 15 Sep 2023 17:11:45 -0400 Subject: [PATCH] remove legacyImportMode flag --- internal/terraform/context_import.go | 5 ++--- internal/terraform/graph_builder_plan.go | 7 ------- internal/terraform/node_resource_plan.go | 15 ++++++--------- 3 files changed, 8 insertions(+), 19 deletions(-) diff --git a/internal/terraform/context_import.go b/internal/terraform/context_import.go index f946c37942..f9c054588d 100644 --- a/internal/terraform/context_import.go +++ b/internal/terraform/context_import.go @@ -30,9 +30,8 @@ type ImportTarget struct { // if the import did not originate in config. Config *configs.Import - // Addr is the address for the resource instance that the new object should - // be imported into. - // TODO: remove + // LegacyAddr is the import address set from the command line arguments + // when using the import command. LegacyAddr addrs.AbsResourceInstance // ID is the ID of the resource to import. This is resource-specific. diff --git a/internal/terraform/graph_builder_plan.go b/internal/terraform/graph_builder_plan.go index adb5830f3f..042d3c525e 100644 --- a/internal/terraform/graph_builder_plan.go +++ b/internal/terraform/graph_builder_plan.go @@ -331,13 +331,6 @@ func (b *PlanGraphBuilder) initImport() { // as the new state, and users are not expecting the import process // to update any other instances in state. skipRefresh: true, - - // If we get here, we know that we are in legacy import mode, and - // that the user has run the import command rather than plan. - // This flag must be propagated down to the - // NodePlannableResourceInstance so we can ignore the new import - // behaviour. - legacyImportMode: true, } } } diff --git a/internal/terraform/node_resource_plan.go b/internal/terraform/node_resource_plan.go index 960195c508..16b253e90e 100644 --- a/internal/terraform/node_resource_plan.go +++ b/internal/terraform/node_resource_plan.go @@ -205,7 +205,6 @@ func (n *nodeExpandPlannableResource) validateExpandedImportTargets() tfdiags.Di for _, addr := range n.expandedImports { if !n.expandedInstances.Has(addr) { - // FIXME diags = diags.Append(fmt.Errorf("MISSING CONFIG FOR %s", addr)) } } @@ -417,14 +416,12 @@ func (n *nodeExpandPlannableResource) resourceInstanceSubgraph(ctx EvalContext, // If we're in legacy import mode (the import CLI command), we only need // to return the import node, not a plannable resource node. - if n.legacyImportMode { - for _, importTarget := range n.importTargets { - if importTarget.LegacyAddr.Equal(a.Addr) { - return &graphNodeImportState{ - Addr: importTarget.LegacyAddr, - ID: importTarget.idString, - ResolvedProvider: n.ResolvedProvider, - } + for _, importTarget := range n.importTargets { + if importTarget.LegacyAddr.Equal(a.Addr) { + return &graphNodeImportState{ + Addr: importTarget.LegacyAddr, + ID: importTarget.idString, + ResolvedProvider: n.ResolvedProvider, } } }