Skip to content

Commit 89478e9

Browse files
committed
move removal of external tflint flag back to tflint module
1 parent 80a6d59 commit 89478e9

2 files changed

Lines changed: 8 additions & 7 deletions

File tree

internal/runner/run/hook.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -182,11 +182,6 @@ func runHook(
182182
containsExternalTFLintFlag := slices.Contains(curHook.Execute, tflint.TfExternalTFLint)
183183
if actionToExecute == "tflint" {
184184
if containsExternalTFLintFlag {
185-
// delete the flag and run external tflint
186-
curHook.Execute = slices.DeleteFunc(curHook.Execute, func(arg string) bool {
187-
return arg == tflint.TfExternalTFLint
188-
})
189-
190185
return executeTFLint(ctx, l, opts, cfg, curHook, workingDir, true)
191186
} else {
192187
strictControl := opts.StrictControls.Find(controls.InternalTFLint)

internal/tflint/tflint.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"context"
77
"fmt"
88
"path/filepath"
9+
"slices"
910
"strings"
1011

1112
"github.com/gruntwork-io/terratest/modules/collections"
@@ -30,8 +31,13 @@ const (
3031

3132
// RunTflintWithOpts runs tflint with the given options and returns an error if there are any issues.
3233
func RunTflintWithOpts(ctx context.Context, l log.Logger, opts *options.TerragruntOptions, cfg *runcfg.RunConfig, hook *runcfg.Hook, externalTfLint bool) error {
34+
args := slices.Clone(hook.Execute)
35+
args = slices.DeleteFunc(args, func(arg string) bool {
36+
return arg == TfExternalTFLint
37+
})
38+
3339
// try to fetch configuration file from hook parameters
34-
configFile, err := tflintConfigFilePath(l, opts, hook.Execute)
40+
configFile, err := tflintConfigFilePath(l, opts, args)
3541
if err != nil {
3642
return err
3743
}
@@ -55,7 +61,7 @@ func RunTflintWithOpts(ctx context.Context, l log.Logger, opts *options.Terragru
5561
return errors.New(err)
5662
}
5763

58-
tflintArgs := hook.Execute[1:]
64+
tflintArgs := args[1:]
5965

6066
// tflint init
6167
initArgs := []string{"tflint", "--init", "--config", configFile, "--chdir", opts.WorkingDir}

0 commit comments

Comments
 (0)