Skip to content
Merged
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
15 changes: 11 additions & 4 deletions cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ import (
"github.com/runatlantis/atlantis/server/logging"
)

// checkout strategies
const (
CheckoutStrategyBranch = "branch"
CheckoutStrategyMerge = "merge"
)

// To add a new flag you must:
// 1. Add a const with the flag name (in alphabetic order).
// 2. Add a new field to server.UserConfig and set the mapstructure tag equal to the flag name.
Expand Down Expand Up @@ -141,7 +147,7 @@ const (
DefaultADHostname = "dev.azure.com"
DefaultAutoplanFileList = "**/*.tf,**/*.tfvars,**/*.tfvars.json,**/terragrunt.hcl,**/.terraform.lock.hcl"
DefaultAllowCommands = "version,plan,apply,unlock,approve_policies"
DefaultCheckoutStrategy = "branch"
DefaultCheckoutStrategy = CheckoutStrategyBranch
DefaultCheckoutDepth = 0
DefaultBitbucketBaseURL = bitbucketcloud.BaseURL
DefaultDataDir = "~/.atlantis"
Expand Down Expand Up @@ -545,7 +551,7 @@ var boolFlags = map[string]boolFlag{
}
var intFlags = map[string]intFlag{
CheckoutDepthFlag: {
description: fmt.Sprintf("Used only if --%s=merge.", CheckoutStrategyFlag) +
description: fmt.Sprintf("Used only if --%s=%s.", CheckoutStrategyFlag, CheckoutStrategyMerge) +
" How many commits to include in each of base and feature branches when cloning repository." +
" If merge base is further behind than this number of commits from any of branches heads, full fetch will be performed.",
defaultValue: DefaultCheckoutDepth,
Expand Down Expand Up @@ -852,8 +858,9 @@ func (s *ServerCmd) validate(userConfig server.UserConfig) error {
}

checkoutStrategy := userConfig.CheckoutStrategy
if checkoutStrategy != "branch" && checkoutStrategy != "merge" {
return errors.New("invalid checkout strategy: not one of branch or merge")
if checkoutStrategy != CheckoutStrategyBranch && checkoutStrategy != CheckoutStrategyMerge {
return fmt.Errorf("invalid checkout strategy: not one of %s or %s",
CheckoutStrategyBranch, CheckoutStrategyMerge)
}

if (userConfig.SSLKeyFile == "") != (userConfig.SSLCertFile == "") {
Expand Down
2 changes: 1 addition & 1 deletion cmd/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ var testFlags = map[string]interface{}{
BitbucketTokenFlag: "bitbucket-token",
BitbucketUserFlag: "bitbucket-user",
BitbucketWebhookSecretFlag: "bitbucket-secret",
CheckoutStrategyFlag: "merge",
CheckoutStrategyFlag: CheckoutStrategyMerge,
DataDirFlag: "/path",
DefaultTFVersionFlag: "v0.11.0",
DisableApplyAllFlag: true,
Expand Down