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 we're refreshing before apply, perform that
|
||||||
if op.PlanRefresh {
|
if op.PlanRefresh {
|
||||||
log.Printf("[INFO] backend/local: apply calling Refresh")
|
log.Printf("[INFO] backend/local: apply calling Refresh")
|
||||||
_, err := tfCtx.Refresh()
|
_, refreshDiags := tfCtx.Refresh()
|
||||||
if err != nil {
|
diags = diags.Append(refreshDiags)
|
||||||
diags = diags.Append(err)
|
if diags.HasErrors() {
|
||||||
runningOp.Result = backend.OperationFailure
|
runningOp.Result = backend.OperationFailure
|
||||||
b.ShowDiagnostics(diags)
|
b.ShowDiagnostics(diags)
|
||||||
return
|
return
|
||||||
|
|
|
@ -86,9 +86,9 @@ func (b *Local) opPlan(
|
||||||
b.CLI.Output(b.Colorize().Color(strings.TrimSpace(planRefreshing) + "\n"))
|
b.CLI.Output(b.Colorize().Color(strings.TrimSpace(planRefreshing) + "\n"))
|
||||||
}
|
}
|
||||||
|
|
||||||
refreshedState, err := tfCtx.Refresh()
|
refreshedState, refreshDiags := tfCtx.Refresh()
|
||||||
if err != nil {
|
diags = diags.Append(refreshDiags)
|
||||||
diags = diags.Append(err)
|
if diags.HasErrors() {
|
||||||
b.ReportResult(runningOp, diags)
|
b.ReportResult(runningOp, diags)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -154,9 +154,9 @@ func IsEmptyDir(path string) (bool, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
p := NewParser(nil)
|
p := NewParser(nil)
|
||||||
fs, os, err := p.dirFiles(path)
|
fs, os, diags := p.dirFiles(path)
|
||||||
if err != nil {
|
if diags.HasErrors() {
|
||||||
return false, err
|
return false, diags
|
||||||
}
|
}
|
||||||
|
|
||||||
return len(fs) == 0 && len(os) == 0, nil
|
return len(fs) == 0 && len(os) == 0, nil
|
||||||
|
|
|
@ -170,12 +170,12 @@ func (n *NodeAbstractResource) References() []*addrs.Reference {
|
||||||
var result []*addrs.Reference
|
var result []*addrs.Reference
|
||||||
|
|
||||||
for _, traversal := range c.DependsOn {
|
for _, traversal := range c.DependsOn {
|
||||||
ref, err := addrs.ParseRef(traversal)
|
ref, diags := addrs.ParseRef(traversal)
|
||||||
if err != nil {
|
if diags.HasErrors() {
|
||||||
// We ignore this here, because this isn't a suitable place to return
|
// We ignore this here, because this isn't a suitable place to return
|
||||||
// errors. This situation should be caught and rejected during
|
// errors. This situation should be caught and rejected during
|
||||||
// validation.
|
// 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
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -308,8 +308,8 @@ func hclRangeFromIndexStepAndAttribute(idxStep cty.IndexStep, attr *hcl.Attribut
|
||||||
}
|
}
|
||||||
stepKey := idxStep.Key.AsString()
|
stepKey := idxStep.Key.AsString()
|
||||||
for _, kvPair := range pairs {
|
for _, kvPair := range pairs {
|
||||||
key, err := kvPair.Key.Value(nil)
|
key, diags := kvPair.Key.Value(nil)
|
||||||
if err != nil {
|
if diags.HasErrors() {
|
||||||
return attr.Expr.Range()
|
return attr.Expr.Range()
|
||||||
}
|
}
|
||||||
if key.AsString() == stepKey {
|
if key.AsString() == stepKey {
|
||||||
|
|
Loading…
Reference in New Issue