terraform: import module works!

This commit is contained in:
Mitchell Hashimoto 2016-04-30 08:28:58 +02:00
parent 3b85544016
commit 0a7f48ab8e
No known key found for this signature in database
GPG Key ID: 744E147AA52F5B0A
2 changed files with 15 additions and 3 deletions

View File

@ -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

View File

@ -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