check errors before using configSnap

configSnap may be nil if there are errors loading it from the plan file.
This commit is contained in:
James Bardin 2021-02-25 09:53:57 -05:00
parent 21d881d4d1
commit 936f597ba1

View File

@ -95,6 +95,10 @@ func (b *Local) context(op *backend.Operation) (*terraform.Context, *configload.
}
log.Printf("[TRACE] backend/local: building context from plan file")
tfCtx, configSnap, ctxDiags = b.contextFromPlanFile(op.PlanFile, opts, stateMeta)
if ctxDiags.HasErrors() {
return nil, nil, nil, ctxDiags
}
// Write sources into the cache of the main loader so that they are
// available if we need to generate diagnostic message snippets.
op.ConfigLoader.ImportSourcesFromSnapshot(configSnap)