@@ -36,6 +36,21 @@ type Lock interface {
3636 GetLock (resource string ) (* int , error )
3737}
3838
39+ type NoOpLock struct {
40+ }
41+
42+ func (noOpLock * NoOpLock ) Lock (transactionId int , resource string ) (bool , error ) {
43+ return true , nil
44+ }
45+
46+ func (noOpLock * NoOpLock ) Unlock (resource string ) (bool , error ) {
47+ return true , nil
48+ }
49+
50+ func (noOpLock * NoOpLock ) GetLock (resource string ) (* int , error ) {
51+ return nil , nil
52+ }
53+
3954type ProjectLock interface {
4055 Lock (prNumber int ) (bool , error )
4156 Unlock (prNumber int ) (bool , error )
@@ -77,7 +92,9 @@ func (projectLock *ProjectLockImpl) Lock(prNumber int) (bool, error) {
7792 return false , err
7893 }
7994
80- if lockAcquired {
95+ _ , isNoOpLock := projectLock .InternalLock .(* NoOpLock )
96+
97+ if lockAcquired && ! isNoOpLock {
8198 comment := "Project " + projectLock .projectId () + " has been locked by PR #" + strconv .Itoa (prNumber )
8299 projectLock .CIService .PublishComment (prNumber , comment )
83100 println ("project " + projectLock .projectId () + " locked successfully. PR # " + strconv .Itoa (prNumber ))
@@ -178,6 +195,11 @@ func GetLock() (Lock, error) {
178195 awsRegion := strings .ToLower (os .Getenv ("AWS_REGION" ))
179196 awsProfile := strings .ToLower (os .Getenv ("AWS_PROFILE" ))
180197 lockProvider := strings .ToLower (os .Getenv ("LOCK_PROVIDER" ))
198+ disableLocking := strings .ToLower (os .Getenv ("DISABLE_LOCKING" )) == "true"
199+ if disableLocking {
200+ log .Println ("Using NoOp lock provider." )
201+ return & NoOpLock {}, nil
202+ }
181203 if lockProvider == "" || lockProvider == "aws" {
182204 log .Println ("Using AWS lock provider." )
183205 sess , err := session .NewSessionWithOptions (session.Options {
0 commit comments