Merge pull request #23450 from hashicorp/jbarin/err-diags
fix diagnostics handling
This commit is contained in:
commit
88a806cc32
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue