Skip to content

Commit

Permalink
Add support for -var-file extra_arguments (#69)
Browse files Browse the repository at this point in the history
Co-authored-by: dmattia <david@transcend.io>
  • Loading branch information
dmattia and dmattia authored Sep 30, 2020
1 parent a97e7da commit 93800b3
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION=0.9.3
VERSION=0.9.4
PATH_BUILD=build/
FILE_COMMAND=terragrunt-atlantis-config
FILE_ARCH=darwin_amd64
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ jobs:
id: atlantis_validator
uses: transcend-io/terragrunt-atlantis-config-github-action@v0.0.3
with:
version: v0.9.3
version: v0.9.4
extra_args: '--autoplan --parallel=false
```

Expand Down
7 changes: 7 additions & 0 deletions cmd/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,13 @@ func getDependencies(path string) ([]string, error) {
dependencies = append(dependencies, file)
}
}
if arg.Arguments != nil {
for _, cliFlag := range *arg.Arguments {
if strings.HasPrefix(cliFlag, "-var-file=") {
dependencies = append(dependencies, strings.TrimPrefix(cliFlag, "-var-file="))
}
}
}
}
}

Expand Down
8 changes: 8 additions & 0 deletions cmd/golden/extraArguments.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,12 @@ projects:
- '*.tf*'
- ../terraform.tfvars
dir: only_required_files
- autoplan:
enabled: false
when_modified:
- '*.hcl'
- '*.tf*'
- ../../../../common_vars/apps/consul/sg.tfvars
- main.tfvars
dir: var_file
version: 3
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import "github.com/transcend-io/terragrunt-atlantis-config/cmd"
// This variable is set at build time using -ldflags parameters.
// But we still set a default here for those using plain `go get` downloads
// For more info, see: http://stackoverflow.com/a/11355611/483528
var VERSION string = "0.9.3"
var VERSION string = "0.9.4"

func main() {
cmd.Execute(VERSION)
Expand Down
25 changes: 25 additions & 0 deletions test_examples/extra_arguments/var_file/terragrunt.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
include {
path = find_in_parent_folders()
}

terraform {
source = "git::git@github.com:transcend-io/terraform-aws-fargate-container?ref=v0.0.4"
extra_arguments "conditional_vars" {
commands = [
"apply",
"plan",
"import",
"push",
"refresh"
]

arguments = [
"-var-file=${get_terragrunt_dir()}/../../../../common_vars/apps/consul/sg.tfvars",
"-var-file=${get_terragrunt_dir()}/main.tfvars"
]
}
}

inputs = {
foo = "bar"
}

0 comments on commit 93800b3

Please sign in to comment.