diff --git a/server/controllers/events/events_controller_e2e_test.go b/server/controllers/events/events_controller_e2e_test.go index 93c63df3bd..d585a6ac71 100644 --- a/server/controllers/events/events_controller_e2e_test.go +++ b/server/controllers/events/events_controller_e2e_test.go @@ -1319,6 +1319,7 @@ func setupE2E(t *testing.T, repoDir string, opt setupOption) (events_controllers false, false, false, + valid.Autodiscover{Enabled: true}, false, false, "", diff --git a/server/core/config/parser_validator_test.go b/server/core/config/parser_validator_test.go index 1175720470..afb5b83831 100644 --- a/server/core/config/parser_validator_test.go +++ b/server/core/config/parser_validator_test.go @@ -180,7 +180,7 @@ workflows: StateRm: valid.DefaultStateRmStage, }, }, - Autodiscover: valid.Autodiscover{Enabled: true}, + Autodiscover: &valid.Autodiscover{Enabled: true}, }, }, @@ -194,7 +194,7 @@ projects:`, Version: 3, Projects: nil, Workflows: map[string]valid.Workflow{}, - Autodiscover: valid.Autodiscover{Enabled: true}, + Autodiscover: &valid.Autodiscover{Enabled: true}, }, }, { @@ -227,7 +227,7 @@ projects: }, }, Workflows: map[string]valid.Workflow{}, - Autodiscover: valid.Autodiscover{Enabled: true}, + Autodiscover: &valid.Autodiscover{Enabled: true}, }, }, { @@ -250,7 +250,7 @@ projects: }, }, Workflows: make(map[string]valid.Workflow), - Autodiscover: valid.Autodiscover{Enabled: true}, + Autodiscover: &valid.Autodiscover{Enabled: true}, }, }, { @@ -275,7 +275,7 @@ projects: }, }, Workflows: make(map[string]valid.Workflow), - Autodiscover: valid.Autodiscover{Enabled: true}, + Autodiscover: &valid.Autodiscover{Enabled: true}, }, }, { @@ -285,7 +285,7 @@ version: 3 `, exp: valid.RepoCfg{ Version: 3, - Autodiscover: valid.Autodiscover{Enabled: true}, + Autodiscover: &valid.Autodiscover{Enabled: true}, Workflows: make(map[string]valid.Workflow), }, }, @@ -298,7 +298,7 @@ autodiscover: `, exp: valid.RepoCfg{ Version: 3, - Autodiscover: valid.Autodiscover{Enabled: false}, + Autodiscover: &valid.Autodiscover{Enabled: false}, Workflows: make(map[string]valid.Workflow), }, }, @@ -322,7 +322,7 @@ projects: }, }, Workflows: make(map[string]valid.Workflow), - Autodiscover: valid.Autodiscover{Enabled: true}, + Autodiscover: &valid.Autodiscover{Enabled: true}, }, }, { @@ -346,7 +346,7 @@ workflows: ~ }, }, Workflows: make(map[string]valid.Workflow), - Autodiscover: valid.Autodiscover{Enabled: true}, + Autodiscover: &valid.Autodiscover{Enabled: true}, }, }, { @@ -377,7 +377,7 @@ workflows: Workflows: map[string]valid.Workflow{ "default": defaultWorkflow("default"), }, - Autodiscover: valid.Autodiscover{Enabled: true}, + Autodiscover: &valid.Autodiscover{Enabled: true}, }, }, { @@ -410,7 +410,7 @@ workflows: Workflows: map[string]valid.Workflow{ "myworkflow": defaultWorkflow("myworkflow"), }, - Autodiscover: valid.Autodiscover{Enabled: true}, + Autodiscover: &valid.Autodiscover{Enabled: true}, }, }, { @@ -445,7 +445,7 @@ workflows: Workflows: map[string]valid.Workflow{ "myworkflow": defaultWorkflow("myworkflow"), }, - Autodiscover: valid.Autodiscover{Enabled: true}, + Autodiscover: &valid.Autodiscover{Enabled: true}, }, }, { @@ -480,7 +480,7 @@ workflows: Workflows: map[string]valid.Workflow{ "myworkflow": defaultWorkflow("myworkflow"), }, - Autodiscover: valid.Autodiscover{Enabled: true}, + Autodiscover: &valid.Autodiscover{Enabled: true}, }, }, { @@ -515,7 +515,7 @@ workflows: Workflows: map[string]valid.Workflow{ "myworkflow": defaultWorkflow("myworkflow"), }, - Autodiscover: valid.Autodiscover{Enabled: true}, + Autodiscover: &valid.Autodiscover{Enabled: true}, }, }, { @@ -550,7 +550,7 @@ workflows: Workflows: map[string]valid.Workflow{ "myworkflow": defaultWorkflow("myworkflow"), }, - Autodiscover: valid.Autodiscover{Enabled: true}, + Autodiscover: &valid.Autodiscover{Enabled: true}, }, }, { @@ -585,7 +585,7 @@ workflows: Workflows: map[string]valid.Workflow{ "myworkflow": defaultWorkflow("myworkflow"), }, - Autodiscover: valid.Autodiscover{Enabled: true}, + Autodiscover: &valid.Autodiscover{Enabled: true}, }, }, { @@ -620,7 +620,7 @@ workflows: Workflows: map[string]valid.Workflow{ "myworkflow": defaultWorkflow("myworkflow"), }, - Autodiscover: valid.Autodiscover{Enabled: true}, + Autodiscover: &valid.Autodiscover{Enabled: true}, }, }, { @@ -655,7 +655,7 @@ workflows: Workflows: map[string]valid.Workflow{ "myworkflow": defaultWorkflow("myworkflow"), }, - Autodiscover: valid.Autodiscover{Enabled: true}, + Autodiscover: &valid.Autodiscover{Enabled: true}, }, }, { @@ -772,7 +772,7 @@ projects: }, }, Workflows: map[string]valid.Workflow{}, - Autodiscover: valid.Autodiscover{Enabled: true}, + Autodiscover: &valid.Autodiscover{Enabled: true}, }, }, { @@ -863,7 +863,7 @@ workflows: }, }, }, - Autodiscover: valid.Autodiscover{Enabled: true}, + Autodiscover: &valid.Autodiscover{Enabled: true}, }, }, { @@ -967,7 +967,7 @@ workflows: }, }, }, - Autodiscover: valid.Autodiscover{Enabled: true}, + Autodiscover: &valid.Autodiscover{Enabled: true}, }, }, { @@ -1051,7 +1051,7 @@ workflows: }, }, }, - Autodiscover: valid.Autodiscover{Enabled: true}, + Autodiscover: &valid.Autodiscover{Enabled: true}, }, }, { @@ -1150,7 +1150,7 @@ workflows: }, }, }, - Autodiscover: valid.Autodiscover{Enabled: true}, + Autodiscover: &valid.Autodiscover{Enabled: true}, }, }, } diff --git a/server/core/config/raw/repo_cfg.go b/server/core/config/raw/repo_cfg.go index 4aa837ef4f..021575c43f 100644 --- a/server/core/config/raw/repo_cfg.go +++ b/server/core/config/raw/repo_cfg.go @@ -7,24 +7,6 @@ import ( "github.com/runatlantis/atlantis/server/core/config/valid" ) -// DefaultAutomerge is the default setting for automerge. -const DefaultAutomerge = false - -// DefaultAutodiscover is the default setting for autodiscover. -const DefaultAutodiscover = true - -// DefaultParallelApply is the default setting for parallel apply -const DefaultParallelApply = false - -// DefaultParallelPlan is the default setting for parallel plan -const DefaultParallelPlan = false - -// DefaultParallelPolicyCheck is the default setting for parallel plan -const DefaultParallelPolicyCheck = false - -// DefaultDeleteSourceBranchOnMerge being false is the default setting whether or not to remove a source branch on merge -const DefaultDeleteSourceBranchOnMerge = false - // DefaultEmojiReaction is the default emoji reaction for repos const DefaultEmojiReaction = "" @@ -76,27 +58,18 @@ func (r RepoCfg) ToValid() valid.RepoCfg { validProjects = append(validProjects, p.ToValid()) } - automerge := DefaultAutomerge - if r.Automerge != nil { - automerge = *r.Automerge - } - - var autodiscover valid.Autodiscover + var autodiscover *valid.Autodiscover if r.Autodiscover == nil { - autodiscover = DefaultAutoDiscover() + defaultAutoDiscover := DefaultAutoDiscover() + autodiscover = &defaultAutoDiscover } else { - autodiscover = r.Autodiscover.ToValid() + validAutoDiscover := r.Autodiscover.ToValid() + autodiscover = &validAutoDiscover } - parallelApply := DefaultParallelApply - if r.ParallelApply != nil { - parallelApply = *r.ParallelApply - } - - parallelPlan := DefaultParallelPlan - if r.ParallelPlan != nil { - parallelPlan = *r.ParallelPlan - } + automerge := r.Automerge + parallelApply := r.ParallelApply + parallelPlan := r.ParallelPlan emojiReaction := DefaultEmojiReaction if r.EmojiReaction != nil { diff --git a/server/core/config/raw/repo_cfg_test.go b/server/core/config/raw/repo_cfg_test.go index cd55e87f18..783fe155b0 100644 --- a/server/core/config/raw/repo_cfg_test.go +++ b/server/core/config/raw/repo_cfg_test.go @@ -248,7 +248,7 @@ func TestConfig_ToValid(t *testing.T) { exp: valid.RepoCfg{ Version: 2, Workflows: make(map[string]valid.Workflow), - Autodiscover: valid.Autodiscover{Enabled: true}, + Autodiscover: &valid.Autodiscover{Enabled: true}, }, }, { @@ -263,7 +263,7 @@ func TestConfig_ToValid(t *testing.T) { Version: 2, Workflows: map[string]valid.Workflow{}, Projects: nil, - Autodiscover: valid.Autodiscover{Enabled: true}, + Autodiscover: &valid.Autodiscover{Enabled: true}, }, }, { @@ -277,7 +277,7 @@ func TestConfig_ToValid(t *testing.T) { ParallelApply: nil, AbortOnExcecutionOrderFail: false, Workflows: map[string]valid.Workflow{}, - Autodiscover: valid.Autodiscover{Enabled: true}, + Autodiscover: &valid.Autodiscover{Enabled: true}, }, }, { @@ -294,7 +294,7 @@ func TestConfig_ToValid(t *testing.T) { ParallelApply: Bool(true), AbortOnExcecutionOrderFail: true, Workflows: map[string]valid.Workflow{}, - Autodiscover: valid.Autodiscover{Enabled: true}, + Autodiscover: &valid.Autodiscover{Enabled: true}, }, }, { @@ -311,7 +311,7 @@ func TestConfig_ToValid(t *testing.T) { ParallelApply: Bool(false), AbortOnExcecutionOrderFail: false, Workflows: map[string]valid.Workflow{}, - Autodiscover: valid.Autodiscover{Enabled: true}, + Autodiscover: &valid.Autodiscover{Enabled: true}, }, }, { @@ -322,7 +322,7 @@ func TestConfig_ToValid(t *testing.T) { }, exp: valid.RepoCfg{ Version: 2, - Autodiscover: valid.Autodiscover{Enabled: false}, + Autodiscover: &valid.Autodiscover{Enabled: false}, Workflows: map[string]valid.Workflow{}, }, }, @@ -354,7 +354,7 @@ func TestConfig_ToValid(t *testing.T) { StateRm: valid.DefaultStateRmStage, }, }, - Autodiscover: valid.Autodiscover{Enabled: true}, + Autodiscover: &valid.Autodiscover{Enabled: true}, }, }, { @@ -411,9 +411,9 @@ func TestConfig_ToValid(t *testing.T) { }, exp: valid.RepoCfg{ Version: 2, - Automerge: true, - Autodiscover: valid.Autodiscover{Enabled: true}, - ParallelApply: true, + Automerge: Bool(true), + Autodiscover: &valid.Autodiscover{Enabled: true}, + ParallelApply: Bool(true), Workflows: map[string]valid.Workflow{ "myworkflow": { Name: "myworkflow", diff --git a/server/core/config/valid/repo_cfg.go b/server/core/config/valid/repo_cfg.go index 73f8cbffee..e2fdf5c04c 100644 --- a/server/core/config/valid/repo_cfg.go +++ b/server/core/config/valid/repo_cfg.go @@ -18,11 +18,11 @@ type RepoCfg struct { Projects []Project Workflows map[string]Workflow PolicySets PolicySets - Automerge bool - Autodiscover Autodiscover - ParallelApply bool - ParallelPlan bool - ParallelPolicyCheck bool + Automerge *bool + Autodiscover *Autodiscover + ParallelApply *bool + ParallelPlan *bool + ParallelPolicyCheck *bool DeleteSourceBranchOnMerge *bool RepoLocking *bool CustomPolicyCheck *bool @@ -130,6 +130,7 @@ type Project struct { WorkflowName *string TerraformVersion *version.Version Autoplan Autoplan + Autodiscover Autodiscover PlanRequirements []string ApplyRequirements []string ImportRequirements []string diff --git a/server/events/project_command_builder.go b/server/events/project_command_builder.go index 1fb09812cf..34d88ec528 100644 --- a/server/events/project_command_builder.go +++ b/server/events/project_command_builder.go @@ -55,6 +55,7 @@ func NewInstrumentedProjectCommandBuilder( skipCloneNoChanges bool, EnableRegExpCmd bool, EnableAutoMerge bool, + EnableAutoDiscover valid.Autodiscover, EnableParallelPlan bool, EnableParallelApply bool, AutoDetectModuleFiles string, @@ -86,6 +87,7 @@ func NewInstrumentedProjectCommandBuilder( skipCloneNoChanges, EnableRegExpCmd, EnableAutoMerge, + EnableAutoDiscover, EnableParallelPlan, EnableParallelApply, AutoDetectModuleFiles, @@ -115,6 +117,7 @@ func NewProjectCommandBuilder( skipCloneNoChanges bool, EnableRegExpCmd bool, EnableAutoMerge bool, + EnableAutoDiscover valid.Autodiscover, EnableParallelPlan bool, EnableParallelApply bool, AutoDetectModuleFiles string, @@ -137,6 +140,7 @@ func NewProjectCommandBuilder( SkipCloneNoChanges: skipCloneNoChanges, EnableRegExpCmd: EnableRegExpCmd, EnableAutoMerge: EnableAutoMerge, + EnableAutoDiscover: EnableAutoDiscover, EnableParallelPlan: EnableParallelPlan, EnableParallelApply: EnableParallelApply, AutoDetectModuleFiles: AutoDetectModuleFiles, @@ -234,6 +238,8 @@ type DefaultProjectCommandBuilder struct { EnableRegExpCmd bool // User config option: Automatically merge pull requests after all plans have been successfully applied. EnableAutoMerge bool + // User config option: Enables auto-discovery of projects in a repository. + EnableAutoDiscover valid.Autodiscover // User config option: Whether to run plan operations in parallel. EnableParallelPlan bool // User config option: Whether to run apply operations in parallel. @@ -423,6 +429,7 @@ func (p *DefaultProjectCommandBuilder) buildAllCommandsByCfg(ctx *command.Contex ctx.Log.Debug("moduleInfo for %s (matching %q) = %v", repoDir, p.AutoDetectModuleFiles, moduleInfo) automerge := p.EnableAutoMerge + autodiscover := p.EnableAutoDiscover parallelApply := p.EnableParallelApply parallelPlan := p.EnableParallelPlan abortOnExcecutionOrderFail := DefaultAbortOnExcecutionOrderFail @@ -430,6 +437,11 @@ func (p *DefaultProjectCommandBuilder) buildAllCommandsByCfg(ctx *command.Contex if repoCfg.Automerge != nil { automerge = *repoCfg.Automerge } + if repoCfg.Autodiscover != nil { + autodiscover = *repoCfg.Autodiscover + } else { + autodiscover = valid.Autodiscover{Enabled: DefaultAutoDiscoverEnabled} + } if repoCfg.ParallelApply != nil { parallelApply = *repoCfg.ParallelApply } @@ -458,12 +470,12 @@ func (p *DefaultProjectCommandBuilder) buildAllCommandsByCfg(ctx *command.Contex mergedCfg, commentFlags, repoDir, - repoCfg.Automerge, - repoCfg.Autodiscover, - repoCfg.ParallelApply, - repoCfg.ParallelPlan, + automerge, + autodiscover, + parallelApply, + parallelPlan, verbose, - repoCfg.AbortOnExcecutionOrderFail, + abortOnExcecutionOrderFail, p.TerraformExecutor, )...) } @@ -488,18 +500,7 @@ func (p *DefaultProjectCommandBuilder) buildAllCommandsByCfg(ctx *command.Contex if err != nil { return nil, errors.Wrapf(err, "looking for Terraform Cloud workspace from configuration %s", repoDir) } - automerge := DefaultAutomergeEnabled - autodiscover := valid.Autodiscover{Enabled: DefaultAutoDiscoverEnabled} - parallelApply := DefaultParallelApplyEnabled - parallelPlan := DefaultParallelPlanEnabled - abortOnExcecutionOrderFail := DefaultAbortOnExcecutionOrderFail - if hasRepoCfg { - automerge = repoCfg.Automerge - parallelApply = repoCfg.ParallelApply - parallelPlan = repoCfg.ParallelPlan - autodiscover = repoCfg.Autodiscover - abortOnExcecutionOrderFail = repoCfg.AbortOnExcecutionOrderFail - } + pCfg := p.GlobalCfg.DefaultProjCfg(ctx.Log, ctx.Pull.BaseRepo.ID(), mp.Path, pWorkspace) projCtxs = append(projCtxs, @@ -803,7 +804,7 @@ func (p *DefaultProjectCommandBuilder) buildProjectCommandCtx(ctx *command.Conte var projCfg valid.MergedProjectCfg automerge := p.EnableAutoMerge - autodiscover := valid.Autodiscover{Enabled: DefaultAutoDiscoverEnabled} + autodiscover := p.EnableAutoDiscover parallelApply := p.EnableParallelApply parallelPlan := p.EnableParallelPlan abortOnExcecutionOrderFail := DefaultAbortOnExcecutionOrderFail @@ -811,9 +812,11 @@ func (p *DefaultProjectCommandBuilder) buildProjectCommandCtx(ctx *command.Conte if repoCfgPtr.Automerge != nil { automerge = *repoCfgPtr.Automerge } - if repoCfgPtr.Autodiscover != nil { - autodiscover = *repoCfgPtr.Autodiscover - } + if repoCfgPtr.Autodiscover != nil { + autodiscover = *repoCfgPtr.Autodiscover + } else { + autodiscover = valid.Autodiscover{Enabled: true} + } if repoCfgPtr.ParallelApply != nil { parallelApply = *repoCfgPtr.ParallelApply } diff --git a/server/events/project_command_builder_internal_test.go b/server/events/project_command_builder_internal_test.go index c8fbfd0968..18ee0f9890 100644 --- a/server/events/project_command_builder_internal_test.go +++ b/server/events/project_command_builder_internal_test.go @@ -525,6 +525,8 @@ workflows: repoCfg: ` version: 3 automerge: true +autodiscover: + enabled: true projects: - dir: project1 workspace: myworkspace @@ -676,6 +678,7 @@ projects: false, false, false, + valid.Autodiscover{Enabled: true}, false, false, "", @@ -892,6 +895,7 @@ projects: false, true, false, + valid.Autodiscover{Enabled: true}, false, false, "", @@ -1145,6 +1149,7 @@ workflows: false, false, false, + valid.Autodiscover{Enabled: true}, false, false, "", @@ -1301,6 +1306,7 @@ projects: false, false, false, + valid.Autodiscover{Enabled: true}, false, false, "", diff --git a/server/events/project_command_builder_test.go b/server/events/project_command_builder_test.go index 8236ed0b91..57d519a8b4 100644 --- a/server/events/project_command_builder_test.go +++ b/server/events/project_command_builder_test.go @@ -26,6 +26,7 @@ var defaultUserConfig = struct { SkipCloneNoChanges bool EnableRegExpCmd bool EnableAutoMerge bool + EnableAutoDiscover valid.Autodiscover EnableParallelPlan bool EnableParallelApply bool AutoDetectModuleFiles string @@ -187,6 +188,7 @@ projects: userConfig.SkipCloneNoChanges, userConfig.EnableRegExpCmd, userConfig.EnableAutoMerge, + userConfig.EnableAutoDiscover, userConfig.EnableParallelPlan, userConfig.EnableParallelApply, userConfig.AutoDetectModuleFiles, @@ -232,6 +234,7 @@ func TestDefaultProjectCommandBuilder_BuildSinglePlanApplyCommand(t *testing.T) ExpErr string ExpApplyReqs []string EnableAutoMergeUserCfg bool + EnableAutoDiscoverUserCfg valid.Autodiscover EnableParallelPlanUserCfg bool EnableParallelApplyUserCfg bool ExpAutoMerge bool @@ -543,6 +546,7 @@ projects: userConfig.SkipCloneNoChanges, userConfig.EnableRegExpCmd, c.EnableAutoMergeUserCfg, + c.EnableAutoDiscoverUserCfg, c.EnableParallelPlanUserCfg, c.EnableParallelApplyUserCfg, userConfig.AutoDetectModuleFiles, @@ -732,6 +736,7 @@ projects: userConfig.SkipCloneNoChanges, userConfig.EnableRegExpCmd, userConfig.EnableAutoMerge, + userConfig.EnableAutoDiscover, userConfig.EnableParallelPlan, userConfig.EnableParallelApply, userConfig.AutoDetectModuleFiles, @@ -770,6 +775,7 @@ func TestDefaultProjectCommandBuilder_BuildPlanCommands(t *testing.T) { RepoRelDir string Workspace string Automerge bool + Autodiscover valid.Autodiscover ExpParallelPlan bool ExpParallelApply bool } @@ -925,7 +931,7 @@ parallel_apply: false AtlantisYAML: ` version: 3 automerge: true -autodiscover: +autodiscover: enabled: true parallel_plan: true parallel_apply: true @@ -933,20 +939,22 @@ parallel_apply: true ModifiedFiles: []string{"project1/main.tf", "project2/main.tf"}, Exp: []expCtxFields{ { - ProjectName: "", - RepoRelDir: "project1", - Workspace: "default", - Automerge: true, - ParallelApplyEnabled: true, - ParallelPlanEnabled: true, + ProjectName: "", + RepoRelDir: "project1", + Workspace: "default", + Automerge: true, + Autodiscover: valid.Autodiscover{Enabled: true}, + ExpParallelApply: true, + ExpParallelPlan: true, }, { - ProjectName: "", - RepoRelDir: "project2", - Workspace: "default", - Automerge: true, - ParallelApplyEnabled: true, - ParallelPlanEnabled: true, + ProjectName: "", + RepoRelDir: "project2", + Workspace: "default", + Automerge: true, + Autodiscover: valid.Autodiscover{Enabled: true}, + ExpParallelApply: true, + ExpParallelPlan: true, }, }, }, @@ -957,7 +965,7 @@ parallel_apply: true AtlantisYAML: ` version: 3 automerge: true -autodiscover: +autodiscover: enabled: false parallel_plan: true parallel_apply: true @@ -1052,6 +1060,7 @@ projects: userConfig.SkipCloneNoChanges, userConfig.EnableRegExpCmd, userConfig.EnableAutoMerge, + userConfig.EnableAutoDiscover, c.ParallelPlanEnabledUserCfg, c.ParallelApplyEnabledUserCfg, userConfig.AutoDetectModuleFiles, @@ -1156,6 +1165,7 @@ func TestDefaultProjectCommandBuilder_BuildMultiApply(t *testing.T) { userConfig.SkipCloneNoChanges, userConfig.EnableRegExpCmd, userConfig.EnableAutoMerge, + userConfig.EnableAutoDiscover, userConfig.EnableParallelPlan, userConfig.EnableParallelApply, userConfig.AutoDetectModuleFiles, @@ -1251,6 +1261,7 @@ projects: userConfig.SkipCloneNoChanges, userConfig.EnableRegExpCmd, userConfig.EnableAutoMerge, + userConfig.EnableAutoDiscover, userConfig.EnableParallelPlan, userConfig.EnableParallelApply, userConfig.AutoDetectModuleFiles, @@ -1341,6 +1352,7 @@ func TestDefaultProjectCommandBuilder_EscapeArgs(t *testing.T) { userConfig.SkipCloneNoChanges, userConfig.EnableRegExpCmd, userConfig.EnableAutoMerge, + userConfig.EnableAutoDiscover, userConfig.EnableParallelPlan, userConfig.EnableParallelApply, userConfig.AutoDetectModuleFiles, @@ -1512,6 +1524,7 @@ projects: userConfig.SkipCloneNoChanges, userConfig.EnableRegExpCmd, userConfig.EnableAutoMerge, + userConfig.EnableAutoDiscover, userConfig.EnableParallelPlan, userConfig.EnableParallelApply, userConfig.AutoDetectModuleFiles, @@ -1613,6 +1626,7 @@ parallel_plan: true`, userConfig.SkipCloneNoChanges, userConfig.EnableRegExpCmd, userConfig.EnableAutoMerge, + userConfig.EnableAutoDiscover, userConfig.EnableParallelPlan, userConfig.EnableParallelApply, userConfig.AutoDetectModuleFiles, @@ -1683,6 +1697,7 @@ func TestDefaultProjectCommandBuilder_WithPolicyCheckEnabled_BuildAutoplanComman userConfig.SkipCloneNoChanges, userConfig.EnableRegExpCmd, userConfig.EnableAutoMerge, + userConfig.EnableAutoDiscover, userConfig.EnableParallelPlan, userConfig.EnableParallelApply, userConfig.AutoDetectModuleFiles, @@ -1775,6 +1790,7 @@ func TestDefaultProjectCommandBuilder_BuildVersionCommand(t *testing.T) { userConfig.SkipCloneNoChanges, userConfig.EnableRegExpCmd, userConfig.EnableAutoMerge, + userConfig.EnableAutoDiscover, userConfig.EnableParallelPlan, userConfig.EnableParallelApply, userConfig.AutoDetectModuleFiles, @@ -1906,6 +1922,7 @@ func TestDefaultProjectCommandBuilder_BuildPlanCommands_Single_With_RestrictFile userConfig.SkipCloneNoChanges, userConfig.EnableRegExpCmd, userConfig.EnableAutoMerge, + userConfig.EnableAutoDiscover, userConfig.EnableParallelPlan, userConfig.EnableParallelApply, userConfig.AutoDetectModuleFiles, @@ -2017,6 +2034,7 @@ func TestDefaultProjectCommandBuilder_BuildPlanCommands_with_IncludeGitUntracked userConfig.SkipCloneNoChanges, userConfig.EnableRegExpCmd, userConfig.EnableAutoMerge, + userConfig.EnableAutoDiscover, userConfig.EnableParallelPlan, userConfig.EnableParallelApply, userConfig.AutoDetectModuleFiles, diff --git a/server/server.go b/server/server.go index 6f80cb420f..bb62c6e261 100644 --- a/server/server.go +++ b/server/server.go @@ -590,6 +590,7 @@ func NewServer(userConfig UserConfig, config Config) (*Server, error) { userConfig.SkipCloneNoChanges, userConfig.EnableRegExpCmd, userConfig.Automerge, + userConfig.Autodiscover, userConfig.ParallelPlan, userConfig.ParallelApply, userConfig.AutoplanModulesFromProjects, diff --git a/server/user_config.go b/server/user_config.go index 49e3ed6fba..2c69b9abed 100644 --- a/server/user_config.go +++ b/server/user_config.go @@ -3,6 +3,7 @@ package server import ( "strings" + "github.com/runatlantis/atlantis/server/core/config/valid" "github.com/runatlantis/atlantis/server/events/command" "github.com/runatlantis/atlantis/server/logging" ) @@ -11,39 +12,40 @@ import ( // The mapstructure tags correspond to flags in cmd/server.go and are used when // the config is parsed from a YAML file. type UserConfig struct { - AllowForkPRs bool `mapstructure:"allow-fork-prs"` - AllowRepoConfig bool `mapstructure:"allow-repo-config"` - AllowCommands string `mapstructure:"allow-commands"` - AtlantisURL string `mapstructure:"atlantis-url"` - Automerge bool `mapstructure:"automerge"` - AutoplanFileList string `mapstructure:"autoplan-file-list"` - AutoplanModules bool `mapstructure:"autoplan-modules"` - AutoplanModulesFromProjects string `mapstructure:"autoplan-modules-from-projects"` - AzureDevopsToken string `mapstructure:"azuredevops-token"` - AzureDevopsUser string `mapstructure:"azuredevops-user"` - AzureDevopsWebhookPassword string `mapstructure:"azuredevops-webhook-password"` - AzureDevopsWebhookUser string `mapstructure:"azuredevops-webhook-user"` - AzureDevOpsHostname string `mapstructure:"azuredevops-hostname"` - BitbucketBaseURL string `mapstructure:"bitbucket-base-url"` - BitbucketToken string `mapstructure:"bitbucket-token"` - BitbucketUser string `mapstructure:"bitbucket-user"` - BitbucketWebhookSecret string `mapstructure:"bitbucket-webhook-secret"` - CheckoutDepth int `mapstructure:"checkout-depth"` - CheckoutStrategy string `mapstructure:"checkout-strategy"` - DataDir string `mapstructure:"data-dir"` - DisableApplyAll bool `mapstructure:"disable-apply-all"` - DisableApply bool `mapstructure:"disable-apply"` - DisableAutoplan bool `mapstructure:"disable-autoplan"` - DisableAutoplanLabel string `mapstructure:"disable-autoplan-label"` - DisableMarkdownFolding bool `mapstructure:"disable-markdown-folding"` - DisableRepoLocking bool `mapstructure:"disable-repo-locking"` - DisableUnlockLabel string `mapstructure:"disable-unlock-label"` - DiscardApprovalOnPlanFlag bool `mapstructure:"discard-approval-on-plan"` - EmojiReaction string `mapstructure:"emoji-reaction"` - EnablePolicyChecksFlag bool `mapstructure:"enable-policy-checks"` - EnableRegExpCmd bool `mapstructure:"enable-regexp-cmd"` - EnableDiffMarkdownFormat bool `mapstructure:"enable-diff-markdown-format"` - ExecutableName string `mapstructure:"executable-name"` + AllowForkPRs bool `mapstructure:"allow-fork-prs"` + AllowRepoConfig bool `mapstructure:"allow-repo-config"` + AllowCommands string `mapstructure:"allow-commands"` + AtlantisURL string `mapstructure:"atlantis-url"` + Automerge bool `mapstructure:"automerge"` + Autodiscover valid.Autodiscover `mapstructure:"autodiscover"` + AutoplanFileList string `mapstructure:"autoplan-file-list"` + AutoplanModules bool `mapstructure:"autoplan-modules"` + AutoplanModulesFromProjects string `mapstructure:"autoplan-modules-from-projects"` + AzureDevopsToken string `mapstructure:"azuredevops-token"` + AzureDevopsUser string `mapstructure:"azuredevops-user"` + AzureDevopsWebhookPassword string `mapstructure:"azuredevops-webhook-password"` + AzureDevopsWebhookUser string `mapstructure:"azuredevops-webhook-user"` + AzureDevOpsHostname string `mapstructure:"azuredevops-hostname"` + BitbucketBaseURL string `mapstructure:"bitbucket-base-url"` + BitbucketToken string `mapstructure:"bitbucket-token"` + BitbucketUser string `mapstructure:"bitbucket-user"` + BitbucketWebhookSecret string `mapstructure:"bitbucket-webhook-secret"` + CheckoutDepth int `mapstructure:"checkout-depth"` + CheckoutStrategy string `mapstructure:"checkout-strategy"` + DataDir string `mapstructure:"data-dir"` + DisableApplyAll bool `mapstructure:"disable-apply-all"` + DisableApply bool `mapstructure:"disable-apply"` + DisableAutoplan bool `mapstructure:"disable-autoplan"` + DisableAutoplanLabel string `mapstructure:"disable-autoplan-label"` + DisableMarkdownFolding bool `mapstructure:"disable-markdown-folding"` + DisableRepoLocking bool `mapstructure:"disable-repo-locking"` + DisableUnlockLabel string `mapstructure:"disable-unlock-label"` + DiscardApprovalOnPlanFlag bool `mapstructure:"discard-approval-on-plan"` + EmojiReaction string `mapstructure:"emoji-reaction"` + EnablePolicyChecksFlag bool `mapstructure:"enable-policy-checks"` + EnableRegExpCmd bool `mapstructure:"enable-regexp-cmd"` + EnableDiffMarkdownFormat bool `mapstructure:"enable-diff-markdown-format"` + ExecutableName string `mapstructure:"executable-name"` // Fail and do not run the Atlantis command request if any of the pre workflow hooks error. FailOnPreWorkflowHookError bool `mapstructure:"fail-on-pre-workflow-hook-error"` HideUnchangedPlanComments bool `mapstructure:"hide-unchanged-plan-comments"`