diff --git a/cmd/server.go b/cmd/server.go index 76e96283c1..37fa486382 100644 --- a/cmd/server.go +++ b/cmd/server.go @@ -53,6 +53,7 @@ const ( DataDirFlag = "data-dir" DefaultTFVersionFlag = "default-tf-version" DisableApplyAllFlag = "disable-apply-all" + DisableAutoplanFlag = "disable-autoplan" DisableMarkdownFoldingFlag = "disable-markdown-folding" GHHostnameFlag = "gh-hostname" GHTokenFlag = "gh-token" @@ -275,6 +276,10 @@ var boolFlags = map[string]boolFlag{ description: "Disable \"atlantis apply\" command so a specific project/workspace/directory has to be specified for applies.", defaultValue: false, }, + DisableAutoplanFlag: { + description: "Disable atlantis auto planning feature", + defaultValue: false, + }, AllowDraftPRs: { description: "Enable autoplan for Github Draft Pull Requests", defaultValue: false, diff --git a/cmd/server_test.go b/cmd/server_test.go index c9ac658f9d..ea159a618f 100644 --- a/cmd/server_test.go +++ b/cmd/server_test.go @@ -95,6 +95,7 @@ var testFlags = map[string]interface{}{ TFETokenFlag: "my-token", VCSStatusName: "my-status", WriteGitCredsFlag: true, + DisableAutoplanFlag: true, } func TestExecute_Defaults(t *testing.T) { diff --git a/runatlantis.io/docs/server-configuration.md b/runatlantis.io/docs/server-configuration.md index af821bad2a..dd100aa6df 100644 --- a/runatlantis.io/docs/server-configuration.md +++ b/runatlantis.io/docs/server-configuration.md @@ -208,6 +208,12 @@ Values are chosen in this order: Disable \"atlantis apply\" command so a specific project/workspace/directory has to be specified for applies. +* ### `--disable-autoplan` + ```bash + atlantis server --disable-autoplan + ``` + Disable atlantis auto planning + * ### `--gh-hostname` ```bash atlantis server --gh-hostname="my.github.enterprise.com" diff --git a/server/events/command_runner.go b/server/events/command_runner.go index 910885267d..e0400054ed 100644 --- a/server/events/command_runner.go +++ b/server/events/command_runner.go @@ -76,6 +76,7 @@ type DefaultCommandRunner struct { GitlabMergeRequestGetter GitlabMergeRequestGetter CommitStatusUpdater CommitStatusUpdater DisableApplyAll bool + DisableAutoplan bool EventParser EventParsing MarkdownRenderer *MarkdownRenderer Logger logging.SimpleLogging @@ -130,6 +131,9 @@ func (c *DefaultCommandRunner) RunAutoplanCommand(baseRepo models.Repo, headRepo if !c.validateCtxAndComment(ctx) { return } + if c.DisableAutoplan { + return + } projectCmds, err := c.ProjectCommandBuilder.BuildAutoplanCommands(ctx) if err != nil { diff --git a/server/events/command_runner_test.go b/server/events/command_runner_test.go index be5cbc70f0..45d35fa7d9 100644 --- a/server/events/command_runner_test.go +++ b/server/events/command_runner_test.go @@ -196,6 +196,22 @@ func TestRunCommentCommand_DisableApplyAllDisabled(t *testing.T) { vcsClient.VerifyWasCalledOnce().CreateComment(fixtures.GithubRepo, modelPull.Num, "**Error:** Running `atlantis apply` without flags is disabled. You must specify which project to apply via the `-d