mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-28 18:01:01 -06:00
terraform: import module works!
This commit is contained in:
parent
3b85544016
commit
0a7f48ab8e
@ -108,7 +108,7 @@ func TestContextImport_module(t *testing.T) {
|
||||
}
|
||||
|
||||
actual := strings.TrimSpace(state.String())
|
||||
expected := strings.TrimSpace(testImportRefreshStr)
|
||||
expected := strings.TrimSpace(testImportModuleStr)
|
||||
if actual != expected {
|
||||
t.Fatalf("bad: \n%s", actual)
|
||||
}
|
||||
@ -120,6 +120,14 @@ aws_instance.foo:
|
||||
provider = aws
|
||||
`
|
||||
|
||||
const testImportModuleStr = `
|
||||
<no state>
|
||||
module.foo:
|
||||
aws_instance.foo:
|
||||
ID = foo
|
||||
provider = aws
|
||||
`
|
||||
|
||||
const testImportRefreshStr = `
|
||||
aws_instance.foo:
|
||||
ID = foo
|
||||
|
@ -51,7 +51,7 @@ func (n *graphNodeImportState) ProvidedBy() []string {
|
||||
|
||||
// GraphNodeSubPath
|
||||
func (n *graphNodeImportState) Path() []string {
|
||||
return n.Addr.Path
|
||||
return normalizeModulePath(n.Addr.Path)
|
||||
}
|
||||
|
||||
// GraphNodeEvalable impl.
|
||||
@ -59,7 +59,7 @@ func (n *graphNodeImportState) EvalTree() EvalNode {
|
||||
var provider ResourceProvider
|
||||
info := &InstanceInfo{
|
||||
Id: n.ID,
|
||||
ModulePath: n.Addr.Path,
|
||||
ModulePath: n.Path(),
|
||||
Type: n.Addr.Type,
|
||||
}
|
||||
|
||||
@ -126,6 +126,10 @@ func (n *graphNodeImportStateSub) Name() string {
|
||||
return fmt.Sprintf("import %s result: %s", n.Target, n.State.ID)
|
||||
}
|
||||
|
||||
func (n *graphNodeImportStateSub) Path() []string {
|
||||
return n.Path_
|
||||
}
|
||||
|
||||
// GraphNodeEvalable impl.
|
||||
func (n *graphNodeImportStateSub) EvalTree() EvalNode {
|
||||
// If the Ephemeral type isn't set, then it is an error
|
||||
|
Loading…
Reference in New Issue
Block a user