You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<!-- Thanks for sending a pull request! Here are some tips for you:
1. Please read our contribution policy:
https://github.com/terramate-io/terramate/blob/main/CONTRIBUTING.md
Note: All code contributions are managed exclusively by the Terramate
team.
2. If the PR is unfinished, mark it as draft:
https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/changing-the-stage-of-a-pull-request
3. Please update the PR title using the Conventional Commits convention:
https://www.conventionalcommits.org/en/v1.0.0/
Example: feat: add support for XYZ.
-->
## What this PR does / why we need it:
This PR adds support for a lets block in bundle definitions. The are
evaluated after bundle inputs, but before exports and bundle stacks.
The lets defined expressions are available as `bundle.let.<name>`
outside of the lets block.
Note: The PR also contains some opportunistic fixes in
`evalBundleExports`.
## Which issue(s) this PR fixes:
<!--
*Automatically closes linked issue when PR is merged.
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
_If PR is about `failing-tests or flakes`, please post the related
issues/tests in a comment and do not use `Fixes`_*
Keep it empty if not applicable.
-->
Implements #2299
## Does this PR introduce a user-facing change?
<!--
If no, just write "no" in the block below.
If yes, please explain the change and update documentation and the
CHANGELOG.md file accordingly.
-->
```
yes, see changelog
```
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Medium Risk**
> Adds a new evaluation phase for bundle configuration (`lets`) that
affects how bundle inputs/scaffolding/exports/stacks are computed, so
regressions could change bundle rendering and UI behavior. Also
refactors `preempt.Run` scheduling/drain logic, which is
concurrency-sensitive but covered by new deadlock-focused tests.
>
> **Overview**
> **Bundles now support a `lets` block** in `define bundle`, merged
across files and exposed to expressions as `bundle.let.<name>`,
evaluated *after inputs* but *before exports and bundle stacks*.
>
> Bundle evaluation is updated to populate `bundle.file.path.*` on the
`bundle` namespace and to call `config.LoadBundleLets()` from core
bundle eval as well as the scaffold and UI change flows so `lets` are
available when computing scaffolding name/path and other derived fields.
>
> Separately, `preempt.Run` is refactored to track in-flight goroutines
and drain/resume waiters without deadlocking when a goroutine issues
additional `Await` calls after receiving `ErrUnresolvable`, with new
tests covering these late-await scenarios.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
bf75b08. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
0 commit comments