don't evaluate an empty connection body

There's a required field now, so evaluating an empty block will always
fail.
This commit is contained in:
James Bardin 2018-12-19 15:22:47 -05:00
parent 8d17fcea4e
commit c552284157
1 changed files with 12 additions and 8 deletions

View File

@ -494,17 +494,21 @@ func (n *EvalApplyProvisioners) apply(ctx EvalContext, provs []*configs.Provisio
connBody = baseConn connBody = baseConn
case localConn != nil: case localConn != nil:
connBody = localConn connBody = localConn
default: // both are nil, by elimination
connBody = hcl.EmptyBody()
} }
connInfo, _, connInfoDiags := ctx.EvaluateBlock(connBody, connectionBlockSupersetSchema, instanceAddr, keyData) // start with an empty connInfo
connInfo := cty.NullVal(connectionBlockSupersetSchema.ImpliedType())
if connBody != nil {
var connInfoDiags tfdiags.Diagnostics
connInfo, _, connInfoDiags = ctx.EvaluateBlock(connBody, connectionBlockSupersetSchema, instanceAddr, keyData)
diags = diags.Append(connInfoDiags) diags = diags.Append(connInfoDiags)
if diags.HasErrors() { if diags.HasErrors() {
// "on failure continue" setting only applies to failures of the // "on failure continue" setting only applies to failures of the
// provisioner itself, not to invalid configuration. // provisioner itself, not to invalid configuration.
return diags.Err() return diags.Err()
} }
}
{ {
// Call pre hook // Call pre hook