Skip to content

Commit b906545

Browse files
authored
direct: plan: add prefix to errors with group/key (#3380)
## Why Resource group/key is useful context. This is similar to what we do in apply.go. ## Tests Untested. Planning currently does not use remote API calls so we cannot inject API errors. Once plan loads remote state, we'll have a test there.
1 parent a39b1ed commit b906545

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

bundle/terranova/plan.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,14 @@ type Planner struct {
2323
}
2424

2525
func (d *Planner) Plan(ctx context.Context, inputConfig any) (deployplan.ActionType, error) {
26-
// TODO: wrap errors with prefix "planning <group>.<name>:"
26+
result, err := d.plan(ctx, inputConfig)
27+
if err != nil {
28+
return deployplan.ActionTypeNoop, fmt.Errorf("planning: %s.%s: %w", d.group, d.resourceName, err)
29+
}
30+
return result, err
31+
}
32+
33+
func (d *Planner) plan(_ context.Context, inputConfig any) (deployplan.ActionType, error) {
2734
entry, hasEntry := d.db.GetResourceEntry(d.group, d.resourceName)
2835

2936
resource, cfgType, err := New(d.client, d.group, d.resourceName, inputConfig)
@@ -97,6 +104,7 @@ func CalculateDeployActions(ctx context.Context, b *bundle.Bundle) ([]deployplan
97104
settings: settings,
98105
}
99106

107+
// This currently does not do API calls, so we can run this sequentially. Once we have remote diffs, we need to run a in threadpool.
100108
actionType, err := pl.Plan(ctx, config)
101109
if err != nil {
102110
return dyn.InvalidValue, err

0 commit comments

Comments
 (0)