Skip to content

Commit

Permalink
add types for plannable import (hashicorp#33080)
Browse files Browse the repository at this point in the history
  • Loading branch information
kmoe committed Apr 25, 2023
1 parent c87a6aa commit 531efd3
Show file tree
Hide file tree
Showing 6 changed files with 158 additions and 119 deletions.
13 changes: 13 additions & 0 deletions internal/configs/import.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package configs

import (
"github.com/hashicorp/hcl/v2"
"github.com/hashicorp/terraform/internal/addrs"
)

type Import struct {
ID string
To addrs.AbsResourceInstance

DeclRange hcl.Range
}
6 changes: 4 additions & 2 deletions internal/configs/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ type Module struct {
ManagedResources map[string]*Resource
DataResources map[string]*Resource

Moved []*Moved
Moved []*Moved
Import []*Import

Checks map[string]*Check
}
Expand Down Expand Up @@ -82,7 +83,8 @@ type File struct {
ManagedResources []*Resource
DataResources []*Resource

Moved []*Moved
Moved []*Moved
Import []*Import

Checks []*Check
}
Expand Down
4 changes: 4 additions & 0 deletions internal/plans/changes.go
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,10 @@ type Change struct {
// either as the values themselves or as nested elements within known
// collections/structures.
Before, After cty.Value

// Importing is true if the resource is being imported as part of the
// change.
Importing bool
}

// Encode produces a variant of the reciever that has its change values
Expand Down
4 changes: 4 additions & 0 deletions internal/plans/changes_src.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,10 @@ type ChangeSrc struct {
// the path+mark combinations allow us to re-mark the value later
// when, for example, displaying the diff to the UI.
BeforeValMarks, AfterValMarks []cty.PathValueMarks

// Importing is true if the resource is being imported as part of the
// change.
Importing bool
}

// Decode unmarshals the raw representations of the before and after values
Expand Down
Loading

0 comments on commit 531efd3

Please sign in to comment.