fix diagnostics handling

Located all non-test paths where a Diagnostic type was assigned to an
error variable.
This commit is contained in:
James Bardin 2019-11-21 09:14:50 -05:00
parent 7081c26e54
commit 6caa5d23e2
5 changed files with 14 additions and 14 deletions

View File

@ -65,9 +65,9 @@ func (b *Local) opApply(
// If we're refreshing before apply, perform that
if op.PlanRefresh {
log.Printf("[INFO] backend/local: apply calling Refresh")
_, err := tfCtx.Refresh()
if err != nil {
diags = diags.Append(err)
_, refreshDiags := tfCtx.Refresh()
diags = diags.Append(refreshDiags)
if diags.HasErrors() {
runningOp.Result = backend.OperationFailure
b.ShowDiagnostics(diags)
return

View File

@ -86,9 +86,9 @@ func (b *Local) opPlan(
b.CLI.Output(b.Colorize().Color(strings.TrimSpace(planRefreshing) + "\n"))
}
refreshedState, err := tfCtx.Refresh()
if err != nil {
diags = diags.Append(err)
refreshedState, refreshDiags := tfCtx.Refresh()
diags = diags.Append(refreshDiags)
if diags.HasErrors() {
b.ReportResult(runningOp, diags)
return
}

View File

@ -154,9 +154,9 @@ func IsEmptyDir(path string) (bool, error) {
}
p := NewParser(nil)
fs, os, err := p.dirFiles(path)
if err != nil {
return false, err
fs, os, diags := p.dirFiles(path)
if diags.HasErrors() {
return false, diags
}
return len(fs) == 0 && len(os) == 0, nil

View File

@ -170,12 +170,12 @@ func (n *NodeAbstractResource) References() []*addrs.Reference {
var result []*addrs.Reference
for _, traversal := range c.DependsOn {
ref, err := addrs.ParseRef(traversal)
if err != nil {
ref, diags := addrs.ParseRef(traversal)
if diags.HasErrors() {
// We ignore this here, because this isn't a suitable place to return
// errors. This situation should be caught and rejected during
// validation.
log.Printf("[ERROR] Can't parse %#v from depends_on as reference: %s", traversal, err)
log.Printf("[ERROR] Can't parse %#v from depends_on as reference: %s", traversal, diags.Err())
continue
}

View File

@ -308,8 +308,8 @@ func hclRangeFromIndexStepAndAttribute(idxStep cty.IndexStep, attr *hcl.Attribut
}
stepKey := idxStep.Key.AsString()
for _, kvPair := range pairs {
key, err := kvPair.Key.Value(nil)
if err != nil {
key, diags := kvPair.Key.Value(nil)
if diags.HasErrors() {
return attr.Expr.Range()
}
if key.AsString() == stepKey {