From cf7722c67b046113e2c3fbef37bbe2a3887aa003 Mon Sep 17 00:00:00 2001 From: chroju Date: Wed, 2 Aug 2023 19:47:14 +0900 Subject: [PATCH] feat: set apply status to successful by default when result is 'No Changes' --- cmd/server.go | 21 +- runatlantis.io/docs/server-configuration.md | 10 - .../events/events_controller_e2e_test.go | 2 - server/events/apply_command_runner.go | 10 +- server/events/command_runner_internal_test.go | 38 +-- server/events/command_runner_test.go | 20 +- server/events/plan_command_runner.go | 15 +- server/events/plan_command_runner_test.go | 238 ++++++++++++++---- server/server.go | 2 - server/user_config.go | 41 ++- 10 files changed, 238 insertions(+), 159 deletions(-) diff --git a/cmd/server.go b/cmd/server.go index a4899279e2..869d46f3f2 100644 --- a/cmd/server.go +++ b/cmd/server.go @@ -115,15 +115,14 @@ const ( RepoConfigFlag = "repo-config" RepoConfigJSONFlag = "repo-config-json" // RepoWhitelistFlag is deprecated for RepoAllowlistFlag. - RepoWhitelistFlag = "repo-whitelist" - RepoAllowlistFlag = "repo-allowlist" - RequireApprovalFlag = "require-approval" - RequireMergeableFlag = "require-mergeable" - SetAtlantisApplyCheckSuccessfulIfNoChanges = "set-atlantis-apply-check-successful-if-no-changes" - SilenceNoProjectsFlag = "silence-no-projects" - SilenceForkPRErrorsFlag = "silence-fork-pr-errors" - SilenceVCSStatusNoPlans = "silence-vcs-status-no-plans" - SilenceAllowlistErrorsFlag = "silence-allowlist-errors" + RepoWhitelistFlag = "repo-whitelist" + RepoAllowlistFlag = "repo-allowlist" + RequireApprovalFlag = "require-approval" + RequireMergeableFlag = "require-mergeable" + SilenceNoProjectsFlag = "silence-no-projects" + SilenceForkPRErrorsFlag = "silence-fork-pr-errors" + SilenceVCSStatusNoPlans = "silence-vcs-status-no-plans" + SilenceAllowlistErrorsFlag = "silence-allowlist-errors" // SilenceWhitelistErrorsFlag is deprecated for SilenceAllowlistErrorsFlag. SilenceWhitelistErrorsFlag = "silence-whitelist-errors" SkipCloneNoChanges = "skip-clone-no-changes" @@ -501,10 +500,6 @@ var boolFlags = map[string]boolFlag{ defaultValue: false, hidden: true, }, - SetAtlantisApplyCheckSuccessfulIfNoChanges: { - description: "Set the `atlantis/apply` pull request status check to \"passing\" if \"No Changes\" are detected.", - defaultValue: false, - }, SilenceNoProjectsFlag: { description: "Silences Atlants from responding to PRs when it finds no projects.", defaultValue: false, diff --git a/runatlantis.io/docs/server-configuration.md b/runatlantis.io/docs/server-configuration.md index 505e2654c9..bca4e04da4 100644 --- a/runatlantis.io/docs/server-configuration.md +++ b/runatlantis.io/docs/server-configuration.md @@ -830,16 +830,6 @@ This is useful when you have many projects and want to keep the pull request cle * Allowlist all repositories * `--repo-allowlist='*'` -### `--set-atlantis-apply-check-successful-if-no-changes` - ```bash - atlantis server --set-atlantis-apply-check-successful-if-no-changes - # or - ATLANTIS_SET_ATLANTIS_APPLY_CHECK_SUCCESSFUL_IF_NO_CHANGES=true - ``` - `--set-atlantis-apply-check-successful-if-no-changes` will set the `atlantis/apply` status check to "passing" on a VCS pull request if the `atlantis plan` command results in "No Changes". - This is useful, for example, when enabling auto-merge for pull requests that do not involve resource changes, such as automatic dependency updates. - Defaults to `false`. - ### `--silence-fork-pr-errors` ```bash atlantis server --silence-fork-pr-errors diff --git a/server/controllers/events/events_controller_e2e_test.go b/server/controllers/events/events_controller_e2e_test.go index 03c69b9c2d..b02af1d06a 100644 --- a/server/controllers/events/events_controller_e2e_test.go +++ b/server/controllers/events/events_controller_e2e_test.go @@ -1425,7 +1425,6 @@ func setupE2E(t *testing.T, repoDir string, opt setupOption) (events_controllers lockingClient, discardApprovalOnPlan, e2ePullReqStatusFetcher, - false, ) applyCommandRunner := events.NewApplyCommandRunner( @@ -1443,7 +1442,6 @@ func setupE2E(t *testing.T, repoDir string, opt setupOption) (events_controllers silenceNoProjects, false, e2ePullReqStatusFetcher, - false, ) approvePoliciesCommandRunner := events.NewApprovePoliciesCommandRunner( diff --git a/server/events/apply_command_runner.go b/server/events/apply_command_runner.go index 4d8e0cfe44..06439aff01 100644 --- a/server/events/apply_command_runner.go +++ b/server/events/apply_command_runner.go @@ -22,7 +22,6 @@ func NewApplyCommandRunner( SilenceNoProjects bool, silenceVCSStatusNoProjects bool, pullReqStatusFetcher vcs.PullReqStatusFetcher, - SetAtlantisApplyCheckSuccessfulIfNoChanges bool, ) *ApplyCommandRunner { return &ApplyCommandRunner{ vcsClient: vcsClient, @@ -39,7 +38,6 @@ func NewApplyCommandRunner( SilenceNoProjects: SilenceNoProjects, silenceVCSStatusNoProjects: silenceVCSStatusNoProjects, pullReqStatusFetcher: pullReqStatusFetcher, - SetAtlantisApplyCheckSuccessfulIfNoChanges: SetAtlantisApplyCheckSuccessfulIfNoChanges, } } @@ -61,8 +59,7 @@ type ApplyCommandRunner struct { SilenceNoProjects bool // SilenceVCSStatusNoPlans is whether any plan should set commit status if no projects // are found - silenceVCSStatusNoProjects bool - SetAtlantisApplyCheckSuccessfulIfNoChanges bool + silenceVCSStatusNoProjects bool } func (a *ApplyCommandRunner) Run(ctx *command.Context, cmd *CommentCommand) { @@ -202,10 +199,7 @@ func (a *ApplyCommandRunner) updateCommitStatus(ctx *command.Context, pullStatus var numErrored int status := models.SuccessCommitStatus - numSuccess = pullStatus.StatusCount(models.AppliedPlanStatus) - if a.SetAtlantisApplyCheckSuccessfulIfNoChanges { - numSuccess += pullStatus.StatusCount(models.PlannedNoChangesPlanStatus) - } + numSuccess = pullStatus.StatusCount(models.AppliedPlanStatus) + pullStatus.StatusCount(models.PlannedNoChangesPlanStatus) numErrored = pullStatus.StatusCount(models.ErroredApplyStatus) if numErrored > 0 { diff --git a/server/events/command_runner_internal_test.go b/server/events/command_runner_internal_test.go index 8726ba7217..4cf3076a0f 100644 --- a/server/events/command_runner_internal_test.go +++ b/server/events/command_runner_internal_test.go @@ -10,16 +10,14 @@ import ( func TestApplyUpdateCommitStatus(t *testing.T) { cases := map[string]struct { - cmd command.Name - SetAtlantisApplyCheckSuccessfulIfNoChanges bool - pullStatus models.PullStatus - expStatus models.CommitStatus - expNumSuccess int - expNumTotal int + cmd command.Name + pullStatus models.PullStatus + expStatus models.CommitStatus + expNumSuccess int + expNumTotal int }{ "apply, one pending": { cmd: command.Apply, - SetAtlantisApplyCheckSuccessfulIfNoChanges: false, pullStatus: models.PullStatus{ Projects: []models.ProjectStatus{ { @@ -36,7 +34,6 @@ func TestApplyUpdateCommitStatus(t *testing.T) { }, "apply, all successful": { cmd: command.Apply, - SetAtlantisApplyCheckSuccessfulIfNoChanges: false, pullStatus: models.PullStatus{ Projects: []models.ProjectStatus{ { @@ -53,7 +50,6 @@ func TestApplyUpdateCommitStatus(t *testing.T) { }, "apply, one errored, one pending": { cmd: command.Apply, - SetAtlantisApplyCheckSuccessfulIfNoChanges: false, pullStatus: models.PullStatus{ Projects: []models.ProjectStatus{ { @@ -73,24 +69,6 @@ func TestApplyUpdateCommitStatus(t *testing.T) { }, "apply, one planned no changes": { cmd: command.Apply, - SetAtlantisApplyCheckSuccessfulIfNoChanges: false, - pullStatus: models.PullStatus{ - Projects: []models.ProjectStatus{ - { - Status: models.AppliedPlanStatus, - }, - { - Status: models.PlannedNoChangesPlanStatus, - }, - }, - }, - expStatus: models.PendingCommitStatus, - expNumSuccess: 1, - expNumTotal: 2, - }, - "apply, one planned no changes, skip apply when no changes": { - cmd: command.Apply, - SetAtlantisApplyCheckSuccessfulIfNoChanges: true, pullStatus: models.PullStatus{ Projects: []models.ProjectStatus{ { @@ -111,8 +89,7 @@ func TestApplyUpdateCommitStatus(t *testing.T) { t.Run(name, func(t *testing.T) { csu := &MockCSU{} cr := &ApplyCommandRunner{ - commitStatusUpdater: csu, - SetAtlantisApplyCheckSuccessfulIfNoChanges: c.SetAtlantisApplyCheckSuccessfulIfNoChanges, + commitStatusUpdater: csu, } cr.updateCommitStatus(&command.Context{}, c.pullStatus) Equals(t, models.Repo{}, csu.CalledRepo) @@ -271,8 +248,7 @@ func TestPlanUpdateApplyCommitStatus(t *testing.T) { t.Run(name, func(t *testing.T) { csu := &MockCSU{} cr := &PlanCommandRunner{ - commitStatusUpdater: csu, - SetAtlantisApplyCheckSuccessfulIfNoChanges: true, + commitStatusUpdater: csu, } cr.updateCommitStatus(&command.Context{}, c.pullStatus, command.Apply) Equals(t, models.Repo{}, csu.CalledRepo) diff --git a/server/events/command_runner_test.go b/server/events/command_runner_test.go index 45e42d94db..3b652d73db 100644 --- a/server/events/command_runner_test.go +++ b/server/events/command_runner_test.go @@ -70,14 +70,13 @@ var preWorkflowHooksCommandRunner events.PreWorkflowHooksCommandRunner var postWorkflowHooksCommandRunner events.PostWorkflowHooksCommandRunner type TestConfig struct { - parallelPoolSize int - SilenceNoProjects bool - silenceVCSStatusNoPlans bool - silenceVCSStatusNoProjects bool - StatusName string - discardApprovalOnPlan bool - SetAtlantisApplyCheckSuccessfulIfNoChanges bool - backend locking.Backend + parallelPoolSize int + SilenceNoProjects bool + silenceVCSStatusNoPlans bool + silenceVCSStatusNoProjects bool + StatusName string + discardApprovalOnPlan bool + backend locking.Backend } func setup(t *testing.T, options ...func(testConfig *TestConfig)) *vcsmocks.MockClient { @@ -93,8 +92,7 @@ func setup(t *testing.T, options ...func(testConfig *TestConfig)) *vcsmocks.Mock SilenceNoProjects: false, StatusName: "atlantis-test", discardApprovalOnPlan: false, - SetAtlantisApplyCheckSuccessfulIfNoChanges: false, - backend: defaultBoltDB, + backend: defaultBoltDB, } for _, op := range options { @@ -163,7 +161,6 @@ func setup(t *testing.T, options ...func(testConfig *TestConfig)) *vcsmocks.Mock lockingLocker, testConfig.discardApprovalOnPlan, pullReqStatusFetcher, - testConfig.SetAtlantisApplyCheckSuccessfulIfNoChanges, ) applyCommandRunner = events.NewApplyCommandRunner( @@ -181,7 +178,6 @@ func setup(t *testing.T, options ...func(testConfig *TestConfig)) *vcsmocks.Mock testConfig.SilenceNoProjects, testConfig.silenceVCSStatusNoProjects, pullReqStatusFetcher, - testConfig.SetAtlantisApplyCheckSuccessfulIfNoChanges, ) approvePoliciesCommandRunner = events.NewApprovePoliciesCommandRunner( diff --git a/server/events/plan_command_runner.go b/server/events/plan_command_runner.go index 65f64aecd1..9313f14d4c 100644 --- a/server/events/plan_command_runner.go +++ b/server/events/plan_command_runner.go @@ -26,7 +26,6 @@ func NewPlanCommandRunner( lockingLocker locking.Locker, discardApprovalOnPlan bool, pullReqStatusFetcher vcs.PullReqStatusFetcher, - SetAtlantisApplyCheckSuccessfulIfNoChanges bool, ) *PlanCommandRunner { return &PlanCommandRunner{ silenceVCSStatusNoPlans: silenceVCSStatusNoPlans, @@ -47,7 +46,6 @@ func NewPlanCommandRunner( lockingLocker: lockingLocker, DiscardApprovalOnPlan: discardApprovalOnPlan, pullReqStatusFetcher: pullReqStatusFetcher, - SetAtlantisApplyCheckSuccessfulIfNoChanges: SetAtlantisApplyCheckSuccessfulIfNoChanges, } } @@ -76,9 +74,8 @@ type PlanCommandRunner struct { lockingLocker locking.Locker // DiscardApprovalOnPlan controls if all already existing approvals should be removed/dismissed before executing // a plan. - DiscardApprovalOnPlan bool - pullReqStatusFetcher vcs.PullReqStatusFetcher - SetAtlantisApplyCheckSuccessfulIfNoChanges bool + DiscardApprovalOnPlan bool + pullReqStatusFetcher vcs.PullReqStatusFetcher } func (p *PlanCommandRunner) runAutoplan(ctx *command.Context) { @@ -152,9 +149,7 @@ func (p *PlanCommandRunner) runAutoplan(ctx *command.Context) { } p.updateCommitStatus(ctx, pullStatus, command.Plan) - if p.SetAtlantisApplyCheckSuccessfulIfNoChanges { - p.updateCommitStatus(ctx, pullStatus, command.Apply) - } + p.updateCommitStatus(ctx, pullStatus, command.Apply) // Check if there are any planned projects and if there are any errors or if plans are being deleted if len(policyCheckCmds) > 0 && @@ -279,9 +274,7 @@ func (p *PlanCommandRunner) run(ctx *command.Context, cmd *CommentCommand) { } p.updateCommitStatus(ctx, pullStatus, command.Plan) - if p.SetAtlantisApplyCheckSuccessfulIfNoChanges { - p.updateCommitStatus(ctx, pullStatus, command.Apply) - } + p.updateCommitStatus(ctx, pullStatus, command.Apply) // Runs policy checks step after all plans are successful. // This step does not approve any policies that require approval. diff --git a/server/events/plan_command_runner_test.go b/server/events/plan_command_runner_test.go index 6d85493abf..e388ef2499 100644 --- a/server/events/plan_command_runner_test.go +++ b/server/events/plan_command_runner_test.go @@ -152,7 +152,6 @@ func TestPlanCommandRunner_IsSilenced(t *testing.T) { } } - func TestPlanCommandRunner_ExecutionOrder(t *testing.T) { logger := logging.NewNoopLogger(t) RegisterMockTestingT(t) @@ -510,41 +509,190 @@ func TestPlanCommandRunner_ExecutionOrder(t *testing.T) { } } -func TestPlanCommandRunner_IsSetAtlantisApplyStatus(t *testing.T) { +func TestPlanCommandRunner_AtlantisApplyStatus(t *testing.T) { logger := logging.NewNoopLogger(t) RegisterMockTestingT(t) cases := []struct { - Description string - PrevPlanStored bool - SetAtlantisApplyCheckSuccessfulIfNoChanges bool - ExpVCSApplyStatusSet bool - ExpVCSApplyStatusTotal int - ExpVCSApplyStatusSucc int + Description string + ProjectContexts []command.ProjectContext + ProjectResults []command.ProjectResult + PrevPlanStored bool // stores a previous "No changes" plan in the backend + ExpVCSApplyStatusTotal int + ExpVCSApplyStatusSucc int }{ { - Description: "When planning without the flag, don't set the atlantis/apply VCS status", + Description: "When planning with changes, set the 0/1 apply status", + ProjectContexts: []command.ProjectContext{ + { + CommandName: command.Plan, + RepoRelDir: "mydir", + }, + }, + ProjectResults: []command.ProjectResult{ + { + RepoRelDir: "mydir", + Command: command.Plan, + PlanSuccess: &models.PlanSuccess{ + TerraformOutput: "Plan: 0 to add, 0 to change, 1 to destroy.", + }, + }, + }, + ExpVCSApplyStatusTotal: 1, + ExpVCSApplyStatusSucc: 0, }, { - Description: "When planning with the flag, set the atlantis/apply VCS status to 0/0", - SetAtlantisApplyCheckSuccessfulIfNoChanges: true, - ExpVCSApplyStatusSet: true, - ExpVCSApplyStatusTotal: 0, - ExpVCSApplyStatusSucc: 0, + Description: "When planning with no changes, set the 1/1 apply status", + ProjectContexts: []command.ProjectContext{ + { + CommandName: command.Plan, + RepoRelDir: "mydir", + }, + }, + ProjectResults: []command.ProjectResult{ + { + RepoRelDir: "mydir", + Command: command.Plan, + PlanSuccess: &models.PlanSuccess{ + TerraformOutput: "No changes. Infrastructure is up-to-date.", + }, + }, + }, + ExpVCSApplyStatusTotal: 1, + ExpVCSApplyStatusSucc: 1, + }, + { + Description: "When planning with no changes and previous plan with no changes, set the 1/2 apply status", + ProjectContexts: []command.ProjectContext{ + { + CommandName: command.Plan, + RepoRelDir: "mydir", + }, + }, + ProjectResults: []command.ProjectResult{ + { + RepoRelDir: "mydir", + Command: command.Plan, + PlanSuccess: &models.PlanSuccess{ + TerraformOutput: "Plan: 0 to add, 0 to change, 1 to destroy.", + }, + }, + }, + PrevPlanStored: true, + ExpVCSApplyStatusTotal: 2, + ExpVCSApplyStatusSucc: 1, }, { - Description: "When planning with the previous plan that results in No Changes and without the flag, don't set the atlantis/apply VCS status", - PrevPlanStored: true, - SetAtlantisApplyCheckSuccessfulIfNoChanges: false, - ExpVCSApplyStatusSet: false, + Description: "When planning with no changes and previous 'No changes' plan, set the 2/2 apply status", + ProjectContexts: []command.ProjectContext{ + { + CommandName: command.Plan, + RepoRelDir: "mydir", + }, + }, + ProjectResults: []command.ProjectResult{ + { + RepoRelDir: "mydir", + Command: command.Plan, + PlanSuccess: &models.PlanSuccess{ + TerraformOutput: "No changes. Infrastructure is up-to-date.", + }, + }, + }, + PrevPlanStored: true, + ExpVCSApplyStatusTotal: 2, + ExpVCSApplyStatusSucc: 2, }, { - Description: "When planning with the previous plan that results in No Changes and setting the flag, set the atlantis/apply VCS status to 1/1", - PrevPlanStored: true, - SetAtlantisApplyCheckSuccessfulIfNoChanges: true, - ExpVCSApplyStatusSet: true, - ExpVCSApplyStatusTotal: 1, - ExpVCSApplyStatusSucc: 1, + Description: "When planning again with changes following a previous 'No changes' plan, set the 0/1 apply status", + ProjectContexts: []command.ProjectContext{ + { + CommandName: command.Plan, + RepoRelDir: "prevdir", + Workspace: "default", + }, + }, + ProjectResults: []command.ProjectResult{ + { + RepoRelDir: "prevdir", + Workspace: "default", + Command: command.Plan, + PlanSuccess: &models.PlanSuccess{ + TerraformOutput: "Plan: 0 to add, 0 to change, 1 to destroy.", + }, + }, + }, + PrevPlanStored: true, + ExpVCSApplyStatusTotal: 1, + ExpVCSApplyStatusSucc: 0, + }, + { + Description: "When planning again with changes following a previous 'No changes' plan, while another plan with 'No changes', set the 1/2 apply status.", + ProjectContexts: []command.ProjectContext{ + { + CommandName: command.Plan, + RepoRelDir: "prevdir", + Workspace: "default", + }, + { + CommandName: command.Plan, + RepoRelDir: "mydir", + }, + }, + ProjectResults: []command.ProjectResult{ + { + RepoRelDir: "prevdir", + Workspace: "default", + Command: command.Plan, + PlanSuccess: &models.PlanSuccess{ + TerraformOutput: "Plan: 0 to add, 0 to change, 1 to destroy.", + }, + }, + { + RepoRelDir: "mydir", + Command: command.Plan, + PlanSuccess: &models.PlanSuccess{ + TerraformOutput: "No changes. Infrastructure is up-to-date.", + }, + }, + }, + PrevPlanStored: true, + ExpVCSApplyStatusTotal: 2, + ExpVCSApplyStatusSucc: 1, + }, + { + Description: "When planning again with no changes following a previous 'No changes' plan, while another plan also with 'No changes', set the 2/2 apply status.", + ProjectContexts: []command.ProjectContext{ + { + CommandName: command.Plan, + RepoRelDir: "prevdir", + Workspace: "default", + }, + { + CommandName: command.Plan, + RepoRelDir: "mydir", + }, + }, + ProjectResults: []command.ProjectResult{ + { + RepoRelDir: "prevdir", + Workspace: "default", + Command: command.Plan, + PlanSuccess: &models.PlanSuccess{ + TerraformOutput: "No changes. Infrastructure is up-to-date.", + }, + }, + { + RepoRelDir: "mydir", + Command: command.Plan, + PlanSuccess: &models.PlanSuccess{ + TerraformOutput: "No changes. Infrastructure is up-to-date.", + }, + }, + }, + PrevPlanStored: true, + ExpVCSApplyStatusTotal: 2, + ExpVCSApplyStatusSucc: 2, }, } @@ -556,7 +704,6 @@ func TestPlanCommandRunner_IsSetAtlantisApplyStatus(t *testing.T) { Ok(t, err) vcsClient := setup(t, func(tc *TestConfig) { - tc.SetAtlantisApplyCheckSuccessfulIfNoChanges = c.SetAtlantisApplyCheckSuccessfulIfNoChanges tc.backend = db }) @@ -564,6 +711,7 @@ func TestPlanCommandRunner_IsSetAtlantisApplyStatus(t *testing.T) { modelPull := models.PullRequest{BaseRepo: testdata.GithubRepo, State: models.OpenPullState, Num: testdata.Pull.Num} cmd := &events.CommentCommand{Name: command.Plan} + ctx := &command.Context{ User: testdata.User, Log: logging.NewNoopLogger(t), @@ -572,6 +720,7 @@ func TestPlanCommandRunner_IsSetAtlantisApplyStatus(t *testing.T) { HeadRepo: testdata.GithubRepo, Trigger: command.CommentTrigger, } + if c.PrevPlanStored { _, err = db.UpdatePullWithResults(modelPull, []command.ProjectResult{ { @@ -586,38 +735,29 @@ func TestPlanCommandRunner_IsSetAtlantisApplyStatus(t *testing.T) { Ok(t, err) } - When(projectCommandBuilder.BuildPlanCommands(ctx, cmd)).Then(func(args []Param) ReturnValues { - return ReturnValues{[]command.ProjectContext{}, nil} - }) + When(projectCommandBuilder.BuildPlanCommands(ctx, cmd)).ThenReturn(c.ProjectContexts, nil) + + for i := range c.ProjectContexts { + When(projectCommandRunner.Plan(c.ProjectContexts[i])).ThenReturn(c.ProjectResults[i]) + } planCommandRunner.Run(ctx, cmd) - vcsClient.VerifyWasCalledOnce().CreateComment(AnyRepo(), AnyInt(), AnyString(), AnyString()) + vcsClient.VerifyWasCalledOnce().CreateComment(Any[models.Repo](), AnyInt(), AnyString(), AnyString()) ExpCommitStatus := models.SuccessCommitStatus if c.ExpVCSApplyStatusSucc != c.ExpVCSApplyStatusTotal { ExpCommitStatus = models.PendingCommitStatus } - if c.ExpVCSApplyStatusSet { - commitUpdater.VerifyWasCalledOnce().UpdateCombinedCount( - matchers.AnyModelsRepo(), - matchers.AnyModelsPullRequest(), - matchers.EqModelsCommitStatus(ExpCommitStatus), - matchers.EqCommandName(command.Apply), - EqInt(c.ExpVCSApplyStatusSucc), - EqInt(c.ExpVCSApplyStatusTotal), - ) - } else { - commitUpdater.VerifyWasCalled(Never()).UpdateCombinedCount( - matchers.AnyModelsRepo(), - matchers.AnyModelsPullRequest(), - matchers.AnyModelsCommitStatus(), - matchers.EqCommandName(command.Apply), - AnyInt(), - AnyInt(), - ) - } + commitUpdater.VerifyWasCalledOnce().UpdateCombinedCount( + Any[models.Repo](), + Any[models.PullRequest](), + Eq[models.CommitStatus](ExpCommitStatus), + Eq[command.Name](command.Apply), + Eq(c.ExpVCSApplyStatusSucc), + Eq(c.ExpVCSApplyStatusTotal), + ) }) } -} \ No newline at end of file +} diff --git a/server/server.go b/server/server.go index a14889ddd5..91aca3be87 100644 --- a/server/server.go +++ b/server/server.go @@ -706,7 +706,6 @@ func NewServer(userConfig UserConfig, config Config) (*Server, error) { lockingClient, userConfig.DiscardApprovalOnPlanFlag, pullReqStatusFetcher, - userConfig.SetAtlantisApplyCheckSuccessfulIfNoChanges, ) applyCommandRunner := events.NewApplyCommandRunner( @@ -724,7 +723,6 @@ func NewServer(userConfig UserConfig, config Config) (*Server, error) { userConfig.SilenceNoProjects, userConfig.SilenceVCSStatusNoProjects, pullReqStatusFetcher, - userConfig.SetAtlantisApplyCheckSuccessfulIfNoChanges, ) approvePoliciesCommandRunner := events.NewApprovePoliciesCommandRunner( diff --git a/server/user_config.go b/server/user_config.go index c1f5fd4369..209482049e 100644 --- a/server/user_config.go +++ b/server/user_config.go @@ -102,27 +102,26 @@ type UserConfig struct { SilenceVCSStatusNoProjects bool `mapstructure:"silence-vcs-status-no-projects"` SilenceAllowlistErrors bool `mapstructure:"silence-allowlist-errors"` // SilenceWhitelistErrors is deprecated in favour of SilenceAllowlistErrors - SilenceWhitelistErrors bool `mapstructure:"silence-whitelist-errors"` - SetAtlantisApplyCheckSuccessfulIfNoChanges bool `mapstructure:"set-atlantis-apply-check-successful-if-no-changes"` - SkipCloneNoChanges bool `mapstructure:"skip-clone-no-changes"` - SlackToken string `mapstructure:"slack-token"` - SSLCertFile string `mapstructure:"ssl-cert-file"` - SSLKeyFile string `mapstructure:"ssl-key-file"` - RestrictFileList bool `mapstructure:"restrict-file-list"` - TFDownload bool `mapstructure:"tf-download"` - TFDownloadURL string `mapstructure:"tf-download-url"` - TFEHostname string `mapstructure:"tfe-hostname"` - TFELocalExecutionMode bool `mapstructure:"tfe-local-execution-mode"` - TFEToken string `mapstructure:"tfe-token"` - VarFileAllowlist string `mapstructure:"var-file-allowlist"` - VCSStatusName string `mapstructure:"vcs-status-name"` - DefaultTFVersion string `mapstructure:"default-tf-version"` - Webhooks []WebhookConfig `mapstructure:"webhooks"` - WebBasicAuth bool `mapstructure:"web-basic-auth"` - WebUsername string `mapstructure:"web-username"` - WebPassword string `mapstructure:"web-password"` - WriteGitCreds bool `mapstructure:"write-git-creds"` - WebsocketCheckOrigin bool `mapstructure:"websocket-check-origin"` + SilenceWhitelistErrors bool `mapstructure:"silence-whitelist-errors"` + SkipCloneNoChanges bool `mapstructure:"skip-clone-no-changes"` + SlackToken string `mapstructure:"slack-token"` + SSLCertFile string `mapstructure:"ssl-cert-file"` + SSLKeyFile string `mapstructure:"ssl-key-file"` + RestrictFileList bool `mapstructure:"restrict-file-list"` + TFDownload bool `mapstructure:"tf-download"` + TFDownloadURL string `mapstructure:"tf-download-url"` + TFEHostname string `mapstructure:"tfe-hostname"` + TFELocalExecutionMode bool `mapstructure:"tfe-local-execution-mode"` + TFEToken string `mapstructure:"tfe-token"` + VarFileAllowlist string `mapstructure:"var-file-allowlist"` + VCSStatusName string `mapstructure:"vcs-status-name"` + DefaultTFVersion string `mapstructure:"default-tf-version"` + Webhooks []WebhookConfig `mapstructure:"webhooks"` + WebBasicAuth bool `mapstructure:"web-basic-auth"` + WebUsername string `mapstructure:"web-username"` + WebPassword string `mapstructure:"web-password"` + WriteGitCreds bool `mapstructure:"write-git-creds"` + WebsocketCheckOrigin bool `mapstructure:"websocket-check-origin"` } // ToAllowCommandNames parse AllowCommands into a slice of CommandName