Skip to content

Commit 959ecd8

Browse files
committed
Merge branch 'main' into OSS-3409
2 parents 3789ed4 + ef69123 commit 959ecd8

65 files changed

Lines changed: 1559 additions & 284 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/pull_request_template.md

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- Prepend '[WIP]' to the title if this PR is still a work-in-progress. Remove it when it is ready for review! -->
1+
<!-- Keep this PR in draft while it is still a work-in-progress. Mark it as ready for review once it is ready for review by maintainers. -->
22

33
## Description
44

@@ -14,15 +14,7 @@ Read the [Gruntwork contribution guidelines](https://gruntwork.notion.site/Grunt
1414
- [ ] I am submitting code based on open source software (e.g. MIT, MPL-2.0, Apache)
1515
- [ ] I am adding or upgrading a dependency or adapted code and confirm it has a compatible open source license
1616
- [ ] Update the docs.
17+
- [ ] Update the changelog in the docs.
1718
- [ ] Run the relevant tests successfully, including pre-commit checks.
18-
- [ ] Include release notes. If this PR is backward incompatible, include a migration guide.
19-
20-
## Release Notes (draft)
21-
22-
<!-- One-line description of the PR that can be included in the final release notes. -->
23-
Added / Removed / Updated [X].
24-
25-
### Migration Guide
26-
27-
<!-- Important: If you made any backward incompatible changes, then you must write a migration guide! -->
28-
19+
- [ ] This change is backwards compatible.
20+
- [ ] If this change is not forwards compatible (e.g. a new feature), it is gated behind a feature flag.

docs/src/content/docs/01-getting-started/04-terminology.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ The Run Queue is the queue of all units that Terragrunt will do work on over one
162162

163163
Certain commands like [run --all](/reference/cli/commands/run#all) populate the Run Queue with all units in a stack, while other commands like `plan` or `apply` will only populate the Run Queue with the unit that the command was run in.
164164

165-
Certain flags like [--include-dir](/reference/cli/commands/run#include-dir) can be used to adjust the Run Queue to include additional units. Conversely, there are flags like [--exclude-dir](/reference/cli/commands/run#exclude-dir) that can be used to adjust the Run Queue to exclude units.
165+
The [`--filter`](/features/filter) flag can be used to adjust the Run Queue, including or excluding units based on filter expressions. For example, `--filter './networking'` includes a specific path, while `--filter '!./legacy'` excludes one.
166166

167167
Terragrunt will always attempt to run until the Run Queue is empty.
168168

@@ -213,7 +213,7 @@ By default, Terragrunt will interact with OpenTofu/Terraform in order to retriev
213213

214214
Terragrunt does have the ability to mock outputs, which is useful when dependencies do not yet have outputs to be consumed (e.g. during the run of a unit with a dependency that has not been applied).
215215

216-
Terragrunt also has the ability to fetch outputs without interacting with OpenTofu/Terraform via [--fetch-dependency-output-from-state](/reference/cli/commands/run#fetch-dependency-output-from-state) for dependencies where state is stored in AWS. This is an experimental feature, and more tooling is planned to make this easier to use.
216+
Terragrunt also has the ability to fetch outputs without interacting with OpenTofu/Terraform via [--dependency-fetch-output-from-state](/reference/cli/commands/run#dependency-fetch-output-from-state) for dependencies where state is stored in AWS. This is an experimental feature, and more tooling is planned to make this easier to use.
217217

218218
### Feature
219219

docs/src/content/docs/02-guides/01-terralith-to-terragrunt/08-step-5-adding-terragrunt.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ Group 1
3939
...
4040
`} />
4141

42-
We can also selectively run the plan for the `dev` environment by changing the working directory to `dev`, or using the [`--queue-include-dir`](https://docs.terragrunt.com/reference/cli-options/#queue-include-dir) flag.
42+
We can also selectively run the plan for the `dev` environment by changing the working directory to `dev`, or using the [`--filter`](/features/filter) flag.
4343

4444
<Code title="live/dev" lang="bash" frame="terminal" code={`$ terragrunt plan`} />
4545

46-
<Code title="live" lang="bash" frame="terminal" code={`$ terragrunt run --all --queue-include-dir dev plan
46+
<Code title="live" lang="bash" frame="terminal" code={`$ terragrunt run --all --filter ./dev plan
4747
15:09:17.090 INFO The runner at . will be processed in the following order for command plan:
4848
Group 1
4949
- Unit ./dev
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
version: "v1.0.4"
3+
category: "bug-fixes"
4+
---
5+
6+
#### Fixed `exclude` block being dropped when defined only in an included parent
7+
8+
A unit that pulled in an `exclude` block from an include that did not declare its own `exclude` block saw the include's `exclude` configurations ignored.
9+
10+
Included `exclude` blocks now get properly merged into unit configurations.
11+
12+
Reported in [#5089](https://github.com/gruntwork-io/terragrunt/issues/5089). Thanks to [@HeikoNeblung](https://github.com/HeikoNeblung) for contributing this fix!

internal/cli/commands/catalog/tui/keys.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func NewListKeyMap() list.KeyMap {
5050
key.WithHelp("esc", "cancel"),
5151
),
5252
AcceptWhileFiltering: key.NewBinding(
53-
key.WithKeys("enter", "tab", "shift+tab", "ctrl+k", "up", "ctrl+j", "down"),
53+
key.WithKeys("enter", "tab", "shift+tab", "ctrl+k", "up", "down"),
5454
key.WithHelp("enter", "apply filter"),
5555
),
5656

@@ -102,8 +102,8 @@ func (d DelegateKeyMap) FullHelp() [][]key.Binding {
102102
func NewDelegateKeyMap() *DelegateKeyMap {
103103
return &DelegateKeyMap{
104104
Choose: key.NewBinding(
105-
key.WithKeys("enter", "ctrl-j"),
106-
key.WithHelp("enter/ctrl-j", "choose"),
105+
key.WithKeys("enter"),
106+
key.WithHelp("enter", "choose"),
107107
),
108108
Scaffold: key.NewBinding(
109109
key.WithKeys("S", "s"),
@@ -205,8 +205,8 @@ func NewPagerKeyMap() PagerKeyMap {
205205
key.WithHelp("shift+tab", "navigation"),
206206
),
207207
Choose: key.NewBinding(
208-
key.WithKeys("enter", "ctrl-j"),
209-
key.WithHelp("enter/ctrl-j", "choose"),
208+
key.WithKeys("enter"),
209+
key.WithHelp("enter", "choose"),
210210
),
211211
Scaffold: key.NewBinding(
212212
key.WithKeys("S", "s"),

internal/cli/commands/exec/exec.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"github.com/gruntwork-io/terragrunt/internal/runner/run"
1212
"github.com/gruntwork-io/terragrunt/internal/runner/runcfg"
1313
"github.com/gruntwork-io/terragrunt/internal/shell"
14+
"github.com/gruntwork-io/terragrunt/internal/vexec"
1415
"github.com/gruntwork-io/terragrunt/pkg/log"
1516
"github.com/gruntwork-io/terragrunt/pkg/options"
1617
)
@@ -82,7 +83,7 @@ func runTargetCommand(
8283

8384
return run.RunActionWithHooks(ctx, l, command, runOpts, cfg, r, func(ctx context.Context) error {
8485
_, err := shell.RunCommandWithOutput(
85-
ctx, l, configbridge.ShellRunOptsFromOpts(opts), dir, false, false, command, cmdArgs...,
86+
ctx, l, vexec.NewOSExec(), configbridge.ShellRunOptsFromOpts(opts), dir, false, false, command, cmdArgs...,
8687
)
8788
if err != nil {
8889
return errors.Errorf("failed to run command in directory %s: %w", dir, err)

internal/cli/commands/run/help.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"github.com/gruntwork-io/terragrunt/internal/errors"
1313
"github.com/gruntwork-io/terragrunt/internal/tf"
1414
"github.com/gruntwork-io/terragrunt/internal/util"
15+
"github.com/gruntwork-io/terragrunt/internal/vexec"
1516
"github.com/gruntwork-io/terragrunt/pkg/log"
1617
"github.com/gruntwork-io/terragrunt/pkg/options"
1718
)
@@ -59,7 +60,7 @@ func runTFHelp(ctx context.Context, cliCtx *clihelper.Context, l log.Logger, opt
5960

6061
terraformHelpCmd := []string{tf.FlagNameHelpLong, cliCtx.Command.Name}
6162

62-
out, err := tf.RunCommandWithOutput(ctx, l, configbridge.TFRunOptsFromOpts(opts), terraformHelpCmd...)
63+
out, err := tf.RunCommandWithOutput(ctx, l, vexec.NewOSExec(), configbridge.TFRunOptsFromOpts(opts), terraformHelpCmd...)
6364
if err != nil {
6465
var processError util.ProcessExecutionError
6566
if ok := errors.As(err, &processError); ok {

internal/cli/commands/run/run.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"github.com/gruntwork-io/terragrunt/internal/shell"
1919
"github.com/gruntwork-io/terragrunt/internal/tf"
2020
"github.com/gruntwork-io/terragrunt/internal/util"
21+
"github.com/gruntwork-io/terragrunt/internal/vexec"
2122
"github.com/gruntwork-io/terragrunt/pkg/config"
2223
"github.com/gruntwork-io/terragrunt/pkg/log"
2324
"github.com/gruntwork-io/terragrunt/pkg/options"
@@ -158,7 +159,7 @@ func runVersionCommand(ctx context.Context, l log.Logger, opts *options.Terragru
158159
}
159160
}
160161

161-
return tf.RunCommand(ctx, l, configbridge.TFRunOptsFromOpts(opts), opts.TerraformCliArgs.Slice()...)
162+
return tf.RunCommand(ctx, l, vexec.NewOSExec(), configbridge.TFRunOptsFromOpts(opts), opts.TerraformCliArgs.Slice()...)
162163
}
163164

164165
func getTFPathFromConfig(ctx context.Context, l log.Logger, opts *options.TerragruntOptions) (string, error) {

internal/discovery/errors.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,3 +135,22 @@ func NewCoexistenceError(a, b component.Component) error {
135135
ConfigFileB: b.ConfigFile(),
136136
})
137137
}
138+
139+
// StackDependencyExpansionError indicates that a stack dependency path could not be expanded into its constituent unit paths. Wraps the underlying parse error so callers can extract typed details via errors.As.
140+
type StackDependencyExpansionError struct {
141+
Wrapped error
142+
DepPath string
143+
}
144+
145+
func (e StackDependencyExpansionError) Error() string {
146+
return fmt.Sprintf("failed to expand stack dependency path %s: %s", e.DepPath, e.Wrapped)
147+
}
148+
149+
func (e StackDependencyExpansionError) Unwrap() error {
150+
return e.Wrapped
151+
}
152+
153+
// NewStackDependencyExpansionError wraps err with the dependency path that triggered the expansion.
154+
func NewStackDependencyExpansionError(depPath string, err error) error {
155+
return errors.New(StackDependencyExpansionError{DepPath: depPath, Wrapped: err})
156+
}

internal/discovery/helpers.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package discovery
22

33
import (
4+
iofs "io/fs"
45
"os"
56
"path/filepath"
67
"slices"
@@ -290,9 +291,21 @@ func stackDependencyPaths(fs vfs.FS, depPaths []string, c component.Component) (
290291
expanded := make([]string, 0, len(depPaths))
291292

292293
for _, depPath := range depPaths {
294+
// Stat upfront so a non-directory dep path (e.g. another-name.hcl) is preserved instead of being passed to the parser, which would reject it as ENOTDIR. The duplication of work is intentional.
295+
info, statErr := fs.Stat(depPath)
296+
// Real I/O errors (permission denied, etc.) must surface so a malformed DAG isn't silently produced; only ENOENT is treated as "keep the raw path".
297+
if statErr != nil && !errors.Is(statErr, iofs.ErrNotExist) {
298+
return nil, NewStackDependencyExpansionError(depPath, statErr)
299+
}
300+
301+
if statErr != nil || !info.IsDir() {
302+
expanded = append(expanded, depPath)
303+
continue
304+
}
305+
293306
unitPaths, err := inthclparse.UnitPathsFromStackDir(fs, depPath)
294307
if err != nil {
295-
return nil, err
308+
return nil, NewStackDependencyExpansionError(depPath, err)
296309
}
297310

298311
if len(unitPaths) > 0 {

0 commit comments

Comments
 (0)