Merge pull request #2878 from hashicorp/b-provider-warnings-crash
core: fix crash on provider warning
This commit is contained in:
commit
686598ebf5
|
@ -78,6 +78,46 @@ func TestContext2Apply_providerAlias(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
// GH-2870
|
||||
func TestContext2Apply_providerWarning(t *testing.T) {
|
||||
m := testModule(t, "apply-provider-warning")
|
||||
p := testProvider("aws")
|
||||
p.ApplyFn = testApplyFn
|
||||
p.DiffFn = testDiffFn
|
||||
p.ValidateFn = func(c *ResourceConfig) (ws []string, es []error) {
|
||||
ws = append(ws, "Just a warning")
|
||||
return
|
||||
}
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
})
|
||||
|
||||
if _, err := ctx.Plan(); err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
||||
state, err := ctx.Apply()
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
||||
actual := strings.TrimSpace(state.String())
|
||||
expected := strings.TrimSpace(`
|
||||
aws_instance.foo:
|
||||
ID = foo
|
||||
`)
|
||||
if actual != expected {
|
||||
t.Fatalf("got: \n%s\n\nexpected:\n%s", actual, expected)
|
||||
}
|
||||
|
||||
if !p.ConfigureCalled {
|
||||
t.Fatalf("provider Configure() was never called!")
|
||||
}
|
||||
}
|
||||
|
||||
func TestContext2Apply_emptyModule(t *testing.T) {
|
||||
m := testModule(t, "apply-empty-module")
|
||||
p := testProvider("aws")
|
||||
|
|
|
@ -40,9 +40,8 @@ func ProviderEvalTree(n string, config *config.RawConfig) EvalNode {
|
|||
},
|
||||
})
|
||||
|
||||
// Apply stuff
|
||||
seq = append(seq, &EvalOpFilter{
|
||||
Ops: []walkOperation{walkValidate, walkRefresh, walkPlan, walkApply},
|
||||
Ops: []walkOperation{walkValidate},
|
||||
Node: &EvalSequence{
|
||||
Nodes: []EvalNode{
|
||||
&EvalGetProvider{
|
||||
|
@ -70,6 +69,32 @@ func ProviderEvalTree(n string, config *config.RawConfig) EvalNode {
|
|||
},
|
||||
})
|
||||
|
||||
// Apply stuff
|
||||
seq = append(seq, &EvalOpFilter{
|
||||
Ops: []walkOperation{walkRefresh, walkPlan, walkApply},
|
||||
Node: &EvalSequence{
|
||||
Nodes: []EvalNode{
|
||||
&EvalGetProvider{
|
||||
Name: n,
|
||||
Output: &provider,
|
||||
},
|
||||
&EvalInterpolate{
|
||||
Config: config,
|
||||
Output: &resourceConfig,
|
||||
},
|
||||
&EvalBuildProviderConfig{
|
||||
Provider: n,
|
||||
Config: &resourceConfig,
|
||||
Output: &resourceConfig,
|
||||
},
|
||||
&EvalSetProviderConfig{
|
||||
Provider: n,
|
||||
Config: &resourceConfig,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
// We configure on everything but validate, since validate may
|
||||
// not have access to all the variables.
|
||||
seq = append(seq, &EvalOpFilter{
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
resource "aws_instance" "foo" {}
|
Loading…
Reference in New Issue