terraform: fix bug with crash with no providers [GH-786]
This commit is contained in:
parent
a7cad594df
commit
dc036a0dd0
|
@ -4044,6 +4044,25 @@ func TestContextPlan_taint(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
// Doing a Refresh (or any operation really, but Refresh usually
|
||||
// happens first) with a config with an unknown provider should result in
|
||||
// an error. The key bug this found was that this wasn't happening if
|
||||
// Providers was _empty_.
|
||||
func TestContextRefresh_unknownProvider(t *testing.T) {
|
||||
m := testModule(t, "refresh-unknown-provider")
|
||||
p := testProvider("aws")
|
||||
p.ApplyFn = testApplyFn
|
||||
p.DiffFn = testDiffFn
|
||||
ctx := testContext(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{},
|
||||
})
|
||||
|
||||
if _, err := ctx.Refresh(); err == nil {
|
||||
t.Fatal("should error")
|
||||
}
|
||||
}
|
||||
|
||||
func TestContextPlan_multiple_taint(t *testing.T) {
|
||||
m := testModule(t, "plan-taint")
|
||||
p := testProvider("aws")
|
||||
|
|
|
@ -214,7 +214,7 @@ func Graph(opts *GraphOpts) (*depgraph.Graph, error) {
|
|||
// determine what providers are missing.
|
||||
graphMapResourceProviderId(g)
|
||||
|
||||
if len(opts.Providers) > 0 {
|
||||
if opts.Providers != nil {
|
||||
// Add missing providers from the mapping.
|
||||
if err := graphAddMissingResourceProviders(g, opts.Providers); err != nil {
|
||||
return nil, err
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
resource "unknown_instance" "foo" {
|
||||
num = "2"
|
||||
compute = "foo"
|
||||
}
|
Loading…
Reference in New Issue