Files
atlantis/server/core/config/raw/autoplan.go
Shouichi Kamiya 2bd778b01e fix: auto plan when .terraform.lock.hcl changed (#3473)
Problem

When `projects` are specified and `when_modified` is not specified via
the config file, changing `.terraform.lock.hcl` file won't trigger auto
plan. This is because the default `raw.WhenModified` does not include
`.terraform.lock.hcl`.

Note that when projects are auto detected, changing
`.terraform.lock.hcl` triggers auto plan. This is because the
`cmd.DefaultAutoplanFileList` includes `.terraform.lock.hcl`.

Solution

Include `.terraform.lock.hcl` to the default `raw.WhenModified`.
2023-07-31 11:29:33 -04:00

48 lines
981 B
Go

package raw
import (
"github.com/runatlantis/atlantis/server/core/config/valid"
)
// DefaultAutoPlanWhenModified is the default element in the when_modified
// list if none is defined.
var DefaultAutoPlanWhenModified = []string{
"**/*.tf*",
"**/terragrunt.hcl",
"**/.terraform.lock.hcl",
}
type Autoplan struct {
WhenModified []string `yaml:"when_modified,omitempty"`
Enabled *bool `yaml:"enabled,omitempty"`
}
func (a Autoplan) ToValid() valid.Autoplan {
var v valid.Autoplan
if a.WhenModified == nil {
v.WhenModified = DefaultAutoPlanWhenModified
} else {
v.WhenModified = a.WhenModified
}
if a.Enabled == nil {
v.Enabled = true
} else {
v.Enabled = *a.Enabled
}
return v
}
func (a Autoplan) Validate() error {
return nil
}
// DefaultAutoPlan returns the default autoplan config.
func DefaultAutoPlan() valid.Autoplan {
return valid.Autoplan{
WhenModified: DefaultAutoPlanWhenModified,
Enabled: valid.DefaultAutoPlanEnabled,
}
}