Skip to content

Commit

Permalink
Merge pull request #23450 from hashicorp/jbarin/err-diags
Browse files Browse the repository at this point in the history
fix diagnostics handling
  • Loading branch information
jbardin authored Nov 22, 2019
2 parents d5602cc + 6caa5d2 commit 88a806c
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions backend/local/backend_apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions backend/local/backend_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
6 changes: 3 additions & 3 deletions configs/parser_config_dir.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions terraform/node_resource_abstract.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
4 changes: 2 additions & 2 deletions tfdiags/contextual.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 88a806c

Please sign in to comment.