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

feat: add support to autodiscover flag #272

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ One way to customize the behavior of this module is through CLI flag values pass
|------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------|
| `--autoplan` | The default value for autoplan settings. Can be overriden by locals. | false |
| `--automerge` | Enables the automerge setting for a repo. | false |
| `--auto-discover` | Enables the auto discovery settings for the repo. | true |
| `--cascade-dependencies` | When true, dependencies will cascade, meaning that a module will be declared to depend not only on its dependencies, but all dependencies of its dependencies all the way down. | true |
| `--ignore-parent-terragrunt` | Ignore parent Terragrunt configs (those which don't reference a terraform module).<br>In most cases, this should be set to `true` | true |
| `--parallel` | Enables `plan`s and `apply`s to happen in parallel. Will typically be used with `--create-workspace` | true |
Expand Down
8 changes: 8 additions & 0 deletions cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ type AtlantisConfig struct {
// If Atlantis should merge after finishing `atlantis apply`
AutoMerge bool `json:"automerge"`

// If Atlantis should do a autodiscovery when dont have projects in config
AutoDiscover *Autodiscover `json:"autodiscover"`

// If Atlantis should allow plans to occur in parallel
ParallelPlan bool `json:"parallel_plan"`

Expand Down Expand Up @@ -66,6 +69,11 @@ type AutoplanConfig struct {
Enabled bool `json:"enabled"`
}

// Autodiscover settings
type Autodiscover struct {
Enabled bool
}

// Checks if an output file already exists. If it does, it reads it
// in to preserve some parts of the old config
func readOldConfig() (*AtlantisConfig, error) {
Expand Down
3 changes: 3 additions & 0 deletions cmd/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,7 @@ func main(cmd *cobra.Command, args []string) error {
config := AtlantisConfig{
Version: 3,
AutoMerge: autoMerge,
AutoDiscover: &Autodiscover{Enabled: autoDiscover},
ParallelPlan: parallel,
ParallelApply: parallel,
}
Expand Down Expand Up @@ -895,6 +896,7 @@ func main(cmd *cobra.Command, args []string) error {
var gitRoot string
var autoPlan bool
var autoMerge bool
var autoDiscover bool
var ignoreParentTerragrunt bool
var createParentProject bool
var ignoreDependencyBlocks bool
Expand Down Expand Up @@ -934,6 +936,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(&autoDiscover, "auto-discover", true, "Enable auto discover when dont spicify any project in the config. Default is enabled")
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(&createParentProject, "create-parent-project", false, "Create a project for the parent terragrunt configs (those which don't reference a terraform module). Default is disabled")
generateCmd.PersistentFlags().BoolVar(&ignoreDependencyBlocks, "ignore-dependency-blocks", false, "When true, dependencies found in `dependency` blocks will be ignored")
Expand Down
5 changes: 5 additions & 0 deletions cmd/golden/autodiscover_disabled.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
automerge: true
autodiscover: false
parallel_apply: true
parallel_plan: true
version: 3