@@ -33,6 +33,12 @@ import (
33
33
"github.com/runatlantis/atlantis/server/logging"
34
34
)
35
35
36
+ // checkout strategies
37
+ const (
38
+ CheckoutStrategyBranch = "branch"
39
+ CheckoutStrategyMerge = "merge"
40
+ )
41
+
36
42
// To add a new flag you must:
37
43
// 1. Add a const with the flag name (in alphabetic order).
38
44
// 2. Add a new field to server.UserConfig and set the mapstructure tag equal to the flag name.
@@ -141,7 +147,7 @@ const (
141
147
DefaultADHostname = "dev.azure.com"
142
148
DefaultAutoplanFileList = "**/*.tf,**/*.tfvars,**/*.tfvars.json,**/terragrunt.hcl,**/.terraform.lock.hcl"
143
149
DefaultAllowCommands = "version,plan,apply,unlock,approve_policies"
144
- DefaultCheckoutStrategy = "branch"
150
+ DefaultCheckoutStrategy = CheckoutStrategyBranch
145
151
DefaultCheckoutDepth = 0
146
152
DefaultBitbucketBaseURL = bitbucketcloud .BaseURL
147
153
DefaultDataDir = "~/.atlantis"
@@ -545,7 +551,7 @@ var boolFlags = map[string]boolFlag{
545
551
}
546
552
var intFlags = map [string ]intFlag {
547
553
CheckoutDepthFlag : {
548
- description : fmt .Sprintf ("Used only if --%s=merge ." , CheckoutStrategyFlag ) +
554
+ description : fmt .Sprintf ("Used only if --%s=%s ." , CheckoutStrategyFlag , CheckoutStrategyMerge ) +
549
555
" How many commits to include in each of base and feature branches when cloning repository." +
550
556
" If merge base is further behind than this number of commits from any of branches heads, full fetch will be performed." ,
551
557
defaultValue : DefaultCheckoutDepth ,
@@ -852,8 +858,9 @@ func (s *ServerCmd) validate(userConfig server.UserConfig) error {
852
858
}
853
859
854
860
checkoutStrategy := userConfig .CheckoutStrategy
855
- if checkoutStrategy != "branch" && checkoutStrategy != "merge" {
856
- return errors .New ("invalid checkout strategy: not one of branch or merge" )
861
+ if checkoutStrategy != CheckoutStrategyBranch && checkoutStrategy != CheckoutStrategyMerge {
862
+ return fmt .Errorf ("invalid checkout strategy: not one of %s or %s" ,
863
+ CheckoutStrategyBranch , CheckoutStrategyMerge )
857
864
}
858
865
859
866
if (userConfig .SSLKeyFile == "" ) != (userConfig .SSLCertFile == "" ) {
0 commit comments