core: Generate "provider bug" warnings only if no errors from provider

We can be more relaxed about our rules that a create musn't return null
or a destroy must return null if the provider also itself indicated an
error. In that case, it's expected that the return value is describing a
partial result, and so we'll just store it and move on.
This commit is contained in:
Martin Atkins 2018-09-14 15:51:17 -07:00
parent f63bba78c9
commit 31c412b44d
1 changed files with 25 additions and 23 deletions

View File

@ -158,6 +158,7 @@ func (n *EvalApply) Eval(ctx EvalContext) (interface{}, error) {
// we still want to save that but it often causes some confusing behaviors
// where it seems like Terraform is failing to take any action at all,
// so we'll generate some errors to draw attention to it.
if !applyDiags.HasErrors() {
if change.Action == plans.Delete && !newVal.IsNull() {
diags = diags.Append(tfdiags.Sourceless(
tfdiags.Error,
@ -178,6 +179,7 @@ func (n *EvalApply) Eval(ctx EvalContext) (interface{}, error) {
),
))
}
}
var newState *states.ResourceInstanceObject
if !newVal.IsNull() { // null value indicates that the object is deleted, so we won't set a new state in that case