Skip to content

Commit

Permalink
[tg-hcl] Fix regex compile moved out from loop
Browse files Browse the repository at this point in the history
  • Loading branch information
gmcoringa committed Apr 23, 2021
1 parent 0cf5b1c commit 15eac76
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -436,11 +436,10 @@ func installFromConstraint(tfconstraint *string, custBinPath *string) {
func installTGHclFile(tgFile *string, custBinPath *string) {
fmt.Printf("Terragrunt file found: %s\n", *tgFile)
content := retrieveFileContents(*tgFile)
regex, _ := regexp.Compile(`^terraform_version_constraint\s+=\s+"(?P<version>.*)".*`)
var constraint = ""

for _, line := range strings.Split(content, "\n") {
regex, _ := regexp.Compile(`^terraform_version_constraint\s+=\s+"(?P<version>.*)".*`)

if regex.MatchString(line) {
res := regex.FindStringSubmatch(line)
constraint = res[1]
Expand Down

0 comments on commit 15eac76

Please sign in to comment.