Skip to content

Commit

Permalink
Allow ignoring dependency blocks (#106)
Browse files Browse the repository at this point in the history
Co-authored-by: dmattia <david@transcend.io>
  • Loading branch information
dmattia and dmattia committed Jan 25, 2021
1 parent 52025b0 commit 6804284
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ One way to customize the behavior of this module is through CLI flag values pass
| `--output` | Path of the file where configuration will be generated. Typically, you want a file named "atlantis.yaml". Default is to write to `stdout`. | "" |
| `--root` | Path to the root directory of the git repo you want to build config for. | current directory |
| `--terraform-version` | Default terraform version to specify for all modules. Can be overriden by locals | "" |
| `--ignore-dependency-blocks` | When true, dependencies found in `dependency` and `dependencies` blocks will be ignored | false |

## All Locals

Expand Down
4 changes: 3 additions & 1 deletion cmd/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func getDependencies(path string, terragruntOptions *options.TerragruntOptions)
}

// Get deps from `dependencies` and `dependency` blocks
if parsedConfig.Dependencies != nil {
if parsedConfig.Dependencies != nil && !ignoreDependencyBlocks {
for _, parsedPaths := range parsedConfig.Dependencies.Paths {
dependencies = append(dependencies, filepath.Join(parsedPaths, "terragrunt.hcl"))
}
Expand Down Expand Up @@ -400,6 +400,7 @@ var gitRoot string
var autoPlan bool
var autoMerge bool
var ignoreParentTerragrunt bool
var ignoreDependencyBlocks bool
var parallel bool
var createWorkspace bool
var createProjectName bool
Expand Down Expand Up @@ -428,6 +429,7 @@ func init() {
generateCmd.PersistentFlags().BoolVar(&autoPlan, "autoplan", false, "Enable auto plan. Default is disabled")
generateCmd.PersistentFlags().BoolVar(&autoMerge, "automerge", false, "Enable auto merge. Default is disabled")
generateCmd.PersistentFlags().BoolVar(&ignoreParentTerragrunt, "ignore-parent-terragrunt", true, "Ignore parent terragrunt configs (those which don't reference a terraform module). Default is enabled")
generateCmd.PersistentFlags().BoolVar(&ignoreDependencyBlocks, "ignore-dependency-blocks", false, "When true, dependencies found in `dependency` blocks will be ignored")
generateCmd.PersistentFlags().BoolVar(&parallel, "parallel", true, "Enables plans and applys to happen in parallel. Default is enabled")
generateCmd.PersistentFlags().BoolVar(&createWorkspace, "create-workspace", false, "Use different workspace for each project. Default is use default workspace")
generateCmd.PersistentFlags().BoolVar(&createProjectName, "create-project-name", false, "Add different name for each project. Default is false")
Expand Down
9 changes: 9 additions & 0 deletions cmd/generate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ func resetForRun() error {
autoMerge = false
cascadeDependencies = true
ignoreParentTerragrunt = true
ignoreDependencyBlocks = false
parallel = true
createWorkspace = false
createProjectName = false
Expand Down Expand Up @@ -166,6 +167,14 @@ func TestTerragruntDependencies(t *testing.T) {
})
}

func TestIgnoringTerragruntDependencies(t *testing.T) {
runTest(t, filepath.Join("golden", "terragrunt_dependency_ignored.yaml"), []string{
"--root",
filepath.Join("..", "test_examples", "terragrunt_dependency"),
"--ignore-dependency-blocks",
})
}

func TestCustomWorkflowName(t *testing.T) {
runTest(t, filepath.Join("golden", "different_workflow_names.yaml"), []string{
"--root",
Expand Down
17 changes: 17 additions & 0 deletions cmd/golden/terragrunt_dependency_ignored.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
automerge: false
parallel_apply: true
parallel_plan: true
projects:
- autoplan:
enabled: false
when_modified:
- '*.hcl'
- '*.tf*'
dir: dependency
- autoplan:
enabled: false
when_modified:
- '*.hcl'
- '*.tf*'
dir: depender
version: 3

0 comments on commit 6804284

Please sign in to comment.