terraform: fix crash if outputs with no state [GH-358]
This commit is contained in:
parent
5c2182e316
commit
94f43ff145
|
@ -498,7 +498,7 @@ func (c *walkContext) Walk() error {
|
|||
// On Apply, we prune so that we don't do outputs if we destroyed
|
||||
mod.prune()
|
||||
}
|
||||
if len(mod.Resources) == 0 {
|
||||
if mod == nil || len(mod.Resources) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -3336,6 +3336,27 @@ func TestContextRefresh_modules(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
// GH-70
|
||||
func TestContextRefresh_noState(t *testing.T) {
|
||||
p := testProvider("aws")
|
||||
m := testModule(t, "refresh-no-state")
|
||||
ctx := testContext(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
})
|
||||
|
||||
p.RefreshFn = nil
|
||||
p.RefreshReturn = &InstanceState{
|
||||
ID: "foo",
|
||||
}
|
||||
|
||||
if _, err := ctx.Refresh(); err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestContextRefresh_state(t *testing.T) {
|
||||
p := testProvider("aws")
|
||||
m := testModule(t, "refresh-basic")
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
output "foo" {}
|
Loading…
Reference in New Issue