Skip to content

Commit

Permalink
Only sets apply_requirements if explicitly set in locals (#130)
Browse files Browse the repository at this point in the history
* Fix apply_requirements bug

* Fix tests updated with bug

* bump versions
  • Loading branch information
dmattia authored Mar 25, 2021
1 parent ec2ca6e commit b065f4a
Show file tree
Hide file tree
Showing 41 changed files with 152 additions and 142 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION=1.3.0
VERSION=1.3.1
PATH_BUILD=build/
FILE_COMMAND=terragrunt-atlantis-config
FILE_ARCH=darwin_amd64
Expand Down
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Then, make sure `terragrunt-atlantis-config` is present on your Atlantis server.

```hcl
variable "terragrunt_atlantis_config_version" {
default = "1.3.0"
default = "1.3.1"
}
build {
Expand Down Expand Up @@ -92,8 +92,7 @@ locals {
In your `atlantis.yaml` file, you will end up seeing output like:

```yaml
- apply_requirements: []
autoplan:
- autoplan:
enabled: false
when_modified:
- "*.hcl"
Expand Down Expand Up @@ -169,7 +168,7 @@ You can install this tool locally to checkout what kinds of config it will gener
Recommended: Install any version via go get:

```bash
cd && GO111MODULE=on go get github.com/transcend-io/[email protected].0 && cd -
cd && GO111MODULE=on go get github.com/transcend-io/[email protected].1 && cd -
```

This module officially supports golang versions v1.13, v1.14, and v1.15, tested on CircleCI with each build
Expand Down
3 changes: 2 additions & 1 deletion cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ type AtlantisProject struct {
// The terraform version to use for this project
TerraformVersion string `json:"terraform_version,omitempty"`

ApplyRequirements []string `json:"apply_requirements,flow"`
// We only want to output `apply_requirements` if explicitly stated in a local value
ApplyRequirements *[]string `json:"apply_requirements,omitempty"`
}

// Autoplan settings for which plans affect other plans
Expand Down
9 changes: 6 additions & 3 deletions cmd/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,12 @@ func createProject(sourcePath string) (*AtlantisProject, error) {
workflow = locals.AtlantisWorkflow
}

applyRequirements := defaultApplyRequirements
if locals.ApplyRequirements != nil && len(locals.ApplyRequirements) > 0 {
applyRequirements = locals.ApplyRequirements
applyRequirements := &defaultApplyRequirements
if len(defaultApplyRequirements) == 0 {
applyRequirements = nil
}
if locals.ApplyRequirements != nil {
applyRequirements = &locals.ApplyRequirements
}

resolvedAutoPlan := autoPlan
Expand Down
28 changes: 28 additions & 0 deletions cmd/golden/apply_overrides.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,32 @@ projects:
- '*.hcl'
- '*.tf*'
dir: child_that_overrides
- apply_requirements: []
autoplan:
enabled: false
when_modified:
- '*.hcl'
- '*.tf*'
dir: child_that_overrides_to_empty
- autoplan:
enabled: false
when_modified:
- '*.hcl'
- '*.tf*'
dir: standalone_module_that_does_not_specify
- apply_requirements:
- mergeable
autoplan:
enabled: false
when_modified:
- '*.hcl'
- '*.tf*'
dir: standalone_module_that_specifies
- apply_requirements: []
autoplan:
enabled: false
when_modified:
- '*.hcl'
- '*.tf*'
dir: standalone_module_that_specifies_empty
version: 3
9 changes: 3 additions & 6 deletions cmd/golden/autoplan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,19 @@ automerge: false
parallel_apply: true
parallel_plan: true
projects:
- apply_requirements: []
autoplan:
- autoplan:
enabled: false
when_modified:
- '*.hcl'
- '*.tf*'
dir: autoplan_false
- apply_requirements: []
autoplan:
- autoplan:
enabled: true
when_modified:
- '*.hcl'
- '*.tf*'
dir: autoplan_true
- apply_requirements: []
autoplan:
- autoplan:
enabled: true
when_modified:
- '*.hcl'
Expand Down
3 changes: 1 addition & 2 deletions cmd/golden/basic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ automerge: false
parallel_apply: true
parallel_plan: true
projects:
- apply_requirements: []
autoplan:
- autoplan:
enabled: false
when_modified:
- '*.hcl'
Expand Down
12 changes: 4 additions & 8 deletions cmd/golden/chained_dependency.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,20 @@ automerge: false
parallel_apply: true
parallel_plan: true
projects:
- apply_requirements: []
autoplan:
- autoplan:
enabled: false
when_modified:
- '*.hcl'
- '*.tf*'
dir: dependency
- apply_requirements: []
autoplan:
- autoplan:
enabled: false
when_modified:
- '*.hcl'
- '*.tf*'
- ../dependency/terragrunt.hcl
dir: depender
- apply_requirements: []
autoplan:
- autoplan:
enabled: false
when_modified:
- '*.hcl'
Expand All @@ -27,8 +24,7 @@ projects:
- ../dependency/terragrunt.hcl
- nested/terragrunt.hcl
dir: depender_on_depender
- apply_requirements: []
autoplan:
- autoplan:
enabled: false
when_modified:
- '*.hcl'
Expand Down
12 changes: 4 additions & 8 deletions cmd/golden/chained_dependency_no_flag.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,28 @@ automerge: false
parallel_apply: true
parallel_plan: true
projects:
- apply_requirements: []
autoplan:
- autoplan:
enabled: false
when_modified:
- '*.hcl'
- '*.tf*'
dir: dependency
- apply_requirements: []
autoplan:
- autoplan:
enabled: false
when_modified:
- '*.hcl'
- '*.tf*'
- ../dependency/terragrunt.hcl
dir: depender
- apply_requirements: []
autoplan:
- autoplan:
enabled: false
when_modified:
- '*.hcl'
- '*.tf*'
- ../depender/terragrunt.hcl
- nested/terragrunt.hcl
dir: depender_on_depender
- apply_requirements: []
autoplan:
- autoplan:
enabled: false
when_modified:
- '*.hcl'
Expand Down
9 changes: 3 additions & 6 deletions cmd/golden/different_workflow_names.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,20 @@ automerge: false
parallel_apply: true
parallel_plan: true
projects:
- apply_requirements: []
autoplan:
- autoplan:
enabled: false
when_modified:
- '*.hcl'
- '*.tf*'
dir: defaultWorkflow
- apply_requirements: []
autoplan:
- autoplan:
enabled: false
when_modified:
- '*.hcl'
- '*.tf*'
dir: workflowA
workflow: workflowA
- apply_requirements: []
autoplan:
- autoplan:
enabled: false
when_modified:
- '*.hcl'
Expand Down
15 changes: 5 additions & 10 deletions cmd/golden/extraArguments.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ automerge: false
parallel_apply: true
parallel_plan: true
projects:
- apply_requirements: []
autoplan:
- autoplan:
enabled: false
when_modified:
- '*.hcl'
Expand All @@ -14,15 +13,13 @@ projects:
- dev.tfvars
- us-east-1.tfvars
dir: child
- apply_requirements: []
autoplan:
- autoplan:
enabled: false
when_modified:
- '*.hcl'
- '*.tf*'
dir: no_files_at_all
- apply_requirements: []
autoplan:
- autoplan:
enabled: false
when_modified:
- '*.hcl'
Expand All @@ -32,16 +29,14 @@ projects:
- dev.tfvars
- us-east-1.tfvars
dir: only_optional_files
- apply_requirements: []
autoplan:
- autoplan:
enabled: false
when_modified:
- '*.hcl'
- '*.tf*'
- ../terraform.tfvars
dir: only_required_files
- apply_requirements: []
autoplan:
- autoplan:
enabled: false
when_modified:
- '*.hcl'
Expand Down
3 changes: 1 addition & 2 deletions cmd/golden/extra_dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ automerge: false
parallel_apply: true
parallel_plan: true
projects:
- apply_requirements: []
autoplan:
- autoplan:
enabled: false
when_modified:
- '*.hcl'
Expand Down
12 changes: 4 additions & 8 deletions cmd/golden/filterInfraLiveNonProd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ automerge: false
parallel_apply: true
parallel_plan: true
projects:
- apply_requirements: []
autoplan:
- autoplan:
enabled: false
when_modified:
- '*.hcl'
Expand All @@ -12,8 +11,7 @@ projects:
- ../../region.hcl
- ../env.hcl
dir: non-prod/us-east-1/qa/mysql
- apply_requirements: []
autoplan:
- autoplan:
enabled: false
when_modified:
- '*.hcl'
Expand All @@ -22,8 +20,7 @@ projects:
- ../../region.hcl
- ../env.hcl
dir: non-prod/us-east-1/qa/webserver-cluster
- apply_requirements: []
autoplan:
- autoplan:
enabled: false
when_modified:
- '*.hcl'
Expand All @@ -32,8 +29,7 @@ projects:
- ../../region.hcl
- ../env.hcl
dir: non-prod/us-east-1/stage/mysql
- apply_requirements: []
autoplan:
- autoplan:
enabled: false
when_modified:
- '*.hcl'
Expand Down
6 changes: 2 additions & 4 deletions cmd/golden/filterInfraLiveProd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ automerge: false
parallel_apply: true
parallel_plan: true
projects:
- apply_requirements: []
autoplan:
- autoplan:
enabled: false
when_modified:
- '*.hcl'
Expand All @@ -12,8 +11,7 @@ projects:
- ../../region.hcl
- ../env.hcl
dir: prod/us-east-1/prod/mysql
- apply_requirements: []
autoplan:
- autoplan:
enabled: false
when_modified:
- '*.hcl'
Expand Down
Loading

0 comments on commit b065f4a

Please sign in to comment.