Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update defaultwhenmodified to include **/terragrunt.hcl #858

Merged
merged 8 commits into from
Jan 20, 2020
1 change: 1 addition & 0 deletions server/events/matchers/models_pullrequest.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions server/events/matchers/models_repo.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions server/events/matchers/ptr_to_logging_simplelogger.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion server/events/runtime/env_step_runner.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package runtime

import (
"github.com/runatlantis/atlantis/server/events/models"
"strings"

"github.com/runatlantis/atlantis/server/events/models"
)

// EnvStepRunner set environment variables.
Expand Down
50 changes: 36 additions & 14 deletions server/events/yaml/parser_validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ projects:
WorkflowName: nil,
TerraformVersion: nil,
Autoplan: valid.Autoplan{
WhenModified: []string{"**/*.tf*"},
WhenModified: []string{"**/*.tf*", "**/terragrunt.hcl"},
Enabled: true,
},
ApplyRequirements: nil,
Expand All @@ -220,6 +220,28 @@ projects:
input: `
version: 3
projects:
- dir: "."
`,
exp: valid.RepoCfg{
Version: 3,
Projects: []valid.Project{
{
Dir: ".",
Workspace: "default",
Autoplan: valid.Autoplan{
WhenModified: []string{"**/*.tf*", "**/terragrunt.hcl"},
Enabled: true,
},
},
},
Workflows: make(map[string]valid.Workflow),
},
},
{
description: "autoplan should be enabled by default if only when_modified set",
input: `
version: 3
projects:
- dir: "."
autoplan:
when_modified: ["**/*.tf*"]
Expand Down Expand Up @@ -253,7 +275,7 @@ projects:
Dir: ".",
Workspace: "default",
Autoplan: valid.Autoplan{
WhenModified: []string{"**/*.tf*"},
WhenModified: []string{"**/*.tf*", "**/terragrunt.hcl"},
Enabled: true,
},
},
Expand All @@ -276,7 +298,7 @@ workflows: ~
Dir: ".",
Workspace: "default",
Autoplan: valid.Autoplan{
WhenModified: []string{"**/*.tf*"},
WhenModified: []string{"**/*.tf*", "**/terragrunt.hcl"},
Enabled: true,
},
},
Expand Down Expand Up @@ -304,7 +326,7 @@ workflows:
Dir: ".",
Workspace: "default",
Autoplan: valid.Autoplan{
WhenModified: []string{"**/*.tf*"},
WhenModified: []string{"**/*.tf*", "**/terragrunt.hcl"},
Enabled: true,
},
},
Expand Down Expand Up @@ -339,7 +361,7 @@ workflows:
WorkflowName: String("myworkflow"),
TerraformVersion: tfVersion,
Autoplan: valid.Autoplan{
WhenModified: []string{"**/*.tf*"},
WhenModified: []string{"**/*.tf*", "**/terragrunt.hcl"},
Enabled: true,
},
ApplyRequirements: []string{"approved"},
Expand Down Expand Up @@ -377,7 +399,7 @@ workflows:
WorkflowName: String("myworkflow"),
TerraformVersion: tfVersion,
Autoplan: valid.Autoplan{
WhenModified: []string{"**/*.tf*"},
WhenModified: []string{"**/*.tf*", "**/terragrunt.hcl"},
Enabled: false,
},
ApplyRequirements: []string{"approved"},
Expand Down Expand Up @@ -415,7 +437,7 @@ workflows:
WorkflowName: String("myworkflow"),
TerraformVersion: tfVersion,
Autoplan: valid.Autoplan{
WhenModified: []string{"**/*.tf*"},
WhenModified: []string{"**/*.tf*", "**/terragrunt.hcl"},
Enabled: false,
},
ApplyRequirements: []string{"mergeable"},
Expand Down Expand Up @@ -453,7 +475,7 @@ workflows:
WorkflowName: String("myworkflow"),
TerraformVersion: tfVersion,
Autoplan: valid.Autoplan{
WhenModified: []string{"**/*.tf*"},
WhenModified: []string{"**/*.tf*", "**/terragrunt.hcl"},
Enabled: false,
},
ApplyRequirements: []string{"mergeable", "approved"},
Expand Down Expand Up @@ -567,7 +589,7 @@ projects:
Dir: ".",
Workspace: "workspace",
Autoplan: valid.Autoplan{
WhenModified: []string{"**/*.tf*"},
WhenModified: []string{"**/*.tf*", "**/terragrunt.hcl"},
Enabled: true,
},
},
Expand All @@ -576,7 +598,7 @@ projects:
Dir: ".",
Workspace: "workspace",
Autoplan: valid.Autoplan{
WhenModified: []string{"**/*.tf*"},
WhenModified: []string{"**/*.tf*", "**/terragrunt.hcl"},
Enabled: true,
},
},
Expand Down Expand Up @@ -608,7 +630,7 @@ workflows:
Dir: ".",
Workspace: "default",
Autoplan: valid.Autoplan{
WhenModified: []string{"**/*.tf*"},
WhenModified: []string{"**/*.tf*", "**/terragrunt.hcl"},
Enabled: true,
},
},
Expand Down Expand Up @@ -670,7 +692,7 @@ workflows:
Dir: ".",
Workspace: "default",
Autoplan: valid.Autoplan{
WhenModified: []string{"**/*.tf*"},
WhenModified: []string{"**/*.tf*", "**/terragrunt.hcl"},
Enabled: true,
},
},
Expand Down Expand Up @@ -728,7 +750,7 @@ workflows:
Dir: ".",
Workspace: "default",
Autoplan: valid.Autoplan{
WhenModified: []string{"**/*.tf*"},
WhenModified: []string{"**/*.tf*", "**/terragrunt.hcl"},
Enabled: true,
},
},
Expand Down Expand Up @@ -782,7 +804,7 @@ workflows:
Dir: ".",
Workspace: "default",
Autoplan: valid.Autoplan{
WhenModified: []string{"**/*.tf*"},
WhenModified: []string{"**/*.tf*", "**/terragrunt.hcl"},
Enabled: true,
},
},
Expand Down
10 changes: 6 additions & 4 deletions server/events/yaml/raw/autoplan.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package raw

import "github.com/runatlantis/atlantis/server/events/yaml/valid"
import (
"github.com/runatlantis/atlantis/server/events/yaml/valid"
)

// DefaultAutoPlanWhenModified is the default element in the when_modified
// list if none is defined.
const DefaultAutoPlanWhenModified = "**/*.tf*"
var DefaultAutoPlanWhenModified = []string{"**/*.tf*", "**/terragrunt.hcl"}

type Autoplan struct {
WhenModified []string `yaml:"when_modified,omitempty"`
Expand All @@ -14,7 +16,7 @@ type Autoplan struct {
func (a Autoplan) ToValid() valid.Autoplan {
var v valid.Autoplan
if a.WhenModified == nil {
v.WhenModified = []string{DefaultAutoPlanWhenModified}
v.WhenModified = DefaultAutoPlanWhenModified
} else {
v.WhenModified = a.WhenModified
}
Expand All @@ -35,7 +37,7 @@ func (a Autoplan) Validate() error {
// DefaultAutoPlan returns the default autoplan config.
func DefaultAutoPlan() valid.Autoplan {
return valid.Autoplan{
WhenModified: []string{DefaultAutoPlanWhenModified},
WhenModified: DefaultAutoPlanWhenModified,
Enabled: valid.DefaultAutoPlanEnabled,
}
}
6 changes: 3 additions & 3 deletions server/events/yaml/raw/autoplan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func TestAutoplan_ToValid(t *testing.T) {
input: raw.Autoplan{},
exp: valid.Autoplan{
Enabled: true,
WhenModified: []string{"**/*.tf*"},
WhenModified: []string{"**/*.tf*", "**/terragrunt.hcl"},
},
},
{
Expand All @@ -129,7 +129,7 @@ func TestAutoplan_ToValid(t *testing.T) {
},
exp: valid.Autoplan{
Enabled: false,
WhenModified: []string{"**/*.tf*"},
WhenModified: []string{"**/*.tf*", "**/terragrunt.hcl"},
},
},
{
Expand All @@ -139,7 +139,7 @@ func TestAutoplan_ToValid(t *testing.T) {
},
exp: valid.Autoplan{
Enabled: true,
WhenModified: []string{"**/*.tf*"},
WhenModified: []string{"**/*.tf*", "**/terragrunt.hcl"},
},
},
}
Expand Down
12 changes: 6 additions & 6 deletions server/events/yaml/raw/project_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ func TestProject_ToValid(t *testing.T) {
WorkflowName: nil,
TerraformVersion: nil,
Autoplan: valid.Autoplan{
WhenModified: []string{"**/*.tf*"},
WhenModified: []string{"**/*.tf*", "**/terragrunt.hcl"},
Enabled: true,
},
ApplyRequirements: nil,
Expand Down Expand Up @@ -276,7 +276,7 @@ func TestProject_ToValid(t *testing.T) {
Workspace: "default",
TerraformVersion: tfVersionPointEleven,
Autoplan: valid.Autoplan{
WhenModified: []string{"**/*.tf*"},
WhenModified: []string{"**/*.tf*", "**/terragrunt.hcl"},
Enabled: true,
},
},
Expand All @@ -290,7 +290,7 @@ func TestProject_ToValid(t *testing.T) {
Dir: ".",
Workspace: "default",
Autoplan: valid.Autoplan{
WhenModified: []string{"**/*.tf*"},
WhenModified: []string{"**/*.tf*", "**/terragrunt.hcl"},
Enabled: true,
},
},
Expand All @@ -304,7 +304,7 @@ func TestProject_ToValid(t *testing.T) {
Dir: "mydir",
Workspace: "default",
Autoplan: valid.Autoplan{
WhenModified: []string{"**/*.tf*"},
WhenModified: []string{"**/*.tf*", "**/terragrunt.hcl"},
Enabled: true,
},
},
Expand All @@ -319,7 +319,7 @@ func TestProject_ToValid(t *testing.T) {
Dir: "mydir",
Workspace: "default",
Autoplan: valid.Autoplan{
WhenModified: []string{"**/*.tf*"},
WhenModified: []string{"**/*.tf*", "**/terragrunt.hcl"},
Enabled: true,
},
},
Expand All @@ -334,7 +334,7 @@ func TestProject_ToValid(t *testing.T) {
Dir: ".",
Workspace: "default",
Autoplan: valid.Autoplan{
WhenModified: []string{"**/*.tf*"},
WhenModified: []string{"**/*.tf*", "**/terragrunt.hcl"},
Enabled: true,
},
},
Expand Down
2 changes: 1 addition & 1 deletion server/events/yaml/raw/repo_cfg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ func TestConfig_ToValid(t *testing.T) {
Dir: "mydir",
Workspace: "default",
Autoplan: valid.Autoplan{
WhenModified: []string{"**/*.tf*"},
WhenModified: []string{"**/*.tf*", "**/terragrunt.hcl"},
Enabled: true,
},
},
Expand Down