Skip to content

Commit

Permalink
Orca 679 global atlantis lock new release branch (#49)
Browse files Browse the repository at this point in the history
* Adding CommandLocker to boltDB and exposing it through locker interface

* Apply lock ui and apply command lock controller

* Minor comments

* Adding more tests and refactorinng

* Linting fixes

* creating applyLockingClient variable to fix interface error

* nullsink for stats

* Addressing PR comments

* fixing e2e tests

* linting fix fml

* Update outdated function descriptions

Address PR comments

* revert stats sink changes
  • Loading branch information
msarvar committed Sep 27, 2021
1 parent b9fcca9 commit 481004f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions server/controllers/events/events_controller_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,11 @@ func TestGitHubWorkflow(t *testing.T) {
_, _ = applyLocker.LockApply()
}

// Create global apply lock if required
if c.ApplyLock {
_, _ = applyLocker.LockApply()
}

// Now send any other comments.
for _, comment := range c.Comments {
commentReq := GitHubCommentEvent(t, comment)
Expand Down
4 changes: 4 additions & 0 deletions server/events/apply_command_runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"testing"

"github.com/google/go-github/v31/github"
stats "github.com/lyft/gostats"
. "github.com/petergtz/pegomock"
"github.com/runatlantis/atlantis/server/core/locking"
"github.com/runatlantis/atlantis/server/events"
Expand Down Expand Up @@ -46,6 +47,8 @@ func TestApplyCommandRunner_IsLocked(t *testing.T) {
t.Run(c.Description, func(t *testing.T) {
vcsClient := setup(t)

scopeNull := stats.NewStore(stats.NewNullSink(), false)

pull := &github.PullRequest{
State: github.String("open"),
}
Expand All @@ -59,6 +62,7 @@ func TestApplyCommandRunner_IsLocked(t *testing.T) {
Pull: modelPull,
HeadRepo: fixtures.GithubRepo,
Trigger: events.Comment,
Scope: scopeNull,
}

When(applyLockChecker.CheckApplyLock()).ThenReturn(locking.ApplyCommandLock{Locked: c.ApplyLocked}, c.ApplyLockError)
Expand Down
1 change: 1 addition & 0 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ func NewServer(userConfig UserConfig, config Config) (*Server, error) {
lockingClient = locking.NewNoOpLocker()
} else {
lockingClient = locking.NewClient(boltdb)
applyLockingClient = locking.NewApplyClient(boltdb, userConfig.DisableApply)
}
applyLockingClient = locking.NewApplyClient(boltdb, userConfig.DisableApply)
workingDirLocker := events.NewDefaultWorkingDirLocker()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**Error:** Running `atlantis apply` is disabled.

0 comments on commit 481004f

Please sign in to comment.