diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index c7703782e..6874d8faa 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -144,7 +144,7 @@ Each interface that is mocked has a `go:generate` command above it, e.g.
//go:generate pegomock generate -m --use-experimental-model-gen --package mocks -o mocks/mock_project_command_builder.go ProjectCommandBuilder
type ProjectCommandBuilder interface {
- BuildAutoplanCommands(ctx *CommandContext) ([]models.ProjectCommandContext, error)
+ BuildAutoplanCommands(ctx *command.Context) ([]command.ProjectContext, error)
}
```
diff --git a/server/controllers/events/events_controller_e2e_test.go b/server/controllers/events/events_controller_e2e_test.go
index 319900f53..4d2204e25 100644
--- a/server/controllers/events/events_controller_e2e_test.go
+++ b/server/controllers/events/events_controller_e2e_test.go
@@ -28,6 +28,7 @@ import (
"github.com/runatlantis/atlantis/server/core/runtime/policy"
"github.com/runatlantis/atlantis/server/core/terraform"
"github.com/runatlantis/atlantis/server/events"
+ "github.com/runatlantis/atlantis/server/events/command"
"github.com/runatlantis/atlantis/server/events/mocks"
"github.com/runatlantis/atlantis/server/events/mocks/matchers"
"github.com/runatlantis/atlantis/server/events/models"
@@ -1068,12 +1069,12 @@ func setupE2E(t *testing.T, repoDir string) (events_controllers.VCSEventsControl
silenceNoProjects,
)
- commentCommandRunnerByCmd := map[models.CommandName]events.CommentCommandRunner{
- models.PlanCommand: planCommandRunner,
- models.ApplyCommand: applyCommandRunner,
- models.ApprovePoliciesCommand: approvePoliciesCommandRunner,
- models.UnlockCommand: unlockCommandRunner,
- models.VersionCommand: versionCommandRunner,
+ commentCommandRunnerByCmd := map[command.Name]events.CommentCommandRunner{
+ command.Plan: planCommandRunner,
+ command.Apply: applyCommandRunner,
+ command.ApprovePolicies: approvePoliciesCommandRunner,
+ command.Unlock: unlockCommandRunner,
+ command.Version: versionCommandRunner,
}
commandRunner := &events.DefaultCommandRunner{
diff --git a/server/controllers/events/mocks/matchers/ptr_to_http_request.go b/server/controllers/events/mocks/matchers/ptr_to_http_request.go
index dfbfc1867..14f45554d 100644
--- a/server/controllers/events/mocks/matchers/ptr_to_http_request.go
+++ b/server/controllers/events/mocks/matchers/ptr_to_http_request.go
@@ -2,9 +2,10 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+ "github.com/petergtz/pegomock"
+
http "net/http"
)
diff --git a/server/controllers/events/mocks/matchers/slice_of_byte.go b/server/controllers/events/mocks/matchers/slice_of_byte.go
index 951531345..7ff2e45ca 100644
--- a/server/controllers/events/mocks/matchers/slice_of_byte.go
+++ b/server/controllers/events/mocks/matchers/slice_of_byte.go
@@ -2,8 +2,9 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+
+ "github.com/petergtz/pegomock"
)
func AnySliceOfByte() []byte {
diff --git a/server/controllers/events/mocks/mock_azuredevops_request_validator.go b/server/controllers/events/mocks/mock_azuredevops_request_validator.go
index 8d100d544..cf26922fa 100644
--- a/server/controllers/events/mocks/mock_azuredevops_request_validator.go
+++ b/server/controllers/events/mocks/mock_azuredevops_request_validator.go
@@ -4,10 +4,11 @@
package mocks
import (
- pegomock "github.com/petergtz/pegomock"
http "net/http"
"reflect"
"time"
+
+ pegomock "github.com/petergtz/pegomock"
)
type MockAzureDevopsRequestValidator struct {
diff --git a/server/controllers/events/mocks/mock_github_request_validator.go b/server/controllers/events/mocks/mock_github_request_validator.go
index e36b79d74..7b8c3e2ae 100644
--- a/server/controllers/events/mocks/mock_github_request_validator.go
+++ b/server/controllers/events/mocks/mock_github_request_validator.go
@@ -4,10 +4,11 @@
package mocks
import (
- pegomock "github.com/petergtz/pegomock"
http "net/http"
"reflect"
"time"
+
+ pegomock "github.com/petergtz/pegomock"
)
type MockGithubRequestValidator struct {
diff --git a/server/controllers/events/mocks/mock_gitlab_request_parser_validator.go b/server/controllers/events/mocks/mock_gitlab_request_parser_validator.go
index 5abefba54..4744d2647 100644
--- a/server/controllers/events/mocks/mock_gitlab_request_parser_validator.go
+++ b/server/controllers/events/mocks/mock_gitlab_request_parser_validator.go
@@ -4,10 +4,11 @@
package mocks
import (
- pegomock "github.com/petergtz/pegomock"
http "net/http"
"reflect"
"time"
+
+ pegomock "github.com/petergtz/pegomock"
)
type MockGitlabRequestParserValidator struct {
diff --git a/server/controllers/locks_controller_test.go b/server/controllers/locks_controller_test.go
index f6ebd5500..01dddf6dd 100644
--- a/server/controllers/locks_controller_test.go
+++ b/server/controllers/locks_controller_test.go
@@ -22,6 +22,7 @@ import (
"github.com/runatlantis/atlantis/server/events"
"github.com/runatlantis/atlantis/server/core/locking/mocks"
+ "github.com/runatlantis/atlantis/server/events/command"
mocks2 "github.com/runatlantis/atlantis/server/events/mocks"
"github.com/runatlantis/atlantis/server/events/models"
vcsmocks "github.com/runatlantis/atlantis/server/events/vcs/mocks"
@@ -302,9 +303,9 @@ func TestDeleteLock_UpdateProjectStatus(t *testing.T) {
db, err := db.New(tmp)
Ok(t, err)
// Seed the DB with a successful plan for that project (that is later discarded).
- _, err = db.UpdatePullWithResults(pull, []models.ProjectResult{
+ _, err = db.UpdatePullWithResults(pull, []command.ProjectResult{
{
- Command: models.PlanCommand,
+ Command: command.Plan,
RepoRelDir: projectPath,
Workspace: workspaceName,
PlanSuccess: &models.PlanSuccess{
diff --git a/server/controllers/templates/mocks/matchers/io_writer.go b/server/controllers/templates/mocks/matchers/io_writer.go
index 856053322..e39a22155 100644
--- a/server/controllers/templates/mocks/matchers/io_writer.go
+++ b/server/controllers/templates/mocks/matchers/io_writer.go
@@ -2,9 +2,10 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+ "github.com/petergtz/pegomock"
+
io "io"
)
diff --git a/server/controllers/templates/mocks/mock_template_writer.go b/server/controllers/templates/mocks/mock_template_writer.go
index 14a3daff5..c26626d3a 100644
--- a/server/controllers/templates/mocks/mock_template_writer.go
+++ b/server/controllers/templates/mocks/mock_template_writer.go
@@ -4,10 +4,11 @@
package mocks
import (
- pegomock "github.com/petergtz/pegomock"
io "io"
"reflect"
"time"
+
+ pegomock "github.com/petergtz/pegomock"
)
type MockTemplateWriter struct {
diff --git a/server/core/db/boltdb.go b/server/core/db/boltdb.go
index 9a95c789c..14641bf0a 100644
--- a/server/core/db/boltdb.go
+++ b/server/core/db/boltdb.go
@@ -11,6 +11,7 @@ import (
"time"
"github.com/pkg/errors"
+ "github.com/runatlantis/atlantis/server/events/command"
"github.com/runatlantis/atlantis/server/events/models"
bolt "go.etcd.io/bbolt"
)
@@ -173,10 +174,10 @@ func (b *BoltDB) List() ([]models.ProjectLock, error) {
// LockCommand attempts to create a new lock for a CommandName.
// If the lock doesn't exists, it will create a lock and return a pointer to it.
// If the lock already exists, it will return an "lock already exists" error
-func (b *BoltDB) LockCommand(cmdName models.CommandName, lockTime time.Time) (*models.CommandLock, error) {
- lock := models.CommandLock{
+func (b *BoltDB) LockCommand(cmdName command.Name, lockTime time.Time) (*command.Lock, error) {
+ lock := command.Lock{
CommandName: cmdName,
- LockMetadata: models.LockMetadata{
+ LockMetadata: command.LockMetadata{
UnixTime: lockTime.Unix(),
},
}
@@ -204,7 +205,7 @@ func (b *BoltDB) LockCommand(cmdName models.CommandName, lockTime time.Time) (*m
// UnlockCommand removes CommandName lock if present.
// If there are no lock it returns an error.
-func (b *BoltDB) UnlockCommand(cmdName models.CommandName) error {
+func (b *BoltDB) UnlockCommand(cmdName command.Name) error {
transactionErr := b.db.Update(func(tx *bolt.Tx) error {
bucket := tx.Bucket(b.globalLocksBucketName)
@@ -224,8 +225,8 @@ func (b *BoltDB) UnlockCommand(cmdName models.CommandName) error {
// CheckCommandLock checks if CommandName lock was set.
// If the lock exists return the pointer to the lock object, otherwise return nil
-func (b *BoltDB) CheckCommandLock(cmdName models.CommandName) (*models.CommandLock, error) {
- cmdLock := models.CommandLock{}
+func (b *BoltDB) CheckCommandLock(cmdName command.Name) (*command.Lock, error) {
+ cmdLock := command.Lock{}
found := false
@@ -312,7 +313,7 @@ func (b *BoltDB) GetLock(p models.Project, workspace string) (*models.ProjectLoc
// UpdatePullWithResults updates pull's status with the latest project results.
// It returns the new PullStatus object.
-func (b *BoltDB) UpdatePullWithResults(pull models.PullRequest, newResults []models.ProjectResult) (models.PullStatus, error) {
+func (b *BoltDB) UpdatePullWithResults(pull models.PullRequest, newResults []command.ProjectResult) (models.PullStatus, error) {
key, err := b.pullKey(pull)
if err != nil {
return models.PullStatus{}, err
@@ -451,7 +452,7 @@ func (b *BoltDB) pullKey(pull models.PullRequest) ([]byte, error) {
nil
}
-func (b *BoltDB) commandLockKey(cmdName models.CommandName) string {
+func (b *BoltDB) commandLockKey(cmdName command.Name) string {
return fmt.Sprintf("%s/lock", cmdName)
}
@@ -480,7 +481,7 @@ func (b *BoltDB) writePullToBucket(bucket *bolt.Bucket, key []byte, pull models.
return bucket.Put(key, serialized)
}
-func (b *BoltDB) projectResultToProject(p models.ProjectResult) models.ProjectStatus {
+func (b *BoltDB) projectResultToProject(p command.ProjectResult) models.ProjectStatus {
return models.ProjectStatus{
Workspace: p.Workspace,
RepoRelDir: p.RepoRelDir,
diff --git a/server/core/db/boltdb_test.go b/server/core/db/boltdb_test.go
index 24b0342f7..ddee030fa 100644
--- a/server/core/db/boltdb_test.go
+++ b/server/core/db/boltdb_test.go
@@ -21,6 +21,7 @@ import (
"github.com/runatlantis/atlantis/server/core/db"
"github.com/pkg/errors"
+ "github.com/runatlantis/atlantis/server/events/command"
"github.com/runatlantis/atlantis/server/events/models"
. "github.com/runatlantis/atlantis/testing"
bolt "go.etcd.io/bbolt"
@@ -47,7 +48,7 @@ func TestLockCommandNotSet(t *testing.T) {
t.Log("retrieving apply lock when there are none should return empty LockCommand")
db, b := newTestDB()
defer cleanupDB(db)
- exists, err := b.CheckCommandLock(models.ApplyCommand)
+ exists, err := b.CheckCommandLock(command.Apply)
Ok(t, err)
Assert(t, exists == nil, "exp nil")
}
@@ -57,10 +58,10 @@ func TestLockCommandEnabled(t *testing.T) {
db, b := newTestDB()
defer cleanupDB(db)
timeNow := time.Now()
- _, err := b.LockCommand(models.ApplyCommand, timeNow)
+ _, err := b.LockCommand(command.Apply, timeNow)
Ok(t, err)
- config, err := b.CheckCommandLock(models.ApplyCommand)
+ config, err := b.CheckCommandLock(command.Apply)
Ok(t, err)
Equals(t, true, config.IsLocked())
}
@@ -70,10 +71,10 @@ func TestLockCommandFail(t *testing.T) {
db, b := newTestDB()
defer cleanupDB(db)
timeNow := time.Now()
- _, err := b.LockCommand(models.ApplyCommand, timeNow)
+ _, err := b.LockCommand(command.Apply, timeNow)
Ok(t, err)
- _, err = b.LockCommand(models.ApplyCommand, timeNow)
+ _, err = b.LockCommand(command.Apply, timeNow)
ErrEquals(t, "db transaction failed: lock already exists", err)
}
@@ -82,17 +83,17 @@ func TestUnlockCommandDisabled(t *testing.T) {
db, b := newTestDB()
defer cleanupDB(db)
timeNow := time.Now()
- _, err := b.LockCommand(models.ApplyCommand, timeNow)
+ _, err := b.LockCommand(command.Apply, timeNow)
Ok(t, err)
- config, err := b.CheckCommandLock(models.ApplyCommand)
+ config, err := b.CheckCommandLock(command.Apply)
Ok(t, err)
Equals(t, true, config.IsLocked())
- err = b.UnlockCommand(models.ApplyCommand)
+ err = b.UnlockCommand(command.Apply)
Ok(t, err)
- config, err = b.CheckCommandLock(models.ApplyCommand)
+ config, err = b.CheckCommandLock(command.Apply)
Ok(t, err)
Assert(t, config == nil, "exp nil object")
}
@@ -101,7 +102,7 @@ func TestUnlockCommandFail(t *testing.T) {
t.Log("setting the apply lock")
db, b := newTestDB()
defer cleanupDB(db)
- err := b.UnlockCommand(models.ApplyCommand)
+ err := b.UnlockCommand(command.Apply)
ErrEquals(t, "db transaction failed: no lock exists", err)
}
@@ -109,7 +110,7 @@ func TestMixedLocksPresent(t *testing.T) {
db, b := newTestDB()
defer cleanupDB(db)
timeNow := time.Now()
- _, err := b.LockCommand(models.ApplyCommand, timeNow)
+ _, err := b.LockCommand(command.Apply, timeNow)
Ok(t, err)
_, _, err = b.TryLock(lock)
@@ -456,9 +457,9 @@ func TestPullStatus_UpdateGet(t *testing.T) {
}
status, err := b.UpdatePullWithResults(
pull,
- []models.ProjectResult{
+ []command.ProjectResult{
{
- Command: models.PlanCommand,
+ Command: command.Plan,
RepoRelDir: ".",
Workspace: "default",
Failure: "failure",
@@ -507,7 +508,7 @@ func TestPullStatus_UpdateDeleteGet(t *testing.T) {
}
_, err := b.UpdatePullWithResults(
pull,
- []models.ProjectResult{
+ []command.ProjectResult{
{
RepoRelDir: ".",
Workspace: "default",
@@ -553,7 +554,7 @@ func TestPullStatus_UpdateProject(t *testing.T) {
}
_, err := b.UpdatePullWithResults(
pull,
- []models.ProjectResult{
+ []command.ProjectResult{
{
RepoRelDir: ".",
Workspace: "default",
@@ -617,7 +618,7 @@ func TestPullStatus_UpdateNewCommit(t *testing.T) {
}
_, err := b.UpdatePullWithResults(
pull,
- []models.ProjectResult{
+ []command.ProjectResult{
{
RepoRelDir: ".",
Workspace: "default",
@@ -628,7 +629,7 @@ func TestPullStatus_UpdateNewCommit(t *testing.T) {
pull.HeadCommit = "newsha"
status, err := b.UpdatePullWithResults(pull,
- []models.ProjectResult{
+ []command.ProjectResult{
{
RepoRelDir: ".",
Workspace: "staging",
@@ -680,22 +681,22 @@ func TestPullStatus_UpdateMerge(t *testing.T) {
}
_, err := b.UpdatePullWithResults(
pull,
- []models.ProjectResult{
+ []command.ProjectResult{
{
- Command: models.PlanCommand,
+ Command: command.Plan,
RepoRelDir: "mergeme",
Workspace: "default",
Failure: "failure",
},
{
- Command: models.PlanCommand,
+ Command: command.Plan,
RepoRelDir: "projectname",
Workspace: "default",
ProjectName: "projectname",
Failure: "failure",
},
{
- Command: models.PlanCommand,
+ Command: command.Plan,
RepoRelDir: "staythesame",
Workspace: "default",
PlanSuccess: &models.PlanSuccess{
@@ -709,22 +710,22 @@ func TestPullStatus_UpdateMerge(t *testing.T) {
Ok(t, err)
updateStatus, err := b.UpdatePullWithResults(pull,
- []models.ProjectResult{
+ []command.ProjectResult{
{
- Command: models.ApplyCommand,
+ Command: command.Apply,
RepoRelDir: "mergeme",
Workspace: "default",
ApplySuccess: "applied!",
},
{
- Command: models.ApplyCommand,
+ Command: command.Apply,
RepoRelDir: "projectname",
Workspace: "default",
ProjectName: "projectname",
Error: errors.New("apply error"),
},
{
- Command: models.ApplyCommand,
+ Command: command.Apply,
RepoRelDir: "newresult",
Workspace: "default",
ApplySuccess: "success!",
diff --git a/server/core/locking/apply_locking.go b/server/core/locking/apply_locking.go
index bb1310443..3ffc295cc 100644
--- a/server/core/locking/apply_locking.go
+++ b/server/core/locking/apply_locking.go
@@ -4,7 +4,7 @@ import (
"errors"
"time"
- "github.com/runatlantis/atlantis/server/events/models"
+ "github.com/runatlantis/atlantis/server/events/command"
)
//go:generate pegomock generate -m --use-experimental-model-gen --package mocks -o mocks/mock_apply_lock_checker.go ApplyLockChecker
@@ -60,7 +60,7 @@ func (c *ApplyClient) LockApply() (ApplyCommandLock, error) {
return response, errors.New("DisableApplyFlag is set; Apply commands are locked globally until flag is unset")
}
- applyCmdLock, err := c.backend.LockCommand(models.ApplyCommand, time.Now())
+ applyCmdLock, err := c.backend.LockCommand(command.Apply, time.Now())
if err != nil {
return response, err
}
@@ -80,7 +80,7 @@ func (c *ApplyClient) UnlockApply() error {
return errors.New("apply commands are disabled until DisableApply flag is unset")
}
- err := c.backend.UnlockCommand(models.ApplyCommand)
+ err := c.backend.UnlockCommand(command.Apply)
if err != nil {
return err
}
@@ -99,7 +99,7 @@ func (c *ApplyClient) CheckApplyLock() (ApplyCommandLock, error) {
}, nil
}
- applyCmdLock, err := c.backend.CheckCommandLock(models.ApplyCommand)
+ applyCmdLock, err := c.backend.CheckCommandLock(command.Apply)
if err != nil {
return response, err
}
diff --git a/server/core/locking/locking.go b/server/core/locking/locking.go
index 17f6b8aad..2abb0a4dc 100644
--- a/server/core/locking/locking.go
+++ b/server/core/locking/locking.go
@@ -20,6 +20,7 @@ import (
"regexp"
"time"
+ "github.com/runatlantis/atlantis/server/events/command"
"github.com/runatlantis/atlantis/server/events/models"
)
@@ -33,9 +34,9 @@ type Backend interface {
GetLock(project models.Project, workspace string) (*models.ProjectLock, error)
UnlockByPull(repoFullName string, pullNum int) ([]models.ProjectLock, error)
- LockCommand(cmdName models.CommandName, lockTime time.Time) (*models.CommandLock, error)
- UnlockCommand(cmdName models.CommandName) error
- CheckCommandLock(cmdName models.CommandName) (*models.CommandLock, error)
+ LockCommand(cmdName command.Name, lockTime time.Time) (*command.Lock, error)
+ UnlockCommand(cmdName command.Name) error
+ CheckCommandLock(cmdName command.Name) (*command.Lock, error)
}
// TryLockResponse results from an attempted lock.
diff --git a/server/core/locking/locking_test.go b/server/core/locking/locking_test.go
index 316b770ba..f6f2c9887 100644
--- a/server/core/locking/locking_test.go
+++ b/server/core/locking/locking_test.go
@@ -24,6 +24,7 @@ import (
"github.com/runatlantis/atlantis/server/core/locking"
"github.com/runatlantis/atlantis/server/core/locking/mocks"
"github.com/runatlantis/atlantis/server/core/locking/mocks/matchers"
+ "github.com/runatlantis/atlantis/server/events/command"
"github.com/runatlantis/atlantis/server/events/models"
. "github.com/runatlantis/atlantis/testing"
)
@@ -184,9 +185,9 @@ func TestGetLock_NoOpLocker(t *testing.T) {
func TestApplyLocker(t *testing.T) {
RegisterMockTestingT(t)
- applyLock := &models.CommandLock{
- CommandName: models.ApplyCommand,
- LockMetadata: models.LockMetadata{
+ applyLock := &command.Lock{
+ CommandName: command.Apply,
+ LockMetadata: command.LockMetadata{
UnixTime: time.Now().Unix(),
},
}
diff --git a/server/core/locking/mocks/matchers/locking_applycommandlock.go b/server/core/locking/mocks/matchers/locking_applycommandlock.go
index 4e5627062..07bbd23e2 100644
--- a/server/core/locking/mocks/matchers/locking_applycommandlock.go
+++ b/server/core/locking/mocks/matchers/locking_applycommandlock.go
@@ -2,9 +2,10 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+ "github.com/petergtz/pegomock"
+
locking "github.com/runatlantis/atlantis/server/core/locking"
)
diff --git a/server/core/locking/mocks/matchers/locking_applycommandlockresponse.go b/server/core/locking/mocks/matchers/locking_applycommandlockresponse.go
index f54209e43..5b9faf936 100644
--- a/server/core/locking/mocks/matchers/locking_applycommandlockresponse.go
+++ b/server/core/locking/mocks/matchers/locking_applycommandlockresponse.go
@@ -2,9 +2,10 @@
package matchers
import (
+ "reflect"
+
"github.com/petergtz/pegomock"
locking "github.com/runatlantis/atlantis/server/core/locking"
- "reflect"
)
func AnyLockingApplyCommandLockResponse() locking.ApplyCommandLock {
diff --git a/server/core/locking/mocks/matchers/locking_trylockresponse.go b/server/core/locking/mocks/matchers/locking_trylockresponse.go
index 53e9bb19d..02aaa0098 100644
--- a/server/core/locking/mocks/matchers/locking_trylockresponse.go
+++ b/server/core/locking/mocks/matchers/locking_trylockresponse.go
@@ -2,9 +2,10 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+ "github.com/petergtz/pegomock"
+
locking "github.com/runatlantis/atlantis/server/core/locking"
)
diff --git a/server/core/locking/mocks/matchers/map_of_string_to_models_projectlock.go b/server/core/locking/mocks/matchers/map_of_string_to_models_projectlock.go
index eb1b54416..e541f2b22 100644
--- a/server/core/locking/mocks/matchers/map_of_string_to_models_projectlock.go
+++ b/server/core/locking/mocks/matchers/map_of_string_to_models_projectlock.go
@@ -2,9 +2,10 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+ "github.com/petergtz/pegomock"
+
models "github.com/runatlantis/atlantis/server/events/models"
)
diff --git a/server/core/locking/mocks/matchers/models_commandlock.go b/server/core/locking/mocks/matchers/models_commandlock.go
index 87669404b..c4078950a 100644
--- a/server/core/locking/mocks/matchers/models_commandlock.go
+++ b/server/core/locking/mocks/matchers/models_commandlock.go
@@ -3,18 +3,19 @@ package matchers
import (
"reflect"
+
"github.com/petergtz/pegomock"
- models "github.com/runatlantis/atlantis/server/events/models"
+ command "github.com/runatlantis/atlantis/server/events/command"
)
-func AnyModelsCommandLock() models.CommandLock {
- pegomock.RegisterMatcher(pegomock.NewAnyMatcher(reflect.TypeOf((*(models.CommandLock))(nil)).Elem()))
- var nullValue models.CommandLock
+func AnyModelsCommandLock() command.Lock {
+ pegomock.RegisterMatcher(pegomock.NewAnyMatcher(reflect.TypeOf((*(command.Lock))(nil)).Elem()))
+ var nullValue command.Lock
return nullValue
}
-func EqModelsCommandLock(value models.CommandLock) models.CommandLock {
+func EqModelsCommandLock(value command.Lock) command.Lock {
pegomock.RegisterMatcher(&pegomock.EqMatcher{Value: value})
- var nullValue models.CommandLock
+ var nullValue command.Lock
return nullValue
}
diff --git a/server/core/locking/mocks/matchers/models_commandname.go b/server/core/locking/mocks/matchers/models_commandname.go
index f586b4d21..aec79b126 100644
--- a/server/core/locking/mocks/matchers/models_commandname.go
+++ b/server/core/locking/mocks/matchers/models_commandname.go
@@ -2,32 +2,32 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
- models "github.com/runatlantis/atlantis/server/events/models"
+ "github.com/petergtz/pegomock"
+ "github.com/runatlantis/atlantis/server/events/command"
)
-func AnyModelsCommandName() models.CommandName {
- pegomock.RegisterMatcher(pegomock.NewAnyMatcher(reflect.TypeOf((*(models.CommandName))(nil)).Elem()))
- var nullValue models.CommandName
+func AnyModelsCommandName() command.Name {
+ pegomock.RegisterMatcher(pegomock.NewAnyMatcher(reflect.TypeOf((*(command.Name))(nil)).Elem()))
+ var nullValue command.Name
return nullValue
}
-func EqModelsCommandName(value models.CommandName) models.CommandName {
+func EqModelsCommandName(value command.Name) command.Name {
pegomock.RegisterMatcher(&pegomock.EqMatcher{Value: value})
- var nullValue models.CommandName
+ var nullValue command.Name
return nullValue
}
-func NotEqModelsCommandName(value models.CommandName) models.CommandName {
+func NotEqModelsCommandName(value command.Name) command.Name {
pegomock.RegisterMatcher(&pegomock.NotEqMatcher{Value: value})
- var nullValue models.CommandName
+ var nullValue command.Name
return nullValue
}
-func ModelsCommandNameThat(matcher pegomock.ArgumentMatcher) models.CommandName {
+func ModelsCommandNameThat(matcher pegomock.ArgumentMatcher) command.Name {
pegomock.RegisterMatcher(matcher)
- var nullValue models.CommandName
+ var nullValue command.Name
return nullValue
}
diff --git a/server/core/locking/mocks/matchers/models_project.go b/server/core/locking/mocks/matchers/models_project.go
index a5a87e6f0..0cc4104e5 100644
--- a/server/core/locking/mocks/matchers/models_project.go
+++ b/server/core/locking/mocks/matchers/models_project.go
@@ -2,9 +2,10 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+ "github.com/petergtz/pegomock"
+
models "github.com/runatlantis/atlantis/server/events/models"
)
diff --git a/server/core/locking/mocks/matchers/models_projectlock.go b/server/core/locking/mocks/matchers/models_projectlock.go
index 182266c5e..64127a924 100644
--- a/server/core/locking/mocks/matchers/models_projectlock.go
+++ b/server/core/locking/mocks/matchers/models_projectlock.go
@@ -2,9 +2,10 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+ "github.com/petergtz/pegomock"
+
models "github.com/runatlantis/atlantis/server/events/models"
)
diff --git a/server/core/locking/mocks/matchers/models_pullrequest.go b/server/core/locking/mocks/matchers/models_pullrequest.go
index 9ae2a7e92..db2666f02 100644
--- a/server/core/locking/mocks/matchers/models_pullrequest.go
+++ b/server/core/locking/mocks/matchers/models_pullrequest.go
@@ -2,9 +2,10 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+ "github.com/petergtz/pegomock"
+
models "github.com/runatlantis/atlantis/server/events/models"
)
diff --git a/server/core/locking/mocks/matchers/models_user.go b/server/core/locking/mocks/matchers/models_user.go
index 0aa92b5d8..e9bf1384b 100644
--- a/server/core/locking/mocks/matchers/models_user.go
+++ b/server/core/locking/mocks/matchers/models_user.go
@@ -2,9 +2,10 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+ "github.com/petergtz/pegomock"
+
models "github.com/runatlantis/atlantis/server/events/models"
)
diff --git a/server/core/locking/mocks/matchers/ptr_to_models_commandlock.go b/server/core/locking/mocks/matchers/ptr_to_models_commandlock.go
index fbd210aad..b4785494b 100644
--- a/server/core/locking/mocks/matchers/ptr_to_models_commandlock.go
+++ b/server/core/locking/mocks/matchers/ptr_to_models_commandlock.go
@@ -2,32 +2,33 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
- models "github.com/runatlantis/atlantis/server/events/models"
+ "github.com/petergtz/pegomock"
+
+ command "github.com/runatlantis/atlantis/server/events/command"
)
-func AnyPtrToModelsCommandLock() *models.CommandLock {
- pegomock.RegisterMatcher(pegomock.NewAnyMatcher(reflect.TypeOf((*(*models.CommandLock))(nil)).Elem()))
- var nullValue *models.CommandLock
+func AnyPtrToModelsCommandLock() *command.Lock {
+ pegomock.RegisterMatcher(pegomock.NewAnyMatcher(reflect.TypeOf((*(*command.Lock))(nil)).Elem()))
+ var nullValue *command.Lock
return nullValue
}
-func EqPtrToModelsCommandLock(value *models.CommandLock) *models.CommandLock {
+func EqPtrToModelsCommandLock(value *command.Lock) *command.Lock {
pegomock.RegisterMatcher(&pegomock.EqMatcher{Value: value})
- var nullValue *models.CommandLock
+ var nullValue *command.Lock
return nullValue
}
-func NotEqPtrToModelsCommandLock(value *models.CommandLock) *models.CommandLock {
+func NotEqPtrToModelsCommandLock(value *command.Lock) *command.Lock {
pegomock.RegisterMatcher(&pegomock.NotEqMatcher{Value: value})
- var nullValue *models.CommandLock
+ var nullValue *command.Lock
return nullValue
}
-func PtrToModelsCommandLockThat(matcher pegomock.ArgumentMatcher) *models.CommandLock {
+func PtrToModelsCommandLockThat(matcher pegomock.ArgumentMatcher) *command.Lock {
pegomock.RegisterMatcher(matcher)
- var nullValue *models.CommandLock
+ var nullValue *command.Lock
return nullValue
}
diff --git a/server/core/locking/mocks/matchers/ptr_to_models_projectlock.go b/server/core/locking/mocks/matchers/ptr_to_models_projectlock.go
index 7b0b6f108..c33537f97 100644
--- a/server/core/locking/mocks/matchers/ptr_to_models_projectlock.go
+++ b/server/core/locking/mocks/matchers/ptr_to_models_projectlock.go
@@ -2,9 +2,10 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+ "github.com/petergtz/pegomock"
+
models "github.com/runatlantis/atlantis/server/events/models"
)
diff --git a/server/core/locking/mocks/matchers/slice_of_models_projectlock.go b/server/core/locking/mocks/matchers/slice_of_models_projectlock.go
index f510db6e8..16932f9a1 100644
--- a/server/core/locking/mocks/matchers/slice_of_models_projectlock.go
+++ b/server/core/locking/mocks/matchers/slice_of_models_projectlock.go
@@ -2,9 +2,10 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+ "github.com/petergtz/pegomock"
+
models "github.com/runatlantis/atlantis/server/events/models"
)
diff --git a/server/core/locking/mocks/matchers/time_time.go b/server/core/locking/mocks/matchers/time_time.go
index 461e1dd6d..755cf1bf8 100644
--- a/server/core/locking/mocks/matchers/time_time.go
+++ b/server/core/locking/mocks/matchers/time_time.go
@@ -2,9 +2,10 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+ "github.com/petergtz/pegomock"
+
time "time"
)
diff --git a/server/core/locking/mocks/mock_apply_lock_checker.go b/server/core/locking/mocks/mock_apply_lock_checker.go
index e133e9994..9234c4d32 100644
--- a/server/core/locking/mocks/mock_apply_lock_checker.go
+++ b/server/core/locking/mocks/mock_apply_lock_checker.go
@@ -4,10 +4,11 @@
package mocks
import (
- pegomock "github.com/petergtz/pegomock"
- locking "github.com/runatlantis/atlantis/server/core/locking"
"reflect"
"time"
+
+ pegomock "github.com/petergtz/pegomock"
+ locking "github.com/runatlantis/atlantis/server/core/locking"
)
type MockApplyLockChecker struct {
diff --git a/server/core/locking/mocks/mock_apply_locker.go b/server/core/locking/mocks/mock_apply_locker.go
index d8608ec1f..88e3c3897 100644
--- a/server/core/locking/mocks/mock_apply_locker.go
+++ b/server/core/locking/mocks/mock_apply_locker.go
@@ -4,10 +4,11 @@
package mocks
import (
- pegomock "github.com/petergtz/pegomock"
- locking "github.com/runatlantis/atlantis/server/core/locking"
"reflect"
"time"
+
+ pegomock "github.com/petergtz/pegomock"
+ locking "github.com/runatlantis/atlantis/server/core/locking"
)
type MockApplyLocker struct {
diff --git a/server/core/locking/mocks/mock_backend.go b/server/core/locking/mocks/mock_backend.go
index c2876a9cb..edfb55055 100644
--- a/server/core/locking/mocks/mock_backend.go
+++ b/server/core/locking/mocks/mock_backend.go
@@ -4,10 +4,12 @@
package mocks
import (
- pegomock "github.com/petergtz/pegomock"
- models "github.com/runatlantis/atlantis/server/events/models"
"reflect"
"time"
+
+ pegomock "github.com/petergtz/pegomock"
+ "github.com/runatlantis/atlantis/server/events/command"
+ models "github.com/runatlantis/atlantis/server/events/models"
)
type MockBackend struct {
@@ -124,17 +126,17 @@ func (mock *MockBackend) UnlockByPull(repoFullName string, pullNum int) ([]model
return ret0, ret1
}
-func (mock *MockBackend) LockCommand(cmdName models.CommandName, lockTime time.Time) (*models.CommandLock, error) {
+func (mock *MockBackend) LockCommand(cmdName command.Name, lockTime time.Time) (*command.Lock, error) {
if mock == nil {
panic("mock must not be nil. Use myMock := NewMockBackend().")
}
params := []pegomock.Param{cmdName, lockTime}
- result := pegomock.GetGenericMockFrom(mock).Invoke("LockCommand", params, []reflect.Type{reflect.TypeOf((**models.CommandLock)(nil)).Elem(), reflect.TypeOf((*error)(nil)).Elem()})
- var ret0 *models.CommandLock
+ result := pegomock.GetGenericMockFrom(mock).Invoke("LockCommand", params, []reflect.Type{reflect.TypeOf((**command.Lock)(nil)).Elem(), reflect.TypeOf((*error)(nil)).Elem()})
+ var ret0 *command.Lock
var ret1 error
if len(result) != 0 {
if result[0] != nil {
- ret0 = result[0].(*models.CommandLock)
+ ret0 = result[0].(*command.Lock)
}
if result[1] != nil {
ret1 = result[1].(error)
@@ -143,7 +145,7 @@ func (mock *MockBackend) LockCommand(cmdName models.CommandName, lockTime time.T
return ret0, ret1
}
-func (mock *MockBackend) UnlockCommand(cmdName models.CommandName) error {
+func (mock *MockBackend) UnlockCommand(cmdName command.Name) error {
if mock == nil {
panic("mock must not be nil. Use myMock := NewMockBackend().")
}
@@ -158,17 +160,17 @@ func (mock *MockBackend) UnlockCommand(cmdName models.CommandName) error {
return ret0
}
-func (mock *MockBackend) CheckCommandLock(cmdName models.CommandName) (*models.CommandLock, error) {
+func (mock *MockBackend) CheckCommandLock(cmdName command.Name) (*command.Lock, error) {
if mock == nil {
panic("mock must not be nil. Use myMock := NewMockBackend().")
}
params := []pegomock.Param{cmdName}
- result := pegomock.GetGenericMockFrom(mock).Invoke("CheckCommandLock", params, []reflect.Type{reflect.TypeOf((**models.CommandLock)(nil)).Elem(), reflect.TypeOf((*error)(nil)).Elem()})
- var ret0 *models.CommandLock
+ result := pegomock.GetGenericMockFrom(mock).Invoke("CheckCommandLock", params, []reflect.Type{reflect.TypeOf((**command.Lock)(nil)).Elem(), reflect.TypeOf((*error)(nil)).Elem()})
+ var ret0 *command.Lock
var ret1 error
if len(result) != 0 {
if result[0] != nil {
- ret0 = result[0].(*models.CommandLock)
+ ret0 = result[0].(*command.Lock)
}
if result[1] != nil {
ret1 = result[1].(error)
@@ -351,7 +353,7 @@ func (c *MockBackend_UnlockByPull_OngoingVerification) GetAllCapturedArguments()
return
}
-func (verifier *VerifierMockBackend) LockCommand(cmdName models.CommandName, lockTime time.Time) *MockBackend_LockCommand_OngoingVerification {
+func (verifier *VerifierMockBackend) LockCommand(cmdName command.Name, lockTime time.Time) *MockBackend_LockCommand_OngoingVerification {
params := []pegomock.Param{cmdName, lockTime}
methodInvocations := pegomock.GetGenericMockFrom(verifier.mock).Verify(verifier.inOrderContext, verifier.invocationCountMatcher, "LockCommand", params, verifier.timeout)
return &MockBackend_LockCommand_OngoingVerification{mock: verifier.mock, methodInvocations: methodInvocations}
@@ -362,17 +364,17 @@ type MockBackend_LockCommand_OngoingVerification struct {
methodInvocations []pegomock.MethodInvocation
}
-func (c *MockBackend_LockCommand_OngoingVerification) GetCapturedArguments() (models.CommandName, time.Time) {
+func (c *MockBackend_LockCommand_OngoingVerification) GetCapturedArguments() (command.Name, time.Time) {
cmdName, lockTime := c.GetAllCapturedArguments()
return cmdName[len(cmdName)-1], lockTime[len(lockTime)-1]
}
-func (c *MockBackend_LockCommand_OngoingVerification) GetAllCapturedArguments() (_param0 []models.CommandName, _param1 []time.Time) {
+func (c *MockBackend_LockCommand_OngoingVerification) GetAllCapturedArguments() (_param0 []command.Name, _param1 []time.Time) {
params := pegomock.GetGenericMockFrom(c.mock).GetInvocationParams(c.methodInvocations)
if len(params) > 0 {
- _param0 = make([]models.CommandName, len(c.methodInvocations))
+ _param0 = make([]command.Name, len(c.methodInvocations))
for u, param := range params[0] {
- _param0[u] = param.(models.CommandName)
+ _param0[u] = param.(command.Name)
}
_param1 = make([]time.Time, len(c.methodInvocations))
for u, param := range params[1] {
@@ -382,7 +384,7 @@ func (c *MockBackend_LockCommand_OngoingVerification) GetAllCapturedArguments()
return
}
-func (verifier *VerifierMockBackend) UnlockCommand(cmdName models.CommandName) *MockBackend_UnlockCommand_OngoingVerification {
+func (verifier *VerifierMockBackend) UnlockCommand(cmdName command.Name) *MockBackend_UnlockCommand_OngoingVerification {
params := []pegomock.Param{cmdName}
methodInvocations := pegomock.GetGenericMockFrom(verifier.mock).Verify(verifier.inOrderContext, verifier.invocationCountMatcher, "UnlockCommand", params, verifier.timeout)
return &MockBackend_UnlockCommand_OngoingVerification{mock: verifier.mock, methodInvocations: methodInvocations}
@@ -393,23 +395,23 @@ type MockBackend_UnlockCommand_OngoingVerification struct {
methodInvocations []pegomock.MethodInvocation
}
-func (c *MockBackend_UnlockCommand_OngoingVerification) GetCapturedArguments() models.CommandName {
+func (c *MockBackend_UnlockCommand_OngoingVerification) GetCapturedArguments() command.Name {
cmdName := c.GetAllCapturedArguments()
return cmdName[len(cmdName)-1]
}
-func (c *MockBackend_UnlockCommand_OngoingVerification) GetAllCapturedArguments() (_param0 []models.CommandName) {
+func (c *MockBackend_UnlockCommand_OngoingVerification) GetAllCapturedArguments() (_param0 []command.Name) {
params := pegomock.GetGenericMockFrom(c.mock).GetInvocationParams(c.methodInvocations)
if len(params) > 0 {
- _param0 = make([]models.CommandName, len(c.methodInvocations))
+ _param0 = make([]command.Name, len(c.methodInvocations))
for u, param := range params[0] {
- _param0[u] = param.(models.CommandName)
+ _param0[u] = param.(command.Name)
}
}
return
}
-func (verifier *VerifierMockBackend) CheckCommandLock(cmdName models.CommandName) *MockBackend_CheckCommandLock_OngoingVerification {
+func (verifier *VerifierMockBackend) CheckCommandLock(cmdName command.Name) *MockBackend_CheckCommandLock_OngoingVerification {
params := []pegomock.Param{cmdName}
methodInvocations := pegomock.GetGenericMockFrom(verifier.mock).Verify(verifier.inOrderContext, verifier.invocationCountMatcher, "CheckCommandLock", params, verifier.timeout)
return &MockBackend_CheckCommandLock_OngoingVerification{mock: verifier.mock, methodInvocations: methodInvocations}
@@ -420,17 +422,17 @@ type MockBackend_CheckCommandLock_OngoingVerification struct {
methodInvocations []pegomock.MethodInvocation
}
-func (c *MockBackend_CheckCommandLock_OngoingVerification) GetCapturedArguments() models.CommandName {
+func (c *MockBackend_CheckCommandLock_OngoingVerification) GetCapturedArguments() command.Name {
cmdName := c.GetAllCapturedArguments()
return cmdName[len(cmdName)-1]
}
-func (c *MockBackend_CheckCommandLock_OngoingVerification) GetAllCapturedArguments() (_param0 []models.CommandName) {
+func (c *MockBackend_CheckCommandLock_OngoingVerification) GetAllCapturedArguments() (_param0 []command.Name) {
params := pegomock.GetGenericMockFrom(c.mock).GetInvocationParams(c.methodInvocations)
if len(params) > 0 {
- _param0 = make([]models.CommandName, len(c.methodInvocations))
+ _param0 = make([]command.Name, len(c.methodInvocations))
for u, param := range params[0] {
- _param0[u] = param.(models.CommandName)
+ _param0[u] = param.(command.Name)
}
}
return
diff --git a/server/core/locking/mocks/mock_locker.go b/server/core/locking/mocks/mock_locker.go
index 645ca4552..2346124d3 100644
--- a/server/core/locking/mocks/mock_locker.go
+++ b/server/core/locking/mocks/mock_locker.go
@@ -4,11 +4,12 @@
package mocks
import (
+ "reflect"
+ "time"
+
pegomock "github.com/petergtz/pegomock"
locking "github.com/runatlantis/atlantis/server/core/locking"
models "github.com/runatlantis/atlantis/server/events/models"
- "reflect"
- "time"
)
type MockLocker struct {
diff --git a/server/core/runtime/apply_step_runner.go b/server/core/runtime/apply_step_runner.go
index 9fe422da1..67e1f5844 100644
--- a/server/core/runtime/apply_step_runner.go
+++ b/server/core/runtime/apply_step_runner.go
@@ -10,6 +10,7 @@ import (
"github.com/pkg/errors"
version "github.com/hashicorp/go-version"
+ "github.com/runatlantis/atlantis/server/events/command"
"github.com/runatlantis/atlantis/server/events/models"
)
@@ -21,7 +22,7 @@ type ApplyStepRunner struct {
AsyncTFExec AsyncTFExec
}
-func (a *ApplyStepRunner) Run(ctx models.ProjectCommandContext, extraArgs []string, path string, envs map[string]string) (string, error) {
+func (a *ApplyStepRunner) Run(ctx command.ProjectContext, extraArgs []string, path string, envs map[string]string) (string, error) {
if a.hasTargetFlag(ctx, extraArgs) {
return "", errors.New("cannot run apply with -target because we are applying an already generated plan. Instead, run -target with atlantis plan")
}
@@ -62,7 +63,7 @@ func (a *ApplyStepRunner) Run(ctx models.ProjectCommandContext, extraArgs []stri
return out, err
}
-func (a *ApplyStepRunner) hasTargetFlag(ctx models.ProjectCommandContext, extraArgs []string) bool {
+func (a *ApplyStepRunner) hasTargetFlag(ctx command.ProjectContext, extraArgs []string) bool {
isTargetFlag := func(s string) bool {
if s == "-target" {
return true
@@ -109,7 +110,7 @@ func (a *ApplyStepRunner) cleanRemoteApplyOutput(out string) string {
// manual diff.
// It also writes "yes" or "no" to the process to confirm the apply.
func (a *ApplyStepRunner) runRemoteApply(
- ctx models.ProjectCommandContext,
+ ctx command.ProjectContext,
applyArgs []string,
path string,
absPlanPath string,
@@ -125,7 +126,7 @@ func (a *ApplyStepRunner) runRemoteApply(
// updateStatusF will update the commit status and log any error.
updateStatusF := func(status models.CommitStatus, url string) {
- if err := a.CommitStatusUpdater.UpdateProject(ctx, models.ApplyCommand, status, url); err != nil {
+ if err := a.CommitStatusUpdater.UpdateProject(ctx, command.Apply, status, url); err != nil {
ctx.Log.Err("unable to update status: %s", err)
}
}
diff --git a/server/core/runtime/apply_step_runner_test.go b/server/core/runtime/apply_step_runner_test.go
index f8df7187e..eebd8ffe3 100644
--- a/server/core/runtime/apply_step_runner_test.go
+++ b/server/core/runtime/apply_step_runner_test.go
@@ -16,6 +16,7 @@ import (
"github.com/runatlantis/atlantis/server/core/terraform"
"github.com/runatlantis/atlantis/server/core/terraform/mocks"
matchers2 "github.com/runatlantis/atlantis/server/core/terraform/mocks/matchers"
+ "github.com/runatlantis/atlantis/server/events/command"
mocks2 "github.com/runatlantis/atlantis/server/events/mocks"
"github.com/runatlantis/atlantis/server/events/mocks/matchers"
"github.com/runatlantis/atlantis/server/events/models"
@@ -28,7 +29,7 @@ func TestRun_NoDir(t *testing.T) {
o := runtime.ApplyStepRunner{
TerraformExecutor: nil,
}
- _, err := o.Run(models.ProjectCommandContext{
+ _, err := o.Run(command.ProjectContext{
RepoRelDir: ".",
Workspace: "workspace",
}, nil, "/nonexistent/path", map[string]string(nil))
@@ -41,7 +42,7 @@ func TestRun_NoPlanFile(t *testing.T) {
o := runtime.ApplyStepRunner{
TerraformExecutor: nil,
}
- _, err := o.Run(models.ProjectCommandContext{
+ _, err := o.Run(command.ProjectContext{
RepoRelDir: ".",
Workspace: "workspace",
}, nil, tmpDir, map[string]string(nil))
@@ -54,7 +55,7 @@ func TestRun_Success(t *testing.T) {
planPath := filepath.Join(tmpDir, "workspace.tfplan")
err := ioutil.WriteFile(planPath, nil, 0600)
logger := logging.NewNoopLogger(t)
- ctx := models.ProjectCommandContext{
+ ctx := command.ProjectContext{
Log: logger,
Workspace: "workspace",
RepoRelDir: ".",
@@ -86,7 +87,7 @@ func TestRun_AppliesCorrectProjectPlan(t *testing.T) {
err := ioutil.WriteFile(planPath, nil, 0600)
logger := logging.NewNoopLogger(t)
- ctx := models.ProjectCommandContext{
+ ctx := command.ProjectContext{
Log: logger,
Workspace: "default",
RepoRelDir: ".",
@@ -120,7 +121,7 @@ func TestRun_UsesConfiguredTFVersion(t *testing.T) {
logger := logging.NewNoopLogger(t)
tfVersion, _ := version.NewVersion("0.11.0")
- ctx := models.ProjectCommandContext{
+ ctx := command.ProjectContext{
Workspace: "workspace",
RepoRelDir: ".",
EscapedCommentArgs: []string{"comment", "args"},
@@ -209,7 +210,7 @@ func TestRun_UsingTarget(t *testing.T) {
TerraformExecutor: terraform,
}
- output, err := step.Run(models.ProjectCommandContext{
+ output, err := step.Run(command.ProjectContext{
Log: logger,
Workspace: "workspace",
RepoRelDir: ".",
@@ -253,7 +254,7 @@ Plan: 0 to add, 0 to change, 1 to destroy.`
CommitStatusUpdater: updater,
}
tfVersion, _ := version.NewVersion("0.11.0")
- ctx := models.ProjectCommandContext{
+ ctx := command.ProjectContext{
Log: logging.NewNoopLogger(t),
Workspace: "workspace",
RepoRelDir: ".",
@@ -279,8 +280,8 @@ Apply complete! Resources: 0 added, 0 changed, 1 destroyed.
// Check that the status was updated with the run url.
runURL := "https://app.terraform.io/app/lkysow-enterprises/atlantis-tfe-test-dir2/runs/run-PiDsRYKGcerTttV2"
- updater.VerifyWasCalledOnce().UpdateProject(ctx, models.ApplyCommand, models.PendingCommitStatus, runURL)
- updater.VerifyWasCalledOnce().UpdateProject(ctx, models.ApplyCommand, models.SuccessCommitStatus, runURL)
+ updater.VerifyWasCalledOnce().UpdateProject(ctx, command.Apply, models.PendingCommitStatus, runURL)
+ updater.VerifyWasCalledOnce().UpdateProject(ctx, command.Apply, models.SuccessCommitStatus, runURL)
}
// Test that if the plan is different, we error out.
@@ -315,7 +316,7 @@ Plan: 0 to add, 0 to change, 1 to destroy.`
}
tfVersion, _ := version.NewVersion("0.11.0")
- output, err := o.Run(models.ProjectCommandContext{
+ output, err := o.Run(command.ProjectContext{
Log: logging.NewNoopLogger(t),
Workspace: "workspace",
RepoRelDir: ".",
@@ -370,7 +371,7 @@ type remoteApplyMock struct {
}
// RunCommandAsync fakes out running terraform async.
-func (r *remoteApplyMock) RunCommandAsync(ctx models.ProjectCommandContext, path string, args []string, envs map[string]string, v *version.Version, workspace string) (chan<- string, <-chan terraform.Line) {
+func (r *remoteApplyMock) RunCommandAsync(ctx command.ProjectContext, path string, args []string, envs map[string]string, v *version.Version, workspace string) (chan<- string, <-chan terraform.Line) {
r.CalledArgs = args
in := make(chan string)
diff --git a/server/core/runtime/cache/mocks/matchers/ptr_to_go_version_version.go b/server/core/runtime/cache/mocks/matchers/ptr_to_go_version_version.go
index bb596fe3d..038c5f8f1 100644
--- a/server/core/runtime/cache/mocks/matchers/ptr_to_go_version_version.go
+++ b/server/core/runtime/cache/mocks/matchers/ptr_to_go_version_version.go
@@ -2,9 +2,10 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+ "github.com/petergtz/pegomock"
+
go_version "github.com/hashicorp/go-version"
)
diff --git a/server/core/runtime/cache/mocks/mock_key_serializer.go b/server/core/runtime/cache/mocks/mock_key_serializer.go
index e82f10140..89006d23f 100644
--- a/server/core/runtime/cache/mocks/mock_key_serializer.go
+++ b/server/core/runtime/cache/mocks/mock_key_serializer.go
@@ -4,10 +4,11 @@
package mocks
import (
- go_version "github.com/hashicorp/go-version"
- pegomock "github.com/petergtz/pegomock"
"reflect"
"time"
+
+ go_version "github.com/hashicorp/go-version"
+ pegomock "github.com/petergtz/pegomock"
)
type MockKeySerializer struct {
diff --git a/server/core/runtime/cache/mocks/mock_version_path.go b/server/core/runtime/cache/mocks/mock_version_path.go
index 8db080d2e..22a83d33a 100644
--- a/server/core/runtime/cache/mocks/mock_version_path.go
+++ b/server/core/runtime/cache/mocks/mock_version_path.go
@@ -4,10 +4,11 @@
package mocks
import (
- go_version "github.com/hashicorp/go-version"
- pegomock "github.com/petergtz/pegomock"
"reflect"
"time"
+
+ go_version "github.com/hashicorp/go-version"
+ pegomock "github.com/petergtz/pegomock"
)
type MockExecutionVersionCache struct {
diff --git a/server/core/runtime/env_step_runner.go b/server/core/runtime/env_step_runner.go
index e8ba3246c..ae7c27dd5 100644
--- a/server/core/runtime/env_step_runner.go
+++ b/server/core/runtime/env_step_runner.go
@@ -3,7 +3,7 @@ package runtime
import (
"strings"
- "github.com/runatlantis/atlantis/server/events/models"
+ "github.com/runatlantis/atlantis/server/events/command"
)
// EnvStepRunner set environment variables.
@@ -14,7 +14,7 @@ type EnvStepRunner struct {
// Run runs the env step command.
// value is the value for the environment variable. If set this is returned as
// the value. Otherwise command is run and its output is the value returned.
-func (r *EnvStepRunner) Run(ctx models.ProjectCommandContext, command string, value string, path string, envs map[string]string) (string, error) {
+func (r *EnvStepRunner) Run(ctx command.ProjectContext, command string, value string, path string, envs map[string]string) (string, error) {
if value != "" {
return value, nil
}
diff --git a/server/core/runtime/env_step_runner_test.go b/server/core/runtime/env_step_runner_test.go
index 746840c4c..0084ca97b 100644
--- a/server/core/runtime/env_step_runner_test.go
+++ b/server/core/runtime/env_step_runner_test.go
@@ -6,6 +6,7 @@ import (
"github.com/hashicorp/go-version"
"github.com/runatlantis/atlantis/server/core/runtime"
"github.com/runatlantis/atlantis/server/core/terraform/mocks"
+ "github.com/runatlantis/atlantis/server/events/command"
"github.com/runatlantis/atlantis/server/events/models"
"github.com/runatlantis/atlantis/server/logging"
@@ -50,7 +51,7 @@ func TestEnvStepRunner_Run(t *testing.T) {
t.Run(c.Command, func(t *testing.T) {
tmpDir, cleanup := TempDir(t)
defer cleanup()
- ctx := models.ProjectCommandContext{
+ ctx := command.ProjectContext{
BaseRepo: models.Repo{
Name: "basename",
Owner: "baseowner",
diff --git a/server/core/runtime/executor.go b/server/core/runtime/executor.go
index 1d73112eb..69b6bb78b 100644
--- a/server/core/runtime/executor.go
+++ b/server/core/runtime/executor.go
@@ -2,7 +2,7 @@ package runtime
import (
version "github.com/hashicorp/go-version"
- "github.com/runatlantis/atlantis/server/events/models"
+ "github.com/runatlantis/atlantis/server/events/command"
"github.com/runatlantis/atlantis/server/logging"
)
@@ -16,7 +16,7 @@ type VersionedExecutorWorkflow interface {
// Executor runs an executable with provided environment variables and arguments and returns stdout
type Executor interface {
- Run(ctx models.ProjectCommandContext, executablePath string, envs map[string]string, workdir string, extraArgs []string) (string, error)
+ Run(ctx command.ProjectContext, executablePath string, envs map[string]string, workdir string, extraArgs []string) (string, error)
}
// ExecutorVersionEnsurer ensures a given version exists and outputs a path to the executable
diff --git a/server/core/runtime/init_step_runner.go b/server/core/runtime/init_step_runner.go
index 55092b245..cd3ab3281 100644
--- a/server/core/runtime/init_step_runner.go
+++ b/server/core/runtime/init_step_runner.go
@@ -6,7 +6,7 @@ import (
version "github.com/hashicorp/go-version"
"github.com/runatlantis/atlantis/server/core/runtime/common"
- "github.com/runatlantis/atlantis/server/events/models"
+ "github.com/runatlantis/atlantis/server/events/command"
)
// InitStep runs `terraform init`.
@@ -15,7 +15,7 @@ type InitStepRunner struct {
DefaultTFVersion *version.Version
}
-func (i *InitStepRunner) Run(ctx models.ProjectCommandContext, extraArgs []string, path string, envs map[string]string) (string, error) {
+func (i *InitStepRunner) Run(ctx command.ProjectContext, extraArgs []string, path string, envs map[string]string) (string, error) {
lockFileName := ".terraform.lock.hcl"
terraformLockfilePath := filepath.Join(path, lockFileName)
terraformLockFileTracked, err := common.IsFileTracked(path, lockFileName)
diff --git a/server/core/runtime/init_step_runner_test.go b/server/core/runtime/init_step_runner_test.go
index a47c5da09..bdc2bacab 100644
--- a/server/core/runtime/init_step_runner_test.go
+++ b/server/core/runtime/init_step_runner_test.go
@@ -14,8 +14,8 @@ import (
"github.com/runatlantis/atlantis/server/core/runtime"
"github.com/runatlantis/atlantis/server/core/terraform/mocks"
matchers2 "github.com/runatlantis/atlantis/server/core/terraform/mocks/matchers"
+ "github.com/runatlantis/atlantis/server/events/command"
"github.com/runatlantis/atlantis/server/events/mocks/matchers"
- "github.com/runatlantis/atlantis/server/events/models"
"github.com/runatlantis/atlantis/server/logging"
. "github.com/runatlantis/atlantis/testing"
)
@@ -49,7 +49,7 @@ func TestRun_UsesGetOrInitForRightVersion(t *testing.T) {
terraform := mocks.NewMockClient()
logger := logging.NewNoopLogger(t)
- ctx := models.ProjectCommandContext{
+ ctx := command.ProjectContext{
Workspace: "workspace",
RepoRelDir: ".",
Log: logger,
@@ -92,7 +92,7 @@ func TestRun_ShowInitOutputOnError(t *testing.T) {
DefaultTFVersion: tfVersion,
}
- output, err := iso.Run(models.ProjectCommandContext{
+ output, err := iso.Run(command.ProjectContext{
Workspace: "workspace",
RepoRelDir: ".",
Log: logger,
@@ -114,7 +114,7 @@ func TestRun_InitOmitsUpgradeFlagIfLockFileTracked(t *testing.T) {
runCmd(t, repoDir, "git", "commit", "-m", "add .terraform.lock.hcl")
logger := logging.NewNoopLogger(t)
- ctx := models.ProjectCommandContext{
+ ctx := command.ProjectContext{
Workspace: "workspace",
RepoRelDir: ".",
Log: logger,
@@ -147,7 +147,7 @@ func TestRun_InitKeepsUpgradeFlagIfLockFileNotPresent(t *testing.T) {
RegisterMockTestingT(t)
terraform := mocks.NewMockClient()
logger := logging.NewNoopLogger(t)
- ctx := models.ProjectCommandContext{
+ ctx := command.ProjectContext{
Workspace: "workspace",
RepoRelDir: ".",
Log: logger,
@@ -181,7 +181,7 @@ func TestRun_InitKeepUpgradeFlagIfLockFilePresentAndTFLessThanPoint14(t *testing
terraform := mocks.NewMockClient()
logger := logging.NewNoopLogger(t)
- ctx := models.ProjectCommandContext{
+ ctx := command.ProjectContext{
Workspace: "workspace",
RepoRelDir: ".",
Log: logger,
@@ -248,7 +248,7 @@ func TestRun_InitExtraArgsDeDupe(t *testing.T) {
terraform := mocks.NewMockClient()
logger := logging.NewNoopLogger(t)
- ctx := models.ProjectCommandContext{
+ ctx := command.ProjectContext{
Workspace: "workspace",
RepoRelDir: ".",
Log: logger,
@@ -287,6 +287,7 @@ func TestRun_InitDeletesLockFileIfPresentAndNotTracked(t *testing.T) {
logger := logging.NewNoopLogger(t)
tfVersion, _ := version.NewVersion("0.14.0")
+
iso := runtime.InitStepRunner{
TerraformExecutor: terraform,
DefaultTFVersion: tfVersion,
@@ -294,7 +295,7 @@ func TestRun_InitDeletesLockFileIfPresentAndNotTracked(t *testing.T) {
When(terraform.RunCommandWithVersion(matchers.AnyModelsProjectCommandContext(), AnyString(), AnyStringSlice(), matchers2.AnyMapOfStringToString(), matchers2.AnyPtrToGoVersionVersion(), AnyString())).
ThenReturn("output", nil)
- ctx := models.ProjectCommandContext{
+ ctx := command.ProjectContext{
Workspace: "workspace",
RepoRelDir: ".",
Log: logger,
diff --git a/server/core/runtime/minimum_version_step_runner_delegate.go b/server/core/runtime/minimum_version_step_runner_delegate.go
index 0ec8acf15..f32e0cb42 100644
--- a/server/core/runtime/minimum_version_step_runner_delegate.go
+++ b/server/core/runtime/minimum_version_step_runner_delegate.go
@@ -5,7 +5,7 @@ import (
"github.com/hashicorp/go-version"
"github.com/pkg/errors"
- "github.com/runatlantis/atlantis/server/events/models"
+ "github.com/runatlantis/atlantis/server/events/command"
)
// MinimumVersionStepRunnerDelegate ensures that a given step runner can't run unless the command version being used
@@ -30,7 +30,7 @@ func NewMinimumVersionStepRunnerDelegate(minimumVersionStr string, defaultVersio
}, nil
}
-func (r *MinimumVersionStepRunnerDelegate) Run(ctx models.ProjectCommandContext, extraArgs []string, path string, envs map[string]string) (string, error) {
+func (r *MinimumVersionStepRunnerDelegate) Run(ctx command.ProjectContext, extraArgs []string, path string, envs map[string]string) (string, error) {
tfVersion := r.defaultTfVersion
if ctx.TerraformVersion != nil {
tfVersion = ctx.TerraformVersion
diff --git a/server/core/runtime/minimum_version_step_runner_delegate_test.go b/server/core/runtime/minimum_version_step_runner_delegate_test.go
index 5bcf7cedf..5b624446b 100644
--- a/server/core/runtime/minimum_version_step_runner_delegate_test.go
+++ b/server/core/runtime/minimum_version_step_runner_delegate_test.go
@@ -6,7 +6,7 @@ import (
"github.com/hashicorp/go-version"
. "github.com/petergtz/pegomock"
"github.com/runatlantis/atlantis/server/core/runtime/mocks"
- "github.com/runatlantis/atlantis/server/events/models"
+ "github.com/runatlantis/atlantis/server/events/command"
. "github.com/runatlantis/atlantis/testing"
)
@@ -32,7 +32,7 @@ func TestRunMinimumVersionDelegate(t *testing.T) {
delegate: mockDelegate,
}
- ctx := models.ProjectCommandContext{}
+ ctx := command.ProjectContext{}
When(mockDelegate.Run(ctx, extraArgs, path, envs)).ThenReturn(expectedOut, nil)
@@ -54,7 +54,7 @@ func TestRunMinimumVersionDelegate(t *testing.T) {
delegate: mockDelegate,
}
- ctx := models.ProjectCommandContext{
+ ctx := command.ProjectContext{
TerraformVersion: tfVersion12,
}
@@ -78,7 +78,7 @@ func TestRunMinimumVersionDelegate(t *testing.T) {
delegate: mockDelegate,
}
- ctx := models.ProjectCommandContext{}
+ ctx := command.ProjectContext{}
output, err := subject.Run(
ctx,
@@ -100,7 +100,7 @@ func TestRunMinimumVersionDelegate(t *testing.T) {
delegate: mockDelegate,
}
- ctx := models.ProjectCommandContext{
+ ctx := command.ProjectContext{
TerraformVersion: tfVersion11,
}
diff --git a/server/core/runtime/mocks/matchers/logging_simplelogging.go b/server/core/runtime/mocks/matchers/logging_simplelogging.go
index 502456e7c..c3b96f61f 100644
--- a/server/core/runtime/mocks/matchers/logging_simplelogging.go
+++ b/server/core/runtime/mocks/matchers/logging_simplelogging.go
@@ -2,9 +2,10 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+ "github.com/petergtz/pegomock"
+
logging "github.com/runatlantis/atlantis/server/logging"
)
diff --git a/server/core/runtime/mocks/matchers/map_of_string_to_string.go b/server/core/runtime/mocks/matchers/map_of_string_to_string.go
index 65175de1a..e1683b5df 100644
--- a/server/core/runtime/mocks/matchers/map_of_string_to_string.go
+++ b/server/core/runtime/mocks/matchers/map_of_string_to_string.go
@@ -2,8 +2,9 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+
+ "github.com/petergtz/pegomock"
)
func AnyMapOfStringToString() map[string]string {
diff --git a/server/core/runtime/mocks/matchers/models_approvalstatus.go b/server/core/runtime/mocks/matchers/models_approvalstatus.go
index 01b76dd96..e4ce9d9d7 100644
--- a/server/core/runtime/mocks/matchers/models_approvalstatus.go
+++ b/server/core/runtime/mocks/matchers/models_approvalstatus.go
@@ -2,9 +2,10 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+ "github.com/petergtz/pegomock"
+
models "github.com/runatlantis/atlantis/server/events/models"
)
diff --git a/server/core/runtime/mocks/matchers/models_projectcommandcontext.go b/server/core/runtime/mocks/matchers/models_projectcommandcontext.go
index 535f8b967..90db05bac 100644
--- a/server/core/runtime/mocks/matchers/models_projectcommandcontext.go
+++ b/server/core/runtime/mocks/matchers/models_projectcommandcontext.go
@@ -2,32 +2,32 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
- models "github.com/runatlantis/atlantis/server/events/models"
+ "github.com/petergtz/pegomock"
+ "github.com/runatlantis/atlantis/server/events/command"
)
-func AnyModelsProjectCommandContext() models.ProjectCommandContext {
- pegomock.RegisterMatcher(pegomock.NewAnyMatcher(reflect.TypeOf((*(models.ProjectCommandContext))(nil)).Elem()))
- var nullValue models.ProjectCommandContext
+func AnyModelsProjectCommandContext() command.ProjectContext {
+ pegomock.RegisterMatcher(pegomock.NewAnyMatcher(reflect.TypeOf((*(command.ProjectContext))(nil)).Elem()))
+ var nullValue command.ProjectContext
return nullValue
}
-func EqModelsProjectCommandContext(value models.ProjectCommandContext) models.ProjectCommandContext {
+func EqModelsProjectCommandContext(value command.ProjectContext) command.ProjectContext {
pegomock.RegisterMatcher(&pegomock.EqMatcher{Value: value})
- var nullValue models.ProjectCommandContext
+ var nullValue command.ProjectContext
return nullValue
}
-func NotEqModelsProjectCommandContext(value models.ProjectCommandContext) models.ProjectCommandContext {
+func NotEqModelsProjectCommandContext(value command.ProjectContext) command.ProjectContext {
pegomock.RegisterMatcher(&pegomock.NotEqMatcher{Value: value})
- var nullValue models.ProjectCommandContext
+ var nullValue command.ProjectContext
return nullValue
}
-func ModelsProjectCommandContextThat(matcher pegomock.ArgumentMatcher) models.ProjectCommandContext {
+func ModelsProjectCommandContextThat(matcher pegomock.ArgumentMatcher) command.ProjectContext {
pegomock.RegisterMatcher(matcher)
- var nullValue models.ProjectCommandContext
+ var nullValue command.ProjectContext
return nullValue
}
diff --git a/server/core/runtime/mocks/matchers/models_pullrequest.go b/server/core/runtime/mocks/matchers/models_pullrequest.go
index 9ae2a7e92..db2666f02 100644
--- a/server/core/runtime/mocks/matchers/models_pullrequest.go
+++ b/server/core/runtime/mocks/matchers/models_pullrequest.go
@@ -2,9 +2,10 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+ "github.com/petergtz/pegomock"
+
models "github.com/runatlantis/atlantis/server/events/models"
)
diff --git a/server/core/runtime/mocks/matchers/models_repo.go b/server/core/runtime/mocks/matchers/models_repo.go
index fd44665f8..2ca60819c 100644
--- a/server/core/runtime/mocks/matchers/models_repo.go
+++ b/server/core/runtime/mocks/matchers/models_repo.go
@@ -2,9 +2,10 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+ "github.com/petergtz/pegomock"
+
models "github.com/runatlantis/atlantis/server/events/models"
)
diff --git a/server/core/runtime/mocks/matchers/models_workflowhookcommandcontext.go b/server/core/runtime/mocks/matchers/models_workflowhookcommandcontext.go
index 18a5a5bae..b7f085915 100644
--- a/server/core/runtime/mocks/matchers/models_workflowhookcommandcontext.go
+++ b/server/core/runtime/mocks/matchers/models_workflowhookcommandcontext.go
@@ -2,9 +2,10 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+ "github.com/petergtz/pegomock"
+
models "github.com/runatlantis/atlantis/server/events/models"
)
diff --git a/server/core/runtime/mocks/matchers/ptr_to_go_version_version.go b/server/core/runtime/mocks/matchers/ptr_to_go_version_version.go
index bb596fe3d..038c5f8f1 100644
--- a/server/core/runtime/mocks/matchers/ptr_to_go_version_version.go
+++ b/server/core/runtime/mocks/matchers/ptr_to_go_version_version.go
@@ -2,9 +2,10 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+ "github.com/petergtz/pegomock"
+
go_version "github.com/hashicorp/go-version"
)
diff --git a/server/core/runtime/mocks/matchers/ptr_to_logging_simplelogger.go b/server/core/runtime/mocks/matchers/ptr_to_logging_simplelogger.go
index cf9bb5453..e7c8b942f 100644
--- a/server/core/runtime/mocks/matchers/ptr_to_logging_simplelogger.go
+++ b/server/core/runtime/mocks/matchers/ptr_to_logging_simplelogger.go
@@ -2,9 +2,10 @@
package matchers
import (
+ "reflect"
+
"github.com/petergtz/pegomock"
logging "github.com/runatlantis/atlantis/server/logging"
- "reflect"
)
func AnyPtrToLoggingSimpleLogger() logging.SimpleLogging {
diff --git a/server/core/runtime/mocks/matchers/slice_of_string.go b/server/core/runtime/mocks/matchers/slice_of_string.go
index f9281819d..8bfc2792f 100644
--- a/server/core/runtime/mocks/matchers/slice_of_string.go
+++ b/server/core/runtime/mocks/matchers/slice_of_string.go
@@ -2,8 +2,9 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+
+ "github.com/petergtz/pegomock"
)
func AnySliceOfString() []string {
diff --git a/server/core/runtime/mocks/mock_post_workflows_hook_runner.go b/server/core/runtime/mocks/mock_post_workflows_hook_runner.go
index 018a093dc..ef45221d0 100644
--- a/server/core/runtime/mocks/mock_post_workflows_hook_runner.go
+++ b/server/core/runtime/mocks/mock_post_workflows_hook_runner.go
@@ -4,10 +4,11 @@
package mocks
import (
- pegomock "github.com/petergtz/pegomock"
- models "github.com/runatlantis/atlantis/server/events/models"
"reflect"
"time"
+
+ pegomock "github.com/petergtz/pegomock"
+ models "github.com/runatlantis/atlantis/server/events/models"
)
type MockPostWorkflowHookRunner struct {
diff --git a/server/core/runtime/mocks/mock_pre_workflows_hook_runner.go b/server/core/runtime/mocks/mock_pre_workflows_hook_runner.go
index 41a0fd359..0753da0ff 100644
--- a/server/core/runtime/mocks/mock_pre_workflows_hook_runner.go
+++ b/server/core/runtime/mocks/mock_pre_workflows_hook_runner.go
@@ -4,10 +4,11 @@
package mocks
import (
- pegomock "github.com/petergtz/pegomock"
- models "github.com/runatlantis/atlantis/server/events/models"
"reflect"
"time"
+
+ pegomock "github.com/petergtz/pegomock"
+ models "github.com/runatlantis/atlantis/server/events/models"
)
type MockPreWorkflowHookRunner struct {
diff --git a/server/core/runtime/mocks/mock_pull_approved_checker.go b/server/core/runtime/mocks/mock_pull_approved_checker.go
index 39eeb6331..d2a2e3d46 100644
--- a/server/core/runtime/mocks/mock_pull_approved_checker.go
+++ b/server/core/runtime/mocks/mock_pull_approved_checker.go
@@ -4,10 +4,11 @@
package mocks
import (
- pegomock "github.com/petergtz/pegomock"
- models "github.com/runatlantis/atlantis/server/events/models"
"reflect"
"time"
+
+ pegomock "github.com/petergtz/pegomock"
+ models "github.com/runatlantis/atlantis/server/events/models"
)
type MockPullApprovedChecker struct {
diff --git a/server/core/runtime/mocks/mock_runner.go b/server/core/runtime/mocks/mock_runner.go
index f3d6534a4..46b944603 100644
--- a/server/core/runtime/mocks/mock_runner.go
+++ b/server/core/runtime/mocks/mock_runner.go
@@ -4,10 +4,11 @@
package mocks
import (
- pegomock "github.com/petergtz/pegomock"
- models "github.com/runatlantis/atlantis/server/events/models"
"reflect"
"time"
+
+ pegomock "github.com/petergtz/pegomock"
+ "github.com/runatlantis/atlantis/server/events/command"
)
type MockRunner struct {
@@ -25,7 +26,7 @@ func NewMockRunner(options ...pegomock.Option) *MockRunner {
func (mock *MockRunner) SetFailHandler(fh pegomock.FailHandler) { mock.fail = fh }
func (mock *MockRunner) FailHandler() pegomock.FailHandler { return mock.fail }
-func (mock *MockRunner) Run(ctx models.ProjectCommandContext, extraArgs []string, path string, envs map[string]string) (string, error) {
+func (mock *MockRunner) Run(ctx command.ProjectContext, extraArgs []string, path string, envs map[string]string) (string, error) {
if mock == nil {
panic("mock must not be nil. Use myMock := NewMockRunner().")
}
@@ -81,7 +82,7 @@ type VerifierMockRunner struct {
timeout time.Duration
}
-func (verifier *VerifierMockRunner) Run(ctx models.ProjectCommandContext, extraArgs []string, path string, envs map[string]string) *MockRunner_Run_OngoingVerification {
+func (verifier *VerifierMockRunner) Run(ctx command.ProjectContext, extraArgs []string, path string, envs map[string]string) *MockRunner_Run_OngoingVerification {
params := []pegomock.Param{ctx, extraArgs, path, envs}
methodInvocations := pegomock.GetGenericMockFrom(verifier.mock).Verify(verifier.inOrderContext, verifier.invocationCountMatcher, "Run", params, verifier.timeout)
return &MockRunner_Run_OngoingVerification{mock: verifier.mock, methodInvocations: methodInvocations}
@@ -92,17 +93,17 @@ type MockRunner_Run_OngoingVerification struct {
methodInvocations []pegomock.MethodInvocation
}
-func (c *MockRunner_Run_OngoingVerification) GetCapturedArguments() (models.ProjectCommandContext, []string, string, map[string]string) {
+func (c *MockRunner_Run_OngoingVerification) GetCapturedArguments() (command.ProjectContext, []string, string, map[string]string) {
ctx, extraArgs, path, envs := c.GetAllCapturedArguments()
return ctx[len(ctx)-1], extraArgs[len(extraArgs)-1], path[len(path)-1], envs[len(envs)-1]
}
-func (c *MockRunner_Run_OngoingVerification) GetAllCapturedArguments() (_param0 []models.ProjectCommandContext, _param1 [][]string, _param2 []string, _param3 []map[string]string) {
+func (c *MockRunner_Run_OngoingVerification) GetAllCapturedArguments() (_param0 []command.ProjectContext, _param1 [][]string, _param2 []string, _param3 []map[string]string) {
params := pegomock.GetGenericMockFrom(c.mock).GetInvocationParams(c.methodInvocations)
if len(params) > 0 {
- _param0 = make([]models.ProjectCommandContext, len(c.methodInvocations))
+ _param0 = make([]command.ProjectContext, len(c.methodInvocations))
for u, param := range params[0] {
- _param0[u] = param.(models.ProjectCommandContext)
+ _param0[u] = param.(command.ProjectContext)
}
_param1 = make([][]string, len(c.methodInvocations))
for u, param := range params[1] {
diff --git a/server/core/runtime/mocks/mock_versionedexecutorworkflow.go b/server/core/runtime/mocks/mock_versionedexecutorworkflow.go
index a2c7939da..b8b3e2ea3 100644
--- a/server/core/runtime/mocks/mock_versionedexecutorworkflow.go
+++ b/server/core/runtime/mocks/mock_versionedexecutorworkflow.go
@@ -4,12 +4,13 @@
package mocks
import (
+ "reflect"
+ "time"
+
go_version "github.com/hashicorp/go-version"
pegomock "github.com/petergtz/pegomock"
- models "github.com/runatlantis/atlantis/server/events/models"
+ "github.com/runatlantis/atlantis/server/events/command"
logging "github.com/runatlantis/atlantis/server/logging"
- "reflect"
- "time"
)
type MockVersionedExecutorWorkflow struct {
@@ -46,7 +47,7 @@ func (mock *MockVersionedExecutorWorkflow) EnsureExecutorVersion(log logging.Sim
return ret0, ret1
}
-func (mock *MockVersionedExecutorWorkflow) Run(ctx models.ProjectCommandContext, executablePath string, envs map[string]string, workdir string, extraArgs []string) (string, error) {
+func (mock *MockVersionedExecutorWorkflow) Run(ctx command.ProjectContext, executablePath string, envs map[string]string, workdir string, extraArgs []string) (string, error) {
if mock == nil {
panic("mock must not be nil. Use myMock := NewMockVersionedExecutorWorkflow().")
}
@@ -133,7 +134,7 @@ func (c *MockVersionedExecutorWorkflow_EnsureExecutorVersion_OngoingVerification
return
}
-func (verifier *VerifierMockVersionedExecutorWorkflow) Run(ctx models.ProjectCommandContext, executablePath string, envs map[string]string, workdir string, extraArgs []string) *MockVersionedExecutorWorkflow_Run_OngoingVerification {
+func (verifier *VerifierMockVersionedExecutorWorkflow) Run(ctx command.ProjectContext, executablePath string, envs map[string]string, workdir string, extraArgs []string) *MockVersionedExecutorWorkflow_Run_OngoingVerification {
params := []pegomock.Param{ctx, executablePath, envs, workdir, extraArgs}
methodInvocations := pegomock.GetGenericMockFrom(verifier.mock).Verify(verifier.inOrderContext, verifier.invocationCountMatcher, "Run", params, verifier.timeout)
return &MockVersionedExecutorWorkflow_Run_OngoingVerification{mock: verifier.mock, methodInvocations: methodInvocations}
@@ -144,17 +145,17 @@ type MockVersionedExecutorWorkflow_Run_OngoingVerification struct {
methodInvocations []pegomock.MethodInvocation
}
-func (c *MockVersionedExecutorWorkflow_Run_OngoingVerification) GetCapturedArguments() (models.ProjectCommandContext, string, map[string]string, string, []string) {
+func (c *MockVersionedExecutorWorkflow_Run_OngoingVerification) GetCapturedArguments() (command.ProjectContext, string, map[string]string, string, []string) {
ctx, executablePath, envs, workdir, extraArgs := c.GetAllCapturedArguments()
return ctx[len(ctx)-1], executablePath[len(executablePath)-1], envs[len(envs)-1], workdir[len(workdir)-1], extraArgs[len(extraArgs)-1]
}
-func (c *MockVersionedExecutorWorkflow_Run_OngoingVerification) GetAllCapturedArguments() (_param0 []models.ProjectCommandContext, _param1 []string, _param2 []map[string]string, _param3 []string, _param4 [][]string) {
+func (c *MockVersionedExecutorWorkflow_Run_OngoingVerification) GetAllCapturedArguments() (_param0 []command.ProjectContext, _param1 []string, _param2 []map[string]string, _param3 []string, _param4 [][]string) {
params := pegomock.GetGenericMockFrom(c.mock).GetInvocationParams(c.methodInvocations)
if len(params) > 0 {
- _param0 = make([]models.ProjectCommandContext, len(c.methodInvocations))
+ _param0 = make([]command.ProjectContext, len(c.methodInvocations))
for u, param := range params[0] {
- _param0[u] = param.(models.ProjectCommandContext)
+ _param0[u] = param.(command.ProjectContext)
}
_param1 = make([]string, len(c.methodInvocations))
for u, param := range params[1] {
diff --git a/server/core/runtime/models/mocks/matchers/map_of_string_to_string.go b/server/core/runtime/models/mocks/matchers/map_of_string_to_string.go
index 65175de1a..e1683b5df 100644
--- a/server/core/runtime/models/mocks/matchers/map_of_string_to_string.go
+++ b/server/core/runtime/models/mocks/matchers/map_of_string_to_string.go
@@ -2,8 +2,9 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+
+ "github.com/petergtz/pegomock"
)
func AnyMapOfStringToString() map[string]string {
diff --git a/server/core/runtime/models/mocks/matchers/models_filepath.go b/server/core/runtime/models/mocks/matchers/models_filepath.go
index 3d484539a..edcd2770a 100644
--- a/server/core/runtime/models/mocks/matchers/models_filepath.go
+++ b/server/core/runtime/models/mocks/matchers/models_filepath.go
@@ -2,9 +2,10 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+ "github.com/petergtz/pegomock"
+
models "github.com/runatlantis/atlantis/server/core/runtime/models"
)
diff --git a/server/core/runtime/models/mocks/matchers/slice_of_string.go b/server/core/runtime/models/mocks/matchers/slice_of_string.go
index f9281819d..8bfc2792f 100644
--- a/server/core/runtime/models/mocks/matchers/slice_of_string.go
+++ b/server/core/runtime/models/mocks/matchers/slice_of_string.go
@@ -2,8 +2,9 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+
+ "github.com/petergtz/pegomock"
)
func AnySliceOfString() []string {
diff --git a/server/core/runtime/models/mocks/mock_exec.go b/server/core/runtime/models/mocks/mock_exec.go
index 83da167ae..5b7816d4b 100644
--- a/server/core/runtime/models/mocks/mock_exec.go
+++ b/server/core/runtime/models/mocks/mock_exec.go
@@ -4,9 +4,10 @@
package mocks
import (
- pegomock "github.com/petergtz/pegomock"
"reflect"
"time"
+
+ pegomock "github.com/petergtz/pegomock"
)
type MockExec struct {
diff --git a/server/core/runtime/models/mocks/mock_filepath.go b/server/core/runtime/models/mocks/mock_filepath.go
index 8bbc61632..a54e1f8a2 100644
--- a/server/core/runtime/models/mocks/mock_filepath.go
+++ b/server/core/runtime/models/mocks/mock_filepath.go
@@ -4,10 +4,11 @@
package mocks
import (
- pegomock "github.com/petergtz/pegomock"
- models "github.com/runatlantis/atlantis/server/core/runtime/models"
"reflect"
"time"
+
+ pegomock "github.com/petergtz/pegomock"
+ models "github.com/runatlantis/atlantis/server/core/runtime/models"
)
type MockFilePath struct {
diff --git a/server/core/runtime/plan_step_runner.go b/server/core/runtime/plan_step_runner.go
index f7dba9402..a328c09da 100644
--- a/server/core/runtime/plan_step_runner.go
+++ b/server/core/runtime/plan_step_runner.go
@@ -9,6 +9,7 @@ import (
version "github.com/hashicorp/go-version"
"github.com/pkg/errors"
+ "github.com/runatlantis/atlantis/server/events/command"
"github.com/runatlantis/atlantis/server/events/models"
)
@@ -31,7 +32,7 @@ type PlanStepRunner struct {
AsyncTFExec AsyncTFExec
}
-func (p *PlanStepRunner) Run(ctx models.ProjectCommandContext, extraArgs []string, path string, envs map[string]string) (string, error) {
+func (p *PlanStepRunner) Run(ctx command.ProjectContext, extraArgs []string, path string, envs map[string]string) (string, error) {
tfVersion := p.DefaultTFVersion
if ctx.TerraformVersion != nil {
tfVersion = ctx.TerraformVersion
@@ -67,7 +68,7 @@ func (p *PlanStepRunner) isRemoteOpsErr(output string, err error) bool {
// remotePlan runs a terraform plan command compatible with TFE remote
// operations.
-func (p *PlanStepRunner) remotePlan(ctx models.ProjectCommandContext, extraArgs []string, path string, tfVersion *version.Version, planFile string, envs map[string]string) (string, error) {
+func (p *PlanStepRunner) remotePlan(ctx command.ProjectContext, extraArgs []string, path string, tfVersion *version.Version, planFile string, envs map[string]string) (string, error) {
argList := [][]string{
{"plan", "-input=false", "-refresh"},
extraArgs,
@@ -101,7 +102,7 @@ func (p *PlanStepRunner) remotePlan(ctx models.ProjectCommandContext, extraArgs
// switchWorkspace changes the terraform workspace if necessary and will create
// it if it doesn't exist. It handles differences between versions.
-func (p *PlanStepRunner) switchWorkspace(ctx models.ProjectCommandContext, path string, tfVersion *version.Version, envs map[string]string) error {
+func (p *PlanStepRunner) switchWorkspace(ctx command.ProjectContext, path string, tfVersion *version.Version, envs map[string]string) error {
// In versions less than 0.9 there is no support for workspaces.
noWorkspaceSupport := MustConstraint("<0.9").Check(tfVersion)
// If the user tried to set a specific workspace in the comment but their
@@ -151,7 +152,7 @@ func (p *PlanStepRunner) switchWorkspace(ctx models.ProjectCommandContext, path
return nil
}
-func (p *PlanStepRunner) buildPlanCmd(ctx models.ProjectCommandContext, extraArgs []string, path string, tfVersion *version.Version, planFile string) []string {
+func (p *PlanStepRunner) buildPlanCmd(ctx command.ProjectContext, extraArgs []string, path string, tfVersion *version.Version, planFile string) []string {
tfVars := p.tfVars(ctx, tfVersion)
// Check if env/{workspace}.tfvars exist and include it. This is a use-case
@@ -185,7 +186,7 @@ func (p *PlanStepRunner) buildPlanCmd(ctx models.ProjectCommandContext, extraArg
// those versions don't allow setting -var flags for any variables that aren't
// actually used in the configuration. Since there's no way for us to detect
// if the configuration is using those variables, we don't set them.
-func (p *PlanStepRunner) tfVars(ctx models.ProjectCommandContext, tfVersion *version.Version) []string {
+func (p *PlanStepRunner) tfVars(ctx command.ProjectContext, tfVersion *version.Version) []string {
if tfVersion.GreaterThanOrEqual(version.Must(version.NewVersion("0.12.0"))) {
return nil
}
@@ -237,7 +238,7 @@ func (p *PlanStepRunner) fmtPlanOutput(output string, tfVersion *version.Version
// cmdArgs is the args to terraform to execute.
// path is the path to where we need to execute.
func (p *PlanStepRunner) runRemotePlan(
- ctx models.ProjectCommandContext,
+ ctx command.ProjectContext,
cmdArgs []string,
path string,
tfVersion *version.Version,
@@ -245,7 +246,7 @@ func (p *PlanStepRunner) runRemotePlan(
// updateStatusF will update the commit status and log any error.
updateStatusF := func(status models.CommitStatus, url string) {
- if err := p.CommitStatusUpdater.UpdateProject(ctx, models.PlanCommand, status, url); err != nil {
+ if err := p.CommitStatusUpdater.UpdateProject(ctx, command.Plan, status, url); err != nil {
ctx.Log.Err("unable to update status: %s", err)
}
}
diff --git a/server/core/runtime/plan_step_runner_test.go b/server/core/runtime/plan_step_runner_test.go
index 1f609fc02..3db351449 100644
--- a/server/core/runtime/plan_step_runner_test.go
+++ b/server/core/runtime/plan_step_runner_test.go
@@ -9,6 +9,7 @@ import (
"github.com/hashicorp/go-version"
"github.com/runatlantis/atlantis/server/core/terraform"
+ "github.com/runatlantis/atlantis/server/events/command"
mocks2 "github.com/runatlantis/atlantis/server/events/mocks"
. "github.com/petergtz/pegomock"
@@ -32,7 +33,7 @@ func TestRun_NoWorkspaceIn08(t *testing.T) {
workspace := "default"
logger := logging.NewNoopLogger(t)
- ctx := models.ProjectCommandContext{
+ ctx := command.ProjectContext{
Log: logger,
EscapedCommentArgs: []string{"comment", "args"},
Workspace: workspace,
@@ -119,7 +120,7 @@ func TestRun_ErrWorkspaceIn08(t *testing.T) {
When(terraform.RunCommandWithVersion(matchers.AnyModelsProjectCommandContext(), AnyString(), AnyStringSlice(), matchers2.AnyMapOfStringToString(), matchers2.AnyPtrToGoVersionVersion(), AnyString())).
ThenReturn("output", nil)
- _, err := s.Run(models.ProjectCommandContext{
+ _, err := s.Run(command.ProjectContext{
Log: logger,
Workspace: workspace,
RepoRelDir: ".",
@@ -159,7 +160,7 @@ func TestRun_SwitchesWorkspace(t *testing.T) {
tfVersion, _ := version.NewVersion(c.tfVersion)
logger := logging.NewNoopLogger(t)
- ctx := models.ProjectCommandContext{
+ ctx := command.ProjectContext{
Log: logger,
Workspace: "workspace",
RepoRelDir: ".",
@@ -253,7 +254,7 @@ func TestRun_CreatesWorkspace(t *testing.T) {
terraform := mocks.NewMockClient()
tfVersion, _ := version.NewVersion(c.tfVersion)
logger := logging.NewNoopLogger(t)
- ctx := models.ProjectCommandContext{
+ ctx := command.ProjectContext{
Log: logger,
Workspace: "workspace",
RepoRelDir: ".",
@@ -319,7 +320,7 @@ func TestRun_NoWorkspaceSwitchIfNotNecessary(t *testing.T) {
terraform := mocks.NewMockClient()
tfVersion, _ := version.NewVersion("0.10.0")
logger := logging.NewNoopLogger(t)
- ctx := models.ProjectCommandContext{
+ ctx := command.ProjectContext{
Log: logger,
Workspace: "workspace",
RepoRelDir: ".",
@@ -415,7 +416,7 @@ func TestRun_AddsEnvVarFile(t *testing.T) {
"-var-file",
envVarsFile,
}
- ctx := models.ProjectCommandContext{
+ ctx := command.ProjectContext{
Log: logger,
Workspace: "workspace",
RepoRelDir: ".",
@@ -452,7 +453,7 @@ func TestRun_UsesDiffPathForProject(t *testing.T) {
TerraformExecutor: terraform,
DefaultTFVersion: tfVersion,
}
- ctx := models.ProjectCommandContext{
+ ctx := command.ProjectContext{
Log: logger,
Workspace: "default",
RepoRelDir: ".",
@@ -551,7 +552,7 @@ Terraform will perform the following actions:
return []ReturnValue{"", errors.New("unexpected call to RunCommandWithVersion")}
}
})
- actOutput, err := s.Run(models.ProjectCommandContext{Workspace: "default"}, nil, "", map[string]string(nil))
+ actOutput, err := s.Run(command.ProjectContext{Workspace: "default"}, nil, "", map[string]string(nil))
Ok(t, err)
Equals(t, `
An execution plan has been generated and is shown below.
@@ -605,7 +606,7 @@ func TestRun_OutputOnErr(t *testing.T) {
return []ReturnValue{"", errors.New("unexpected call to RunCommandWithVersion")}
}
})
- actOutput, actErr := s.Run(models.ProjectCommandContext{Workspace: "default"}, nil, "", map[string]string(nil))
+ actOutput, actErr := s.Run(command.ProjectContext{Workspace: "default"}, nil, "", map[string]string(nil))
ErrEquals(t, expErrMsg, actErr)
Equals(t, expOutput, actOutput)
}
@@ -658,7 +659,7 @@ func TestRun_NoOptionalVarsIn012(t *testing.T) {
TerraformExecutor: terraform,
DefaultTFVersion: tfVersion,
}
- ctx := models.ProjectCommandContext{
+ ctx := command.ProjectContext{
Workspace: "default",
RepoRelDir: ".",
User: models.User{Username: "username"},
@@ -704,7 +705,7 @@ locally at this time.
logger := logging.NewNoopLogger(t)
// Now that mocking is set up, we're ready to run the plan.
- ctx := models.ProjectCommandContext{
+ ctx := command.ProjectContext{
Log: logger,
Workspace: "default",
RepoRelDir: ".",
@@ -806,8 +807,8 @@ Plan: 0 to add, 0 to change, 1 to destroy.`, string(bytes))
// Ensure that the status was updated with the runURL.
runURL := "https://app.terraform.io/app/lkysow-enterprises/atlantis-tfe-test/runs/run-is4oVvJfrkud1KvE"
- updater.VerifyWasCalledOnce().UpdateProject(ctx, models.PlanCommand, models.PendingCommitStatus, runURL)
- updater.VerifyWasCalledOnce().UpdateProject(ctx, models.PlanCommand, models.SuccessCommitStatus, runURL)
+ updater.VerifyWasCalledOnce().UpdateProject(ctx, command.Plan, models.PendingCommitStatus, runURL)
+ updater.VerifyWasCalledOnce().UpdateProject(ctx, command.Plan, models.SuccessCommitStatus, runURL)
})
}
}
@@ -884,7 +885,7 @@ type remotePlanMock struct {
CalledArgs []string
}
-func (r *remotePlanMock) RunCommandAsync(ctx models.ProjectCommandContext, path string, args []string, envs map[string]string, v *version.Version, workspace string) (chan<- string, <-chan terraform.Line) {
+func (r *remotePlanMock) RunCommandAsync(ctx command.ProjectContext, path string, args []string, envs map[string]string, v *version.Version, workspace string) (chan<- string, <-chan terraform.Line) {
r.CalledArgs = args
in := make(chan string)
out := make(chan terraform.Line)
diff --git a/server/core/runtime/plan_type_step_runner_delegate.go b/server/core/runtime/plan_type_step_runner_delegate.go
index d2cef7a2d..f288d4d41 100644
--- a/server/core/runtime/plan_type_step_runner_delegate.go
+++ b/server/core/runtime/plan_type_step_runner_delegate.go
@@ -5,13 +5,13 @@ import (
"path/filepath"
"github.com/pkg/errors"
- "github.com/runatlantis/atlantis/server/events/models"
+ "github.com/runatlantis/atlantis/server/events/command"
)
// NullRunner is a runner that isn't configured for a given plan type but outputs nothing
type NullRunner struct{}
-func (p NullRunner) Run(ctx models.ProjectCommandContext, extraArgs []string, path string, envs map[string]string) (string, error) {
+func (p NullRunner) Run(ctx command.ProjectContext, extraArgs []string, path string, envs map[string]string) (string, error) {
ctx.Log.Debug("runner not configured for plan type")
return "", nil
@@ -20,7 +20,7 @@ func (p NullRunner) Run(ctx models.ProjectCommandContext, extraArgs []string, pa
// RemoteBackendUnsupportedRunner is a runner that is responsible for outputting that the remote backend is unsupported
type RemoteBackendUnsupportedRunner struct{}
-func (p RemoteBackendUnsupportedRunner) Run(ctx models.ProjectCommandContext, extraArgs []string, path string, envs map[string]string) (string, error) {
+func (p RemoteBackendUnsupportedRunner) Run(ctx command.ProjectContext, extraArgs []string, path string, envs map[string]string) (string, error) {
ctx.Log.Debug("runner not configured for remote backend")
return "Remote backend is unsupported for this step.", nil
@@ -49,7 +49,7 @@ func (p *PlanTypeStepRunnerDelegate) isRemotePlan(planFile string) (bool, error)
return IsRemotePlan(data), nil
}
-func (p *PlanTypeStepRunnerDelegate) Run(ctx models.ProjectCommandContext, extraArgs []string, path string, envs map[string]string) (string, error) {
+func (p *PlanTypeStepRunnerDelegate) Run(ctx command.ProjectContext, extraArgs []string, path string, envs map[string]string) (string, error) {
planFile := filepath.Join(path, GetPlanFilename(ctx.Workspace, ctx.ProjectName))
remotePlan, err := p.isRemotePlan(planFile)
diff --git a/server/core/runtime/plan_type_step_runner_delegate_test.go b/server/core/runtime/plan_type_step_runner_delegate_test.go
index 189f171de..6645fd995 100644
--- a/server/core/runtime/plan_type_step_runner_delegate_test.go
+++ b/server/core/runtime/plan_type_step_runner_delegate_test.go
@@ -11,7 +11,7 @@ import (
. "github.com/runatlantis/atlantis/testing"
"github.com/runatlantis/atlantis/server/core/runtime/mocks"
- "github.com/runatlantis/atlantis/server/events/models"
+ "github.com/runatlantis/atlantis/server/events/command"
)
var planFileContents = `
@@ -47,7 +47,7 @@ func TestRunDelegate(t *testing.T) {
err := os.WriteFile(planPath, []byte("Atlantis: this plan was created by remote ops\n"+planFileContents), 0600)
Ok(t, err)
- ctx := models.ProjectCommandContext{
+ ctx := command.ProjectContext{
Workspace: "workspace",
RepoRelDir: ".",
EscapedCommentArgs: []string{"comment", "args"},
@@ -76,7 +76,7 @@ func TestRunDelegate(t *testing.T) {
err := os.WriteFile(planPath, []byte("Atlantis: this plan was created by remote ops\n"+planFileContents), 0600)
Ok(t, err)
- ctx := models.ProjectCommandContext{
+ ctx := command.ProjectContext{
Workspace: "workspace",
RepoRelDir: ".",
EscapedCommentArgs: []string{"comment", "args"},
@@ -105,7 +105,7 @@ func TestRunDelegate(t *testing.T) {
err := os.WriteFile(planPath, []byte(planFileContents), 0600)
Ok(t, err)
- ctx := models.ProjectCommandContext{
+ ctx := command.ProjectContext{
Workspace: "workspace",
RepoRelDir: ".",
EscapedCommentArgs: []string{"comment", "args"},
@@ -134,7 +134,7 @@ func TestRunDelegate(t *testing.T) {
err := os.WriteFile(planPath, []byte(planFileContents), 0600)
Ok(t, err)
- ctx := models.ProjectCommandContext{
+ ctx := command.ProjectContext{
Workspace: "workspace",
RepoRelDir: ".",
EscapedCommentArgs: []string{"comment", "args"},
diff --git a/server/core/runtime/policy/conftest_client.go b/server/core/runtime/policy/conftest_client.go
index aa3d83ea4..16a932977 100644
--- a/server/core/runtime/policy/conftest_client.go
+++ b/server/core/runtime/policy/conftest_client.go
@@ -13,7 +13,7 @@ import (
"github.com/runatlantis/atlantis/server/core/runtime/cache"
runtime_models "github.com/runatlantis/atlantis/server/core/runtime/models"
"github.com/runatlantis/atlantis/server/core/terraform"
- "github.com/runatlantis/atlantis/server/events/models"
+ "github.com/runatlantis/atlantis/server/events/command"
"github.com/runatlantis/atlantis/server/logging"
)
@@ -159,7 +159,7 @@ func NewConfTestExecutorWorkflow(log logging.SimpleLogging, versionRootDir strin
}
}
-func (c *ConfTestExecutorWorkflow) Run(ctx models.ProjectCommandContext, executablePath string, envs map[string]string, workdir string, extraArgs []string) (string, error) {
+func (c *ConfTestExecutorWorkflow) Run(ctx command.ProjectContext, executablePath string, envs map[string]string, workdir string, extraArgs []string) (string, error) {
policyArgs := []Arg{}
policySetNames := []string{}
ctx.Log.Debug("policy sets, %s ", ctx.PolicySets)
diff --git a/server/core/runtime/policy/conftest_client_test.go b/server/core/runtime/policy/conftest_client_test.go
index c08a7360f..5251fcc63 100644
--- a/server/core/runtime/policy/conftest_client_test.go
+++ b/server/core/runtime/policy/conftest_client_test.go
@@ -15,7 +15,7 @@ import (
models_mocks "github.com/runatlantis/atlantis/server/core/runtime/models/mocks"
conftest_mocks "github.com/runatlantis/atlantis/server/core/runtime/policy/mocks"
terraform_mocks "github.com/runatlantis/atlantis/server/core/terraform/mocks"
- "github.com/runatlantis/atlantis/server/events/models"
+ "github.com/runatlantis/atlantis/server/events/command"
"github.com/runatlantis/atlantis/server/logging"
. "github.com/runatlantis/atlantis/testing"
)
@@ -159,7 +159,7 @@ func TestRun(t *testing.T) {
Name: policySetName2,
}
- ctx := models.ProjectCommandContext{
+ ctx := command.ProjectContext{
PolicySets: valid.PolicySets{
PolicySets: []valid.PolicySet{
policySet1,
diff --git a/server/core/runtime/policy/mocks/matchers/valid_policyset.go b/server/core/runtime/policy/mocks/matchers/valid_policyset.go
index 4b2d633e0..6a45c052d 100644
--- a/server/core/runtime/policy/mocks/matchers/valid_policyset.go
+++ b/server/core/runtime/policy/mocks/matchers/valid_policyset.go
@@ -2,9 +2,10 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+ "github.com/petergtz/pegomock"
+
valid "github.com/runatlantis/atlantis/server/core/config/valid"
)
diff --git a/server/core/runtime/policy/mocks/mock_conftest_client.go b/server/core/runtime/policy/mocks/mock_conftest_client.go
index 7b461634c..08cf94cd4 100644
--- a/server/core/runtime/policy/mocks/mock_conftest_client.go
+++ b/server/core/runtime/policy/mocks/mock_conftest_client.go
@@ -4,10 +4,11 @@
package mocks
import (
- pegomock "github.com/petergtz/pegomock"
- valid "github.com/runatlantis/atlantis/server/core/config/valid"
"reflect"
"time"
+
+ pegomock "github.com/petergtz/pegomock"
+ valid "github.com/runatlantis/atlantis/server/core/config/valid"
)
type MockSourceResolver struct {
diff --git a/server/core/runtime/policy_check_step_runner.go b/server/core/runtime/policy_check_step_runner.go
index 09321dd23..41677ff73 100644
--- a/server/core/runtime/policy_check_step_runner.go
+++ b/server/core/runtime/policy_check_step_runner.go
@@ -3,7 +3,7 @@ package runtime
import (
"github.com/hashicorp/go-version"
"github.com/pkg/errors"
- "github.com/runatlantis/atlantis/server/events/models"
+ "github.com/runatlantis/atlantis/server/events/command"
)
// PolicyCheckStepRunner runs a policy check command given a ctx
@@ -27,7 +27,7 @@ func NewPolicyCheckStepRunner(defaultTfVersion *version.Version, executorWorkflo
}
// Run ensures a given version for the executable, builds the args from the project context and then runs executable returning the result
-func (p *PolicyCheckStepRunner) Run(ctx models.ProjectCommandContext, extraArgs []string, path string, envs map[string]string) (string, error) {
+func (p *PolicyCheckStepRunner) Run(ctx command.ProjectContext, extraArgs []string, path string, envs map[string]string) (string, error) {
executable, err := p.versionEnsurer.EnsureExecutorVersion(ctx.Log, ctx.PolicySets.Version)
if err != nil {
diff --git a/server/core/runtime/policy_check_step_runner_test.go b/server/core/runtime/policy_check_step_runner_test.go
index daea0bcc0..3562371cf 100644
--- a/server/core/runtime/policy_check_step_runner_test.go
+++ b/server/core/runtime/policy_check_step_runner_test.go
@@ -8,6 +8,7 @@ import (
. "github.com/petergtz/pegomock"
"github.com/runatlantis/atlantis/server/core/config/valid"
"github.com/runatlantis/atlantis/server/core/runtime/mocks"
+ "github.com/runatlantis/atlantis/server/events/command"
"github.com/runatlantis/atlantis/server/events/models"
"github.com/runatlantis/atlantis/server/logging"
. "github.com/runatlantis/atlantis/testing"
@@ -21,7 +22,7 @@ func TestRun(t *testing.T) {
workdir := "/path"
executablePath := "some/path/conftest"
- context := models.ProjectCommandContext{
+ context := command.ProjectContext{
Log: logger,
EscapedCommentArgs: []string{"comment", "args"},
Workspace: workspace,
diff --git a/server/core/runtime/run_step_runner.go b/server/core/runtime/run_step_runner.go
index 485b71cf7..6a7673bf3 100644
--- a/server/core/runtime/run_step_runner.go
+++ b/server/core/runtime/run_step_runner.go
@@ -8,7 +8,7 @@ import (
"strings"
"github.com/hashicorp/go-version"
- "github.com/runatlantis/atlantis/server/events/models"
+ "github.com/runatlantis/atlantis/server/events/command"
)
// RunStepRunner runs custom commands.
@@ -19,7 +19,7 @@ type RunStepRunner struct {
TerraformBinDir string
}
-func (r *RunStepRunner) Run(ctx models.ProjectCommandContext, command string, path string, envs map[string]string) (string, error) {
+func (r *RunStepRunner) Run(ctx command.ProjectContext, command string, path string, envs map[string]string) (string, error) {
tfVersion := r.DefaultTFVersion
if ctx.TerraformVersion != nil {
tfVersion = ctx.TerraformVersion
diff --git a/server/core/runtime/run_step_runner_test.go b/server/core/runtime/run_step_runner_test.go
index be6d4642a..8536a331e 100644
--- a/server/core/runtime/run_step_runner_test.go
+++ b/server/core/runtime/run_step_runner_test.go
@@ -11,6 +11,7 @@ import (
"github.com/runatlantis/atlantis/server/core/runtime"
"github.com/runatlantis/atlantis/server/core/terraform/mocks"
matchers2 "github.com/runatlantis/atlantis/server/core/terraform/mocks/matchers"
+ "github.com/runatlantis/atlantis/server/events/command"
"github.com/runatlantis/atlantis/server/events/mocks/matchers"
"github.com/runatlantis/atlantis/server/events/models"
"github.com/runatlantis/atlantis/server/logging"
@@ -112,7 +113,7 @@ func TestRunStepRunner_Run(t *testing.T) {
t.Run(c.Command, func(t *testing.T) {
tmpDir, cleanup := TempDir(t)
defer cleanup()
- ctx := models.ProjectCommandContext{
+ ctx := command.ProjectContext{
BaseRepo: models.Repo{
Name: "basename",
Owner: "baseowner",
diff --git a/server/core/runtime/runtime.go b/server/core/runtime/runtime.go
index 7e35e0762..7bd575308 100644
--- a/server/core/runtime/runtime.go
+++ b/server/core/runtime/runtime.go
@@ -11,6 +11,7 @@ import (
version "github.com/hashicorp/go-version"
"github.com/pkg/errors"
"github.com/runatlantis/atlantis/server/core/terraform"
+ "github.com/runatlantis/atlantis/server/events/command"
"github.com/runatlantis/atlantis/server/events/models"
"github.com/runatlantis/atlantis/server/logging"
)
@@ -25,7 +26,7 @@ const (
// TerraformExec brings the interface from TerraformClient into this package
// without causing circular imports.
type TerraformExec interface {
- RunCommandWithVersion(ctx models.ProjectCommandContext, path string, args []string, envs map[string]string, v *version.Version, workspace string) (string, error)
+ RunCommandWithVersion(ctx command.ProjectContext, path string, args []string, envs map[string]string, v *version.Version, workspace string) (string, error)
EnsureVersion(log logging.SimpleLogging, v *version.Version) error
}
@@ -40,19 +41,19 @@ type AsyncTFExec interface {
// Callers can use the input channel to pass stdin input to the command.
// If any error is passed on the out channel, there will be no
// further output (so callers are free to exit).
- RunCommandAsync(ctx models.ProjectCommandContext, path string, args []string, envs map[string]string, v *version.Version, workspace string) (chan<- string, <-chan terraform.Line)
+ RunCommandAsync(ctx command.ProjectContext, path string, args []string, envs map[string]string, v *version.Version, workspace string) (chan<- string, <-chan terraform.Line)
}
// StatusUpdater brings the interface from CommitStatusUpdater into this package
// without causing circular imports.
type StatusUpdater interface {
- UpdateProject(ctx models.ProjectCommandContext, cmdName models.CommandName, status models.CommitStatus, url string) error
+ UpdateProject(ctx command.ProjectContext, cmdName command.Name, status models.CommitStatus, url string) error
}
//go:generate pegomock generate -m --use-experimental-model-gen --package mocks -o mocks/mock_runner.go Runner
// Runner mirrors events.StepRunner as a way to bring it into this package
type Runner interface {
- Run(ctx models.ProjectCommandContext, extraArgs []string, path string, envs map[string]string) (string, error)
+ Run(ctx command.ProjectContext, extraArgs []string, path string, envs map[string]string) (string, error)
}
// MustConstraint returns a constraint. It panics on error.
diff --git a/server/core/runtime/show_step_runner.go b/server/core/runtime/show_step_runner.go
index 46b9b3aae..266ae9bb1 100644
--- a/server/core/runtime/show_step_runner.go
+++ b/server/core/runtime/show_step_runner.go
@@ -6,7 +6,7 @@ import (
"github.com/hashicorp/go-version"
"github.com/pkg/errors"
- "github.com/runatlantis/atlantis/server/events/models"
+ "github.com/runatlantis/atlantis/server/events/command"
)
const minimumShowTfVersion string = "0.12.0"
@@ -29,7 +29,7 @@ type ShowStepRunner struct {
DefaultTFVersion *version.Version
}
-func (p *ShowStepRunner) Run(ctx models.ProjectCommandContext, extraArgs []string, path string, envs map[string]string) (string, error) {
+func (p *ShowStepRunner) Run(ctx command.ProjectContext, extraArgs []string, path string, envs map[string]string) (string, error) {
tfVersion := p.DefaultTFVersion
if ctx.TerraformVersion != nil {
tfVersion = ctx.TerraformVersion
diff --git a/server/core/runtime/show_step_runner_test.go b/server/core/runtime/show_step_runner_test.go
index 3ff1a5de0..8d2909733 100644
--- a/server/core/runtime/show_step_runner_test.go
+++ b/server/core/runtime/show_step_runner_test.go
@@ -10,7 +10,7 @@ import (
"github.com/hashicorp/go-version"
. "github.com/petergtz/pegomock"
"github.com/runatlantis/atlantis/server/core/terraform/mocks"
- "github.com/runatlantis/atlantis/server/events/models"
+ "github.com/runatlantis/atlantis/server/events/command"
"github.com/runatlantis/atlantis/server/logging"
. "github.com/runatlantis/atlantis/testing"
)
@@ -21,7 +21,7 @@ func TestShowStepRunnner(t *testing.T) {
resultPath := filepath.Join(path, "test-default.json")
envs := map[string]string{"key": "val"}
tfVersion, _ := version.NewVersion("0.12")
- context := models.ProjectCommandContext{
+ context := command.ProjectContext{
Workspace: "default",
ProjectName: "test",
Log: logger,
@@ -58,7 +58,7 @@ func TestShowStepRunnner(t *testing.T) {
v, _ := version.NewVersion("0.13.0")
- contextWithVersionOverride := models.ProjectCommandContext{
+ contextWithVersionOverride := command.ProjectContext{
Workspace: "default",
ProjectName: "test",
Log: logger,
diff --git a/server/core/runtime/version_step_runner.go b/server/core/runtime/version_step_runner.go
index a7369af7c..8485e1230 100644
--- a/server/core/runtime/version_step_runner.go
+++ b/server/core/runtime/version_step_runner.go
@@ -4,7 +4,7 @@ import (
"path/filepath"
"github.com/hashicorp/go-version"
- "github.com/runatlantis/atlantis/server/events/models"
+ "github.com/runatlantis/atlantis/server/events/command"
)
// VersionStepRunner runs a version command given a ctx
@@ -14,7 +14,7 @@ type VersionStepRunner struct {
}
// Run ensures a given version for the executable, builds the args from the project context and then runs executable returning the result
-func (v *VersionStepRunner) Run(ctx models.ProjectCommandContext, extraArgs []string, path string, envs map[string]string) (string, error) {
+func (v *VersionStepRunner) Run(ctx command.ProjectContext, extraArgs []string, path string, envs map[string]string) (string, error) {
tfVersion := v.DefaultTFVersion
if ctx.TerraformVersion != nil {
tfVersion = ctx.TerraformVersion
diff --git a/server/core/runtime/version_step_runner_test.go b/server/core/runtime/version_step_runner_test.go
index 797e4ba6c..ea20cf45e 100644
--- a/server/core/runtime/version_step_runner_test.go
+++ b/server/core/runtime/version_step_runner_test.go
@@ -6,6 +6,7 @@ import (
"github.com/hashicorp/go-version"
. "github.com/petergtz/pegomock"
"github.com/runatlantis/atlantis/server/core/terraform/mocks"
+ "github.com/runatlantis/atlantis/server/events/command"
"github.com/runatlantis/atlantis/server/events/models"
"github.com/runatlantis/atlantis/server/logging"
. "github.com/runatlantis/atlantis/testing"
@@ -16,7 +17,7 @@ func TestRunVersionStep(t *testing.T) {
logger := logging.NewNoopLogger(t)
workspace := "default"
- context := models.ProjectCommandContext{
+ context := command.ProjectContext{
Log: logger,
EscapedCommentArgs: []string{"comment", "args"},
Workspace: workspace,
diff --git a/server/core/terraform/mocks/matchers/go_getter_clientoption.go b/server/core/terraform/mocks/matchers/go_getter_clientoption.go
index c6a41e3bd..7cf1a3365 100644
--- a/server/core/terraform/mocks/matchers/go_getter_clientoption.go
+++ b/server/core/terraform/mocks/matchers/go_getter_clientoption.go
@@ -2,9 +2,10 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+ "github.com/petergtz/pegomock"
+
go_getter "github.com/hashicorp/go-getter"
)
diff --git a/server/core/terraform/mocks/matchers/logging_simplelogging.go b/server/core/terraform/mocks/matchers/logging_simplelogging.go
index 502456e7c..c3b96f61f 100644
--- a/server/core/terraform/mocks/matchers/logging_simplelogging.go
+++ b/server/core/terraform/mocks/matchers/logging_simplelogging.go
@@ -2,9 +2,10 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+ "github.com/petergtz/pegomock"
+
logging "github.com/runatlantis/atlantis/server/logging"
)
diff --git a/server/core/terraform/mocks/matchers/map_of_string_to_string.go b/server/core/terraform/mocks/matchers/map_of_string_to_string.go
index 65175de1a..e1683b5df 100644
--- a/server/core/terraform/mocks/matchers/map_of_string_to_string.go
+++ b/server/core/terraform/mocks/matchers/map_of_string_to_string.go
@@ -2,8 +2,9 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+
+ "github.com/petergtz/pegomock"
)
func AnyMapOfStringToString() map[string]string {
diff --git a/server/core/terraform/mocks/matchers/ptr_to_go_version_version.go b/server/core/terraform/mocks/matchers/ptr_to_go_version_version.go
index bb596fe3d..038c5f8f1 100644
--- a/server/core/terraform/mocks/matchers/ptr_to_go_version_version.go
+++ b/server/core/terraform/mocks/matchers/ptr_to_go_version_version.go
@@ -2,9 +2,10 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+ "github.com/petergtz/pegomock"
+
go_version "github.com/hashicorp/go-version"
)
diff --git a/server/core/terraform/mocks/matchers/ptr_to_logging_simplelogger.go b/server/core/terraform/mocks/matchers/ptr_to_logging_simplelogger.go
index cf9bb5453..e7c8b942f 100644
--- a/server/core/terraform/mocks/matchers/ptr_to_logging_simplelogger.go
+++ b/server/core/terraform/mocks/matchers/ptr_to_logging_simplelogger.go
@@ -2,9 +2,10 @@
package matchers
import (
+ "reflect"
+
"github.com/petergtz/pegomock"
logging "github.com/runatlantis/atlantis/server/logging"
- "reflect"
)
func AnyPtrToLoggingSimpleLogger() logging.SimpleLogging {
diff --git a/server/core/terraform/mocks/matchers/slice_of_string.go b/server/core/terraform/mocks/matchers/slice_of_string.go
index f9281819d..8bfc2792f 100644
--- a/server/core/terraform/mocks/matchers/slice_of_string.go
+++ b/server/core/terraform/mocks/matchers/slice_of_string.go
@@ -2,8 +2,9 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+
+ "github.com/petergtz/pegomock"
)
func AnySliceOfString() []string {
diff --git a/server/core/terraform/mocks/mock_downloader.go b/server/core/terraform/mocks/mock_downloader.go
index 7d5719ccd..e18a7f046 100644
--- a/server/core/terraform/mocks/mock_downloader.go
+++ b/server/core/terraform/mocks/mock_downloader.go
@@ -4,10 +4,11 @@
package mocks
import (
- go_getter "github.com/hashicorp/go-getter"
- pegomock "github.com/petergtz/pegomock"
"reflect"
"time"
+
+ go_getter "github.com/hashicorp/go-getter"
+ pegomock "github.com/petergtz/pegomock"
)
type MockDownloader struct {
diff --git a/server/core/terraform/mocks/mock_terraform_client.go b/server/core/terraform/mocks/mock_terraform_client.go
index 95157c368..76ccc3da4 100644
--- a/server/core/terraform/mocks/mock_terraform_client.go
+++ b/server/core/terraform/mocks/mock_terraform_client.go
@@ -10,7 +10,7 @@ import (
go_version "github.com/hashicorp/go-version"
pegomock "github.com/petergtz/pegomock"
"github.com/runatlantis/atlantis/server/core/terraform"
- "github.com/runatlantis/atlantis/server/events/models"
+ "github.com/runatlantis/atlantis/server/events/command"
logging "github.com/runatlantis/atlantis/server/logging"
)
@@ -29,7 +29,7 @@ func NewMockClient(options ...pegomock.Option) *MockClient {
func (mock *MockClient) SetFailHandler(fh pegomock.FailHandler) { mock.fail = fh }
func (mock *MockClient) FailHandler() pegomock.FailHandler { return mock.fail }
-func (mock *MockClient) RunCommandWithVersion(ctx models.ProjectCommandContext, path string, args []string, envs map[string]string, v *go_version.Version, workspace string) (string, error) {
+func (mock *MockClient) RunCommandWithVersion(ctx command.ProjectContext, path string, args []string, envs map[string]string, v *go_version.Version, workspace string) (string, error) {
if mock == nil {
panic("mock must not be nil. Use myMock := NewMockClient().")
}
@@ -48,7 +48,7 @@ func (mock *MockClient) RunCommandWithVersion(ctx models.ProjectCommandContext,
return ret0, ret1
}
-func (mock *MockClient) RunCommandAsync(ctx models.ProjectCommandContext, path string, args []string, envs map[string]string, v *go_version.Version, workspace string) (chan<- string, <-chan terraform.Line) {
+func (mock *MockClient) RunCommandAsync(ctx command.ProjectContext, path string, args []string, envs map[string]string, v *go_version.Version, workspace string) (chan<- string, <-chan terraform.Line) {
if mock == nil {
panic("mock must not be nil. Use myMock := NewMockClient().")
}
@@ -110,7 +110,7 @@ type VerifierMockClient struct {
timeout time.Duration
}
-func (verifier *VerifierMockClient) RunCommandWithVersion(ctx models.ProjectCommandContext, path string, args []string, envs map[string]string, v *go_version.Version, workspace string) *MockClient_RunCommandWithVersion_OngoingVerification {
+func (verifier *VerifierMockClient) RunCommandWithVersion(ctx command.ProjectContext, path string, args []string, envs map[string]string, v *go_version.Version, workspace string) *MockClient_RunCommandWithVersion_OngoingVerification {
params := []pegomock.Param{ctx, path, args, envs, v, workspace}
methodInvocations := pegomock.GetGenericMockFrom(verifier.mock).Verify(verifier.inOrderContext, verifier.invocationCountMatcher, "RunCommandWithVersion", params, verifier.timeout)
return &MockClient_RunCommandWithVersion_OngoingVerification{mock: verifier.mock, methodInvocations: methodInvocations}
diff --git a/server/core/terraform/terraform_client.go b/server/core/terraform/terraform_client.go
index 5e0195456..f6e5c92a4 100644
--- a/server/core/terraform/terraform_client.go
+++ b/server/core/terraform/terraform_client.go
@@ -31,7 +31,7 @@ import (
"github.com/mitchellh/go-homedir"
"github.com/pkg/errors"
- "github.com/runatlantis/atlantis/server/events/models"
+ "github.com/runatlantis/atlantis/server/events/command"
"github.com/runatlantis/atlantis/server/events/terraform/ansi"
"github.com/runatlantis/atlantis/server/jobs"
"github.com/runatlantis/atlantis/server/logging"
@@ -48,7 +48,7 @@ type Client interface {
// RunCommandWithVersion executes terraform with args in path. If v is nil,
// it will use the default Terraform version. workspace is the Terraform
// workspace which should be set as an environment variable.
- RunCommandWithVersion(log logging.SimpleLogging, path string, args []string, envs map[string]string, v *version.Version, workspace string) (string, error)
+ RunCommandWithVersion(ctx command.ProjectContext, path string, args []string, envs map[string]string, v *version.Version, workspace string) (string, error)
// EnsureVersion makes sure that terraform version `v` is available to use
EnsureVersion(log logging.SimpleLogging, v *version.Version) error
@@ -278,9 +278,10 @@ func (c *DefaultClient) EnsureVersion(log logging.SimpleLogging, v *version.Vers
}
// See Client.RunCommandWithVersion.
-func (c *DefaultClient) RunCommandWithVersion(ctx models.ProjectCommandContext, path string, args []string, customEnvVars map[string]string, v *version.Version, workspace string) (string, error) {
+func (c *DefaultClient) RunCommandWithVersion(ctx command.ProjectContext, path string, args []string, customEnvVars map[string]string, v *version.Version, workspace string) (string, error) {
if isAsyncEligibleCommand(args[0]) {
_, outCh := c.RunCommandAsync(ctx, path, args, customEnvVars, v, workspace)
+
var lines []string
var err error
for line := range outCh {
@@ -375,7 +376,7 @@ type Line struct {
// Callers can use the input channel to pass stdin input to the command.
// If any error is passed on the out channel, there will be no
// further output (so callers are free to exit).
-func (c *DefaultClient) RunCommandAsync(ctx models.ProjectCommandContext, path string, args []string, customEnvVars map[string]string, v *version.Version, workspace string) (chan<- string, <-chan Line) {
+func (c *DefaultClient) RunCommandAsync(ctx command.ProjectContext, path string, args []string, customEnvVars map[string]string, v *version.Version, workspace string) (chan<- string, <-chan Line) {
outCh := make(chan Line)
inCh := make(chan string)
diff --git a/server/core/terraform/terraform_client_internal_test.go b/server/core/terraform/terraform_client_internal_test.go
index d0d30e759..a99bc584b 100644
--- a/server/core/terraform/terraform_client_internal_test.go
+++ b/server/core/terraform/terraform_client_internal_test.go
@@ -8,6 +8,7 @@ import (
"testing"
version "github.com/hashicorp/go-version"
+ "github.com/runatlantis/atlantis/server/events/command"
"github.com/runatlantis/atlantis/server/events/models"
jobmocks "github.com/runatlantis/atlantis/server/jobs/mocks"
"github.com/runatlantis/atlantis/server/logging"
@@ -93,7 +94,7 @@ func TestDefaultClient_RunCommandWithVersion_EnvVars(t *testing.T) {
logger := logging.NewNoopLogger(t)
projectCmdOutputHandler := jobmocks.NewMockProjectCommandOutputHandler()
- ctx := models.ProjectCommandContext{
+ ctx := command.ProjectContext{
Log: logger,
Workspace: "default",
RepoRelDir: ".",
@@ -103,11 +104,6 @@ func TestDefaultClient_RunCommandWithVersion_EnvVars(t *testing.T) {
Pull: models.PullRequest{
Num: 2,
},
- BaseRepo: models.Repo{
- FullName: "owner/repo",
- Owner: "owner",
- Name: "repo",
- },
}
defer cleanup()
client := &DefaultClient{
@@ -140,7 +136,7 @@ func TestDefaultClient_RunCommandWithVersion_Error(t *testing.T) {
logger := logging.NewNoopLogger(t)
projectCmdOutputHandler := jobmocks.NewMockProjectCommandOutputHandler()
- ctx := models.ProjectCommandContext{
+ ctx := command.ProjectContext{
Log: logger,
Workspace: "default",
RepoRelDir: ".",
@@ -183,7 +179,7 @@ func TestDefaultClient_RunCommandAsync_Success(t *testing.T) {
logger := logging.NewNoopLogger(t)
projectCmdOutputHandler := jobmocks.NewMockProjectCommandOutputHandler()
- ctx := models.ProjectCommandContext{
+ ctx := command.ProjectContext{
Log: logger,
Workspace: "default",
RepoRelDir: ".",
@@ -230,7 +226,7 @@ func TestDefaultClient_RunCommandAsync_BigOutput(t *testing.T) {
logger := logging.NewNoopLogger(t)
projectCmdOutputHandler := jobmocks.NewMockProjectCommandOutputHandler()
- ctx := models.ProjectCommandContext{
+ ctx := command.ProjectContext{
Log: logger,
Workspace: "default",
RepoRelDir: ".",
@@ -278,7 +274,7 @@ func TestDefaultClient_RunCommandAsync_StderrOutput(t *testing.T) {
logger := logging.NewNoopLogger(t)
projectCmdOutputHandler := jobmocks.NewMockProjectCommandOutputHandler()
- ctx := models.ProjectCommandContext{
+ ctx := command.ProjectContext{
Log: logger,
Workspace: "default",
RepoRelDir: ".",
@@ -315,7 +311,7 @@ func TestDefaultClient_RunCommandAsync_ExitOne(t *testing.T) {
logger := logging.NewNoopLogger(t)
projectCmdOutputHandler := jobmocks.NewMockProjectCommandOutputHandler()
- ctx := models.ProjectCommandContext{
+ ctx := command.ProjectContext{
Log: logger,
Workspace: "default",
RepoRelDir: ".",
@@ -353,7 +349,7 @@ func TestDefaultClient_RunCommandAsync_Input(t *testing.T) {
logger := logging.NewNoopLogger(t)
projectCmdOutputHandler := jobmocks.NewMockProjectCommandOutputHandler()
- ctx := models.ProjectCommandContext{
+ ctx := command.ProjectContext{
Log: logger,
Workspace: "default",
RepoRelDir: ".",
diff --git a/server/core/terraform/terraform_client_test.go b/server/core/terraform/terraform_client_test.go
index 610b26269..54c022f63 100644
--- a/server/core/terraform/terraform_client_test.go
+++ b/server/core/terraform/terraform_client_test.go
@@ -27,7 +27,7 @@ import (
"github.com/runatlantis/atlantis/cmd"
"github.com/runatlantis/atlantis/server/core/terraform"
"github.com/runatlantis/atlantis/server/core/terraform/mocks"
- "github.com/runatlantis/atlantis/server/events/models"
+ "github.com/runatlantis/atlantis/server/events/command"
jobmocks "github.com/runatlantis/atlantis/server/jobs/mocks"
"github.com/runatlantis/atlantis/server/logging"
. "github.com/runatlantis/atlantis/testing"
@@ -62,7 +62,7 @@ is 0.11.13. You can update by downloading from www.terraform.io/downloads.html
`
tmp, binDir, cacheDir, cleanup := mkSubDirs(t)
projectCmdOutputHandler := jobmocks.NewMockProjectCommandOutputHandler()
- ctx := models.ProjectCommandContext{
+ ctx := command.ProjectContext{
Log: logging.NewNoopLogger(t),
Workspace: "default",
RepoRelDir: ".",
@@ -99,7 +99,7 @@ is 0.11.13. You can update by downloading from www.terraform.io/downloads.html
logger := logging.NewNoopLogger(t)
tmp, binDir, cacheDir, cleanup := mkSubDirs(t)
projectCmdOutputHandler := jobmocks.NewMockProjectCommandOutputHandler()
- ctx := models.ProjectCommandContext{
+ ctx := command.ProjectContext{
Log: logging.NewNoopLogger(t),
Workspace: "default",
RepoRelDir: ".",
@@ -145,7 +145,7 @@ func TestNewClient_DefaultTFFlagInPath(t *testing.T) {
logger := logging.NewNoopLogger(t)
tmp, binDir, cacheDir, cleanup := mkSubDirs(t)
projectCmdOutputHandler := jobmocks.NewMockProjectCommandOutputHandler()
- ctx := models.ProjectCommandContext{
+ ctx := command.ProjectContext{
Log: logging.NewNoopLogger(t),
Workspace: "default",
RepoRelDir: ".",
@@ -175,7 +175,7 @@ func TestNewClient_DefaultTFFlagInBinDir(t *testing.T) {
fakeBinOut := "Terraform v0.11.10\n"
tmp, binDir, cacheDir, cleanup := mkSubDirs(t)
projectCmdOutputHandler := jobmocks.NewMockProjectCommandOutputHandler()
- ctx := models.ProjectCommandContext{
+ ctx := command.ProjectContext{
Log: logging.NewNoopLogger(t),
Workspace: "default",
RepoRelDir: ".",
@@ -204,7 +204,7 @@ func TestNewClient_DefaultTFFlagDownload(t *testing.T) {
logger := logging.NewNoopLogger(t)
tmp, binDir, cacheDir, cleanup := mkSubDirs(t)
projectCmdOutputHandler := jobmocks.NewMockProjectCommandOutputHandler()
- ctx := models.ProjectCommandContext{
+ ctx := command.ProjectContext{
Log: logging.NewNoopLogger(t),
Workspace: "default",
RepoRelDir: ".",
@@ -257,7 +257,7 @@ func TestRunCommandWithVersion_DLsTF(t *testing.T) {
RegisterMockTestingT(t)
tmp, binDir, cacheDir, cleanup := mkSubDirs(t)
projectCmdOutputHandler := jobmocks.NewMockProjectCommandOutputHandler()
- ctx := models.ProjectCommandContext{
+ ctx := command.ProjectContext{
Log: logging.NewNoopLogger(t),
Workspace: "default",
RepoRelDir: ".",
diff --git a/server/events/apply_command_runner.go b/server/events/apply_command_runner.go
index fd36d1ac0..1cd1f5baa 100644
--- a/server/events/apply_command_runner.go
+++ b/server/events/apply_command_runner.go
@@ -3,6 +3,7 @@ package events
import (
"github.com/runatlantis/atlantis/server/core/db"
"github.com/runatlantis/atlantis/server/core/locking"
+ "github.com/runatlantis/atlantis/server/events/command"
"github.com/runatlantis/atlantis/server/events/models"
"github.com/runatlantis/atlantis/server/events/vcs"
)
@@ -62,7 +63,7 @@ type ApplyCommandRunner struct {
silenceVCSStatusNoProjects bool
}
-func (a *ApplyCommandRunner) Run(ctx *CommandContext, cmd *CommentCommand) {
+func (a *ApplyCommandRunner) Run(ctx *command.Context, cmd *CommentCommand) {
var err error
baseRepo := ctx.Pull.BaseRepo
pull := ctx.Pull
@@ -77,7 +78,7 @@ func (a *ApplyCommandRunner) Run(ctx *CommandContext, cmd *CommentCommand) {
if locked {
ctx.Log.Info("ignoring apply command since apply disabled globally")
- if err := a.vcsClient.CreateComment(baseRepo, pull.Num, applyDisabledComment, models.ApplyCommand.String()); err != nil {
+ if err := a.vcsClient.CreateComment(baseRepo, pull.Num, applyDisabledComment, command.Apply.String()); err != nil {
ctx.Log.Err("unable to comment on pull request: %s", err)
}
@@ -86,7 +87,7 @@ func (a *ApplyCommandRunner) Run(ctx *CommandContext, cmd *CommentCommand) {
if a.DisableApplyAll && !cmd.IsForSpecificProject() {
ctx.Log.Info("ignoring apply command without flags since apply all is disabled")
- if err := a.vcsClient.CreateComment(baseRepo, pull.Num, applyAllDisabledComment, models.ApplyCommand.String()); err != nil {
+ if err := a.vcsClient.CreateComment(baseRepo, pull.Num, applyAllDisabledComment, command.Apply.String()); err != nil {
ctx.Log.Err("unable to comment on pull request: %s", err)
}
@@ -111,14 +112,14 @@ func (a *ApplyCommandRunner) Run(ctx *CommandContext, cmd *CommentCommand) {
ctx.Log.Warn("unable to update commit status: %s", err)
}
- var projectCmds []models.ProjectCommandContext
+ var projectCmds []command.ProjectContext
projectCmds, err = a.prjCmdBuilder.BuildApplyCommands(ctx, cmd)
if err != nil {
if statusErr := a.commitStatusUpdater.UpdateCombined(ctx.Pull.BaseRepo, ctx.Pull, models.FailedCommitStatus, cmd.CommandName()); statusErr != nil {
ctx.Log.Warn("unable to update commit status: %s", statusErr)
}
- a.pullUpdater.updatePull(ctx, cmd, CommandResult{Error: err})
+ a.pullUpdater.updatePull(ctx, cmd, command.Result{Error: err})
return
}
@@ -130,7 +131,7 @@ func (a *ApplyCommandRunner) Run(ctx *CommandContext, cmd *CommentCommand) {
// with 0/0 projects applied successfully because some users require
// the Atlantis status to be passing for all pull requests.
ctx.Log.Debug("setting VCS status to success with no projects found")
- if err := a.commitStatusUpdater.UpdateCombinedCount(baseRepo, pull, models.SuccessCommitStatus, models.ApplyCommand, 0, 0); err != nil {
+ if err := a.commitStatusUpdater.UpdateCombinedCount(baseRepo, pull, models.SuccessCommitStatus, command.Apply, 0, 0); err != nil {
ctx.Log.Warn("unable to update commit status: %s", err)
}
}
@@ -138,7 +139,7 @@ func (a *ApplyCommandRunner) Run(ctx *CommandContext, cmd *CommentCommand) {
}
// Only run commands in parallel if enabled
- var result CommandResult
+ var result command.Result
if a.isParallelEnabled(projectCmds) {
ctx.Log.Info("Running applies in parallel")
result = runProjectCmdsParallel(projectCmds, a.prjCmdRunner.Apply, a.parallelPoolSize)
@@ -170,11 +171,11 @@ func (a *ApplyCommandRunner) IsLocked() (bool, error) {
return lock.Locked, err
}
-func (a *ApplyCommandRunner) isParallelEnabled(projectCmds []models.ProjectCommandContext) bool {
+func (a *ApplyCommandRunner) isParallelEnabled(projectCmds []command.ProjectContext) bool {
return len(projectCmds) > 0 && projectCmds[0].ParallelApplyEnabled
}
-func (a *ApplyCommandRunner) updateCommitStatus(ctx *CommandContext, pullStatus models.PullStatus) {
+func (a *ApplyCommandRunner) updateCommitStatus(ctx *command.Context, pullStatus models.PullStatus) {
var numSuccess int
var numErrored int
status := models.SuccessCommitStatus
@@ -194,7 +195,7 @@ func (a *ApplyCommandRunner) updateCommitStatus(ctx *CommandContext, pullStatus
ctx.Pull.BaseRepo,
ctx.Pull,
status,
- models.ApplyCommand,
+ command.Apply,
numSuccess,
len(pullStatus.Projects),
); err != nil {
diff --git a/server/events/apply_command_runner_test.go b/server/events/apply_command_runner_test.go
index 09442966f..567c0d64a 100644
--- a/server/events/apply_command_runner_test.go
+++ b/server/events/apply_command_runner_test.go
@@ -8,6 +8,7 @@ import (
. "github.com/petergtz/pegomock"
"github.com/runatlantis/atlantis/server/core/locking"
"github.com/runatlantis/atlantis/server/events"
+ "github.com/runatlantis/atlantis/server/events/command"
"github.com/runatlantis/atlantis/server/events/models"
"github.com/runatlantis/atlantis/server/events/models/fixtures"
"github.com/runatlantis/atlantis/server/logging"
@@ -56,17 +57,17 @@ func TestApplyCommandRunner_IsLocked(t *testing.T) {
When(githubGetter.GetPullRequest(fixtures.GithubRepo, fixtures.Pull.Num)).ThenReturn(pull, nil)
When(eventParsing.ParseGithubPull(pull)).ThenReturn(modelPull, modelPull.BaseRepo, fixtures.GithubRepo, nil)
- ctx := &events.CommandContext{
+ ctx := &command.Context{
User: fixtures.User,
Log: logging.NewNoopLogger(t),
Scope: scopeNull,
Pull: modelPull,
HeadRepo: fixtures.GithubRepo,
- Trigger: events.Comment,
+ Trigger: command.CommentTrigger,
}
When(applyLockChecker.CheckApplyLock()).ThenReturn(locking.ApplyCommandLock{Locked: c.ApplyLocked}, c.ApplyLockError)
- applyCommandRunner.Run(ctx, &events.CommentCommand{Name: models.ApplyCommand})
+ applyCommandRunner.Run(ctx, &events.CommentCommand{Name: command.Apply})
vcsClient.VerifyWasCalledOnce().CreateComment(fixtures.GithubRepo, modelPull.Num, c.ExpComment, "apply")
})
diff --git a/server/events/apply_requirement_handler.go b/server/events/apply_requirement_handler.go
index 5d8fa93af..107b163ca 100644
--- a/server/events/apply_requirement_handler.go
+++ b/server/events/apply_requirement_handler.go
@@ -3,19 +3,20 @@ package events
import (
"github.com/runatlantis/atlantis/server/core/config/raw"
"github.com/runatlantis/atlantis/server/core/config/valid"
+ "github.com/runatlantis/atlantis/server/events/command"
"github.com/runatlantis/atlantis/server/events/models"
)
//go:generate pegomock generate -m --package mocks -o mocks/mock_apply_handler.go ApplyRequirement
type ApplyRequirement interface {
- ValidateProject(repoDir string, ctx models.ProjectCommandContext) (string, error)
+ ValidateProject(repoDir string, ctx command.ProjectContext) (string, error)
}
type AggregateApplyRequirements struct {
WorkingDir WorkingDir
}
-func (a *AggregateApplyRequirements) ValidateProject(repoDir string, ctx models.ProjectCommandContext) (failure string, err error) {
+func (a *AggregateApplyRequirements) ValidateProject(repoDir string, ctx command.ProjectContext) (failure string, err error) {
for _, req := range ctx.ApplyRequirements {
switch req {
case raw.ApprovedApplyRequirement:
diff --git a/server/events/approve_policies_command_runner.go b/server/events/approve_policies_command_runner.go
index ea57e4520..7e9a56e1a 100644
--- a/server/events/approve_policies_command_runner.go
+++ b/server/events/approve_policies_command_runner.go
@@ -3,6 +3,7 @@ package events
import (
"fmt"
+ "github.com/runatlantis/atlantis/server/events/command"
"github.com/runatlantis/atlantis/server/events/models"
)
@@ -38,20 +39,20 @@ type ApprovePoliciesCommandRunner struct {
silenceVCSStatusNoProjects bool
}
-func (a *ApprovePoliciesCommandRunner) Run(ctx *CommandContext, cmd *CommentCommand) {
+func (a *ApprovePoliciesCommandRunner) Run(ctx *command.Context, cmd *CommentCommand) {
baseRepo := ctx.Pull.BaseRepo
pull := ctx.Pull
- if err := a.commitStatusUpdater.UpdateCombined(baseRepo, pull, models.PendingCommitStatus, models.PolicyCheckCommand); err != nil {
+ if err := a.commitStatusUpdater.UpdateCombined(baseRepo, pull, models.PendingCommitStatus, command.PolicyCheck); err != nil {
ctx.Log.Warn("unable to update commit status: %s", err)
}
projectCmds, err := a.prjCmdBuilder.BuildApprovePoliciesCommands(ctx, cmd)
if err != nil {
- if statusErr := a.commitStatusUpdater.UpdateCombined(ctx.Pull.BaseRepo, ctx.Pull, models.FailedCommitStatus, models.PolicyCheckCommand); statusErr != nil {
+ if statusErr := a.commitStatusUpdater.UpdateCombined(ctx.Pull.BaseRepo, ctx.Pull, models.FailedCommitStatus, command.PolicyCheck); statusErr != nil {
ctx.Log.Warn("unable to update commit status: %s", statusErr)
}
- a.pullUpdater.updatePull(ctx, cmd, CommandResult{Error: err})
+ a.pullUpdater.updatePull(ctx, cmd, command.Result{Error: err})
return
}
@@ -62,7 +63,7 @@ func (a *ApprovePoliciesCommandRunner) Run(ctx *CommandContext, cmd *CommentComm
// with 0/0 projects approve_policies successfully because some users require
// the Atlantis status to be passing for all pull requests.
ctx.Log.Debug("setting VCS status to success with no projects found")
- if err := a.commitStatusUpdater.UpdateCombinedCount(ctx.Pull.BaseRepo, ctx.Pull, models.SuccessCommitStatus, models.PolicyCheckCommand, 0, 0); err != nil {
+ if err := a.commitStatusUpdater.UpdateCombinedCount(ctx.Pull.BaseRepo, ctx.Pull, models.SuccessCommitStatus, command.PolicyCheck, 0, 0); err != nil {
ctx.Log.Warn("unable to update commit status: %s", err)
}
}
@@ -86,7 +87,7 @@ func (a *ApprovePoliciesCommandRunner) Run(ctx *CommandContext, cmd *CommentComm
a.updateCommitStatus(ctx, pullStatus)
}
-func (a *ApprovePoliciesCommandRunner) buildApprovePolicyCommandResults(ctx *CommandContext, prjCmds []models.ProjectCommandContext) (result CommandResult) {
+func (a *ApprovePoliciesCommandRunner) buildApprovePolicyCommandResults(ctx *command.Context, prjCmds []command.ProjectContext) (result command.Result) {
// Check if vcs user is in the owner list of the PolicySets. All projects
// share the same Owners list at this time so no reason to iterate over each
// project.
@@ -95,7 +96,7 @@ func (a *ApprovePoliciesCommandRunner) buildApprovePolicyCommandResults(ctx *Com
return
}
- var prjResults []models.ProjectResult
+ var prjResults []command.ProjectResult
for _, prjCmd := range prjCmds {
prjResult := a.prjCmdRunner.ApprovePolicies(prjCmd)
@@ -105,7 +106,7 @@ func (a *ApprovePoliciesCommandRunner) buildApprovePolicyCommandResults(ctx *Com
return
}
-func (a *ApprovePoliciesCommandRunner) updateCommitStatus(ctx *CommandContext, pullStatus models.PullStatus) {
+func (a *ApprovePoliciesCommandRunner) updateCommitStatus(ctx *command.Context, pullStatus models.PullStatus) {
var numSuccess int
var numErrored int
status := models.SuccessCommitStatus
@@ -117,7 +118,7 @@ func (a *ApprovePoliciesCommandRunner) updateCommitStatus(ctx *CommandContext, p
status = models.FailedCommitStatus
}
- if err := a.commitStatusUpdater.UpdateCombinedCount(ctx.Pull.BaseRepo, ctx.Pull, status, models.PolicyCheckCommand, numSuccess, len(pullStatus.Projects)); err != nil {
+ if err := a.commitStatusUpdater.UpdateCombinedCount(ctx.Pull.BaseRepo, ctx.Pull, status, command.PolicyCheck, numSuccess, len(pullStatus.Projects)); err != nil {
ctx.Log.Warn("unable to update commit status: %s", err)
}
}
diff --git a/server/events/automerger.go b/server/events/automerger.go
index 4ce7e3d2d..2dc55dacd 100644
--- a/server/events/automerger.go
+++ b/server/events/automerger.go
@@ -3,6 +3,7 @@ package events
import (
"fmt"
+ "github.com/runatlantis/atlantis/server/events/command"
"github.com/runatlantis/atlantis/server/events/models"
"github.com/runatlantis/atlantis/server/events/vcs"
)
@@ -12,7 +13,7 @@ type AutoMerger struct {
GlobalAutomerge bool
}
-func (c *AutoMerger) automerge(ctx *CommandContext, pullStatus models.PullStatus, deleteSourceBranchOnMerge bool) {
+func (c *AutoMerger) automerge(ctx *command.Context, pullStatus models.PullStatus, deleteSourceBranchOnMerge bool) {
// We only automerge if all projects have been successfully applied.
for _, p := range pullStatus.Projects {
if p.Status != models.AppliedPlanStatus {
@@ -22,7 +23,7 @@ func (c *AutoMerger) automerge(ctx *CommandContext, pullStatus models.PullStatus
}
// Comment that we're automerging the pull request.
- if err := c.VCSClient.CreateComment(ctx.Pull.BaseRepo, ctx.Pull.Num, automergeComment, models.ApplyCommand.String()); err != nil {
+ if err := c.VCSClient.CreateComment(ctx.Pull.BaseRepo, ctx.Pull.Num, automergeComment, command.Apply.String()); err != nil {
ctx.Log.Err("failed to comment about automerge: %s", err)
// Commenting isn't required so continue.
}
@@ -37,14 +38,14 @@ func (c *AutoMerger) automerge(ctx *CommandContext, pullStatus models.PullStatus
ctx.Log.Err("automerging failed: %s", err)
failureComment := fmt.Sprintf("Automerging failed:\n```\n%s\n```", err)
- if commentErr := c.VCSClient.CreateComment(ctx.Pull.BaseRepo, ctx.Pull.Num, failureComment, models.ApplyCommand.String()); commentErr != nil {
+ if commentErr := c.VCSClient.CreateComment(ctx.Pull.BaseRepo, ctx.Pull.Num, failureComment, command.Apply.String()); commentErr != nil {
ctx.Log.Err("failed to comment about automerge failing: %s", err)
}
}
}
// automergeEnabled returns true if automerging is enabled in this context.
-func (c *AutoMerger) automergeEnabled(projectCmds []models.ProjectCommandContext) bool {
+func (c *AutoMerger) automergeEnabled(projectCmds []command.ProjectContext) bool {
// If the global automerge is set, we always automerge.
return c.GlobalAutomerge ||
// Otherwise we check if this repo is configured for automerging.
@@ -52,7 +53,7 @@ func (c *AutoMerger) automergeEnabled(projectCmds []models.ProjectCommandContext
}
// deleteSourceBranchOnMergeEnabled returns true if we should delete the source branch on merge in this context.
-func (c *AutoMerger) deleteSourceBranchOnMergeEnabled(projectCmds []models.ProjectCommandContext) bool {
+func (c *AutoMerger) deleteSourceBranchOnMergeEnabled(projectCmds []command.ProjectContext) bool {
//check if this repo is configured for automerging.
return (len(projectCmds) > 0 && projectCmds[0].DeleteSourceBranchOnMerge)
}
diff --git a/server/events/command/context.go b/server/events/command/context.go
new file mode 100644
index 000000000..0e2ba7d9e
--- /dev/null
+++ b/server/events/command/context.go
@@ -0,0 +1,40 @@
+package command
+
+import (
+ "github.com/runatlantis/atlantis/server/events/models"
+ "github.com/runatlantis/atlantis/server/logging"
+ "github.com/uber-go/tally"
+)
+
+// Trigger represents the how the command was triggered
+type Trigger int
+
+const (
+ // Commands that are automatically triggered (ie. automatic plans)
+ AutoTrigger Trigger = iota
+
+ // Commands that are triggered by comments (ie. atlantis plan)
+ CommentTrigger
+)
+
+// Context represents the context of a command that should be executed
+// for a pull request.
+type Context struct {
+ // HeadRepo is the repository that is getting merged into the BaseRepo.
+ // If the pull request branch is from the same repository then HeadRepo will
+ // be the same as BaseRepo.
+ // See https://help.github.com/articles/about-pull-request-merges/.
+ HeadRepo models.Repo
+ Pull models.PullRequest
+ Scope tally.Scope
+ // User is the user that triggered this command.
+ User models.User
+ Log logging.SimpleLogging
+
+ // Current PR state
+ PullRequestStatus models.PullReqStatus
+
+ PullStatus *models.PullStatus
+
+ Trigger Trigger
+}
diff --git a/server/events/command/lock.go b/server/events/command/lock.go
new file mode 100644
index 000000000..e95cc38db
--- /dev/null
+++ b/server/events/command/lock.go
@@ -0,0 +1,26 @@
+package command
+
+import (
+ "time"
+)
+
+// LockMetadata contains additional data provided to the lock
+type LockMetadata struct {
+ UnixTime int64
+}
+
+// Lock represents a global lock for an atlantis command (plan, apply, policy_check).
+// It is used to prevent commands from being executed
+type Lock struct {
+ // Time is the time at which the lock was first created.
+ LockMetadata LockMetadata
+ CommandName Name
+}
+
+func (l *Lock) LockTime() time.Time {
+ return time.Unix(l.LockMetadata.UnixTime, 0)
+}
+
+func (l *Lock) IsLocked() bool {
+ return !l.LockTime().IsZero()
+}
diff --git a/server/events/command/name.go b/server/events/command/name.go
new file mode 100644
index 000000000..cd31e66a2
--- /dev/null
+++ b/server/events/command/name.go
@@ -0,0 +1,49 @@
+package command
+
+import "strings"
+
+// Name is which command to run.
+type Name int
+
+const (
+ // Apply is a command to run terraform apply.
+ Apply Name = iota
+ // Plan is a command to run terraform plan.
+ Plan
+ // Unlock is a command to discard previous plans as well as the atlantis locks.
+ Unlock
+ // PolicyCheck is a command to run conftest test.
+ PolicyCheck
+ // ApprovePolicies is a command to approve policies with owner check
+ ApprovePolicies
+ // Autoplan is a command to run terrafor plan on PR open/update if autoplan is enabled
+ Autoplan
+ // Version is a command to run terraform version.
+ Version
+ // Adding more? Don't forget to update String() below
+)
+
+// TitleString returns the string representation in title form.
+// ie. policy_check becomes Policy Check
+func (c Name) TitleString() string {
+ return strings.Title(strings.ReplaceAll(strings.ToLower(c.String()), "_", " "))
+}
+
+// String returns the string representation of c.
+func (c Name) String() string {
+ switch c {
+ case Apply:
+ return "apply"
+ case Plan, Autoplan:
+ return "plan"
+ case Unlock:
+ return "unlock"
+ case PolicyCheck:
+ return "policy_check"
+ case ApprovePolicies:
+ return "approve_policies"
+ case Version:
+ return "version"
+ }
+ return ""
+}
diff --git a/server/events/command/name_test.go b/server/events/command/name_test.go
new file mode 100644
index 000000000..6f766000c
--- /dev/null
+++ b/server/events/command/name_test.go
@@ -0,0 +1,32 @@
+package command_test
+
+import (
+ "testing"
+
+ "github.com/runatlantis/atlantis/server/events/command"
+ . "github.com/runatlantis/atlantis/testing"
+)
+
+func TestApplyCommand_String(t *testing.T) {
+ uc := command.Apply
+
+ Equals(t, "apply", uc.String())
+}
+
+func TestPlanCommand_String(t *testing.T) {
+ uc := command.Plan
+
+ Equals(t, "plan", uc.String())
+}
+
+func TestPolicyCheckCommand_String(t *testing.T) {
+ uc := command.PolicyCheck
+
+ Equals(t, "policy_check", uc.String())
+}
+
+func TestUnlockCommand_String(t *testing.T) {
+ uc := command.Unlock
+
+ Equals(t, "unlock", uc.String())
+}
diff --git a/server/events/command/project_context.go b/server/events/command/project_context.go
new file mode 100644
index 000000000..6f4a4da31
--- /dev/null
+++ b/server/events/command/project_context.go
@@ -0,0 +1,130 @@
+package command
+
+import (
+ "fmt"
+ "strings"
+
+ "github.com/hashicorp/go-version"
+ "github.com/runatlantis/atlantis/server/core/config/valid"
+ "github.com/runatlantis/atlantis/server/events/models"
+ "github.com/runatlantis/atlantis/server/logging"
+ "github.com/uber-go/tally"
+)
+
+const (
+ planfileSlashReplace = "::"
+)
+
+// ProjectContext defines the context for a plan or apply stage that will
+// be executed for a project.
+type ProjectContext struct {
+ CommandName Name
+ // ApplyCmd is the command that users should run to apply this plan. If
+ // this is an apply then this will be empty.
+ ApplyCmd string
+ // ApplyRequirements is the list of requirements that must be satisfied
+ // before we will run the apply stage.
+ ApplyRequirements []string
+ // AutomergeEnabled is true if automerge is enabled for the repo that this
+ // project is in.
+ AutomergeEnabled bool
+ // ParallelApplyEnabled is true if parallel apply is enabled for this project.
+ ParallelApplyEnabled bool
+ // ParallelPlanEnabled is true if parallel plan is enabled for this project.
+ ParallelPlanEnabled bool
+ // ParallelPolicyCheckEnabled is true if parallel policy_check is enabled for this project.
+ ParallelPolicyCheckEnabled bool
+ // AutoplanEnabled is true if autoplanning is enabled for this project.
+ AutoplanEnabled bool
+ // BaseRepo is the repository that the pull request will be merged into.
+ BaseRepo models.Repo
+ // EscapedCommentArgs are the extra arguments that were added to the atlantis
+ // command, ex. atlantis plan -- -target=resource. We then escape them
+ // by adding a \ before each character so that they can be used within
+ // sh -c safely, i.e. sh -c "terraform plan $(touch bad)".
+ EscapedCommentArgs []string
+ // HeadRepo is the repository that is getting merged into the BaseRepo.
+ // If the pull request branch is from the same repository then HeadRepo will
+ // be the same as BaseRepo.
+ HeadRepo models.Repo
+ // Log is a logger that's been set up for this context.
+ Log logging.SimpleLogging
+ // Scope is the scope for reporting stats setup for this context
+ Scope tally.Scope
+ // PullReqStatus holds state about the PR that requires additional computation outside models.PullRequest
+ PullReqStatus models.PullReqStatus
+ // CurrentProjectPlanStatus is the status of the current project prior to this command.
+ ProjectPlanStatus models.ProjectPlanStatus
+ // Pull is the pull request we're responding to.
+ Pull models.PullRequest
+ // ProjectName is the name of the project set in atlantis.yaml. If there was
+ // no name this will be an empty string.
+ ProjectName string
+ // RepoConfigVersion is the version of the repo's atlantis.yaml file. If
+ // there was no file, this will be 0.
+ RepoConfigVersion int
+ // RePlanCmd is the command that users should run to re-plan this project.
+ // If this is an apply then this will be empty.
+ RePlanCmd string
+ // RepoRelDir is the directory of this project relative to the repo root.
+ RepoRelDir string
+ // Steps are the sequence of commands we need to run for this project and this
+ // stage.
+ Steps []valid.Step
+ // TerraformVersion is the version of terraform we should use when executing
+ // commands for this project. This can be set to nil in which case we will
+ // use the default Atlantis terraform version.
+ TerraformVersion *version.Version
+ // Configuration metadata for a given project.
+ User models.User
+ // Verbose is true when the user would like verbose output.
+ Verbose bool
+ // Workspace is the Terraform workspace this project is in. It will always
+ // be set.
+ Workspace string
+ // PolicySets represent the policies that are run on the plan as part of the
+ // policy check stage
+ PolicySets valid.PolicySets
+ // DeleteSourceBranchOnMerge will attempt to allow a branch to be deleted when merged (AzureDevOps & GitLab Support Only)
+ DeleteSourceBranchOnMerge bool
+ // UUID for atlantis logs
+ JobID string
+}
+
+// SetScope sets the scope of the stats object field. Note: we deliberately set this on the value
+// instead of a pointer since we want scopes to mirror our function stack
+func (p ProjectContext) SetScope(scope string) {
+ p.Scope = p.Scope.SubScope(scope) //nolint
+}
+
+// GetShowResultFileName returns the filename (not the path) to store the tf show result
+func (p ProjectContext) GetShowResultFileName() string {
+ if p.ProjectName == "" {
+ return fmt.Sprintf("%s.json", p.Workspace)
+ }
+ projName := strings.Replace(p.ProjectName, "/", planfileSlashReplace, -1)
+ return fmt.Sprintf("%s-%s.json", projName, p.Workspace)
+}
+
+// Gets a unique identifier for the current pull request as a single string
+func (p ProjectContext) PullInfo() string {
+ normalizedOwner := strings.ReplaceAll(p.BaseRepo.Owner, "/", "-")
+ normalizedName := strings.ReplaceAll(p.BaseRepo.Name, "/", "-")
+ projectRepo := fmt.Sprintf("%s/%s", normalizedOwner, normalizedName)
+
+ return buildPullInfo(projectRepo, p.Pull.Num, p.ProjectName, p.RepoRelDir, p.Workspace)
+}
+func buildPullInfo(repoName string, pullNum int, projectName string, relDir string, workspace string) string {
+ projectIdentifier := getProjectIdentifier(relDir, projectName)
+ return fmt.Sprintf("%s/%d/%s/%s", repoName, pullNum, projectIdentifier, workspace)
+}
+
+func getProjectIdentifier(relRepoDir string, projectName string) string {
+ if projectName != "" {
+ return projectName
+ }
+ // Replace directory separator / with -
+ // Replace . with _ to ensure projects with no project name and root dir set to "." have a valid URL
+ replacer := strings.NewReplacer("/", "-", ".", "_")
+ return replacer.Replace(relRepoDir)
+}
diff --git a/server/events/command/project_result.go b/server/events/command/project_result.go
new file mode 100644
index 000000000..3fadd00c8
--- /dev/null
+++ b/server/events/command/project_result.go
@@ -0,0 +1,65 @@
+package command
+
+import (
+ "github.com/runatlantis/atlantis/server/events/models"
+)
+
+// ProjectResult is the result of executing a plan/policy_check/apply for a specific project.
+type ProjectResult struct {
+ Command Name
+ RepoRelDir string
+ Workspace string
+ Error error
+ Failure string
+ PlanSuccess *models.PlanSuccess
+ PolicyCheckSuccess *models.PolicyCheckSuccess
+ ApplySuccess string
+ VersionSuccess string
+ ProjectName string
+}
+
+// CommitStatus returns the vcs commit status of this project result.
+func (p ProjectResult) CommitStatus() models.CommitStatus {
+ if p.Error != nil {
+ return models.FailedCommitStatus
+ }
+ if p.Failure != "" {
+ return models.FailedCommitStatus
+ }
+ return models.SuccessCommitStatus
+}
+
+// PlanStatus returns the plan status.
+func (p ProjectResult) PlanStatus() models.ProjectPlanStatus {
+ switch p.Command {
+
+ case Plan:
+ if p.Error != nil {
+ return models.ErroredPlanStatus
+ } else if p.Failure != "" {
+ return models.ErroredPlanStatus
+ }
+ return models.PlannedPlanStatus
+ case PolicyCheck, ApprovePolicies:
+ if p.Error != nil {
+ return models.ErroredPolicyCheckStatus
+ } else if p.Failure != "" {
+ return models.ErroredPolicyCheckStatus
+ }
+ return models.PassedPolicyCheckStatus
+ case Apply:
+ if p.Error != nil {
+ return models.ErroredApplyStatus
+ } else if p.Failure != "" {
+ return models.ErroredApplyStatus
+ }
+ return models.AppliedPlanStatus
+ }
+
+ panic("PlanStatus() missing a combination")
+}
+
+// IsSuccessful returns true if this project result had no errors.
+func (p ProjectResult) IsSuccessful() bool {
+ return p.PlanSuccess != nil || p.PolicyCheckSuccess != nil || p.ApplySuccess != ""
+}
diff --git a/server/events/command/project_result_test.go b/server/events/command/project_result_test.go
new file mode 100644
index 000000000..cd1e7bb67
--- /dev/null
+++ b/server/events/command/project_result_test.go
@@ -0,0 +1,227 @@
+package command_test
+
+import (
+ "errors"
+ "testing"
+
+ "github.com/runatlantis/atlantis/server/events/command"
+ "github.com/runatlantis/atlantis/server/events/models"
+ . "github.com/runatlantis/atlantis/testing"
+)
+
+func TestProjectResult_IsSuccessful(t *testing.T) {
+ cases := map[string]struct {
+ pr command.ProjectResult
+ exp bool
+ }{
+ "plan success": {
+ command.ProjectResult{
+ PlanSuccess: &models.PlanSuccess{},
+ },
+ true,
+ },
+ "policy_check success": {
+ command.ProjectResult{
+ PolicyCheckSuccess: &models.PolicyCheckSuccess{},
+ },
+ true,
+ },
+ "apply success": {
+ command.ProjectResult{
+ ApplySuccess: "success",
+ },
+ true,
+ },
+ "failure": {
+ command.ProjectResult{
+ Failure: "failure",
+ },
+ false,
+ },
+ "error": {
+ command.ProjectResult{
+ Error: errors.New("error"),
+ },
+ false,
+ },
+ }
+
+ for name, c := range cases {
+ t.Run(name, func(t *testing.T) {
+ Equals(t, c.exp, c.pr.IsSuccessful())
+ })
+ }
+}
+
+func TestProjectResult_PlanStatus(t *testing.T) {
+ cases := []struct {
+ p command.ProjectResult
+ expStatus models.ProjectPlanStatus
+ }{
+ {
+ p: command.ProjectResult{
+ Command: command.Plan,
+ Error: errors.New("err"),
+ },
+ expStatus: models.ErroredPlanStatus,
+ },
+ {
+ p: command.ProjectResult{
+ Command: command.Plan,
+ Failure: "failure",
+ },
+ expStatus: models.ErroredPlanStatus,
+ },
+ {
+ p: command.ProjectResult{
+ Command: command.Plan,
+ PlanSuccess: &models.PlanSuccess{},
+ },
+ expStatus: models.PlannedPlanStatus,
+ },
+ {
+ p: command.ProjectResult{
+ Command: command.Apply,
+ Error: errors.New("err"),
+ },
+ expStatus: models.ErroredApplyStatus,
+ },
+ {
+ p: command.ProjectResult{
+ Command: command.Apply,
+ Failure: "failure",
+ },
+ expStatus: models.ErroredApplyStatus,
+ },
+ {
+ p: command.ProjectResult{
+ Command: command.Apply,
+ ApplySuccess: "success",
+ },
+ expStatus: models.AppliedPlanStatus,
+ },
+ {
+ p: command.ProjectResult{
+ Command: command.PolicyCheck,
+ PolicyCheckSuccess: &models.PolicyCheckSuccess{},
+ },
+ expStatus: models.PassedPolicyCheckStatus,
+ },
+ {
+ p: command.ProjectResult{
+ Command: command.PolicyCheck,
+ Failure: "failure",
+ },
+ expStatus: models.ErroredPolicyCheckStatus,
+ },
+ {
+ p: command.ProjectResult{
+ Command: command.ApprovePolicies,
+ PolicyCheckSuccess: &models.PolicyCheckSuccess{},
+ },
+ expStatus: models.PassedPolicyCheckStatus,
+ },
+ {
+ p: command.ProjectResult{
+ Command: command.ApprovePolicies,
+ Failure: "failure",
+ },
+ expStatus: models.ErroredPolicyCheckStatus,
+ },
+ }
+
+ for _, c := range cases {
+ t.Run(c.expStatus.String(), func(t *testing.T) {
+ Equals(t, c.expStatus, c.p.PlanStatus())
+ })
+ }
+}
+
+func TestPlanSuccess_Summary(t *testing.T) {
+ cases := []struct {
+ p command.ProjectResult
+ expResult string
+ }{
+ {
+ p: command.ProjectResult{
+ PlanSuccess: &models.PlanSuccess{
+ TerraformOutput: `
+ An execution plan has been generated and is shown below.
+ Resource actions are indicated with the following symbols:
+ - destroy
+
+ Terraform will perform the following actions:
+
+ - null_resource.hi[1]
+
+
+ Plan: 0 to add, 0 to change, 1 to destroy.`,
+ },
+ },
+ expResult: "Plan: 0 to add, 0 to change, 1 to destroy.",
+ },
+ {
+ p: command.ProjectResult{
+ PlanSuccess: &models.PlanSuccess{
+ TerraformOutput: `
+ An execution plan has been generated and is shown below.
+ Resource actions are indicated with the following symbols:
+
+ No changes. Infrastructure is up-to-date.`,
+ },
+ },
+ expResult: "No changes. Infrastructure is up-to-date.",
+ },
+ {
+ p: command.ProjectResult{
+ PlanSuccess: &models.PlanSuccess{
+ TerraformOutput: `
+ Note: Objects have changed outside of Terraform
+
+ Terraform detected the following changes made outside of Terraform since the
+ last "terraform apply":
+
+ No changes. Your infrastructure matches the configuration.`,
+ },
+ },
+ expResult: "\n**Note: Objects have changed outside of Terraform**\nNo changes. Your infrastructure matches the configuration.",
+ },
+ {
+ p: command.ProjectResult{
+ PlanSuccess: &models.PlanSuccess{
+ TerraformOutput: `
+ Note: Objects have changed outside of Terraform
+
+ Terraform detected the following changes made outside of Terraform since the
+ last "terraform apply":
+
+ An execution plan has been generated and is shown below.
+ Resource actions are indicated with the following symbols:
+ - destroy
+
+ Terraform will perform the following actions:
+
+ - null_resource.hi[1]
+
+
+ Plan: 0 to add, 0 to change, 1 to destroy.`,
+ },
+ },
+ expResult: "\n**Note: Objects have changed outside of Terraform**\nPlan: 0 to add, 0 to change, 1 to destroy.",
+ },
+ {
+ p: command.ProjectResult{
+ PlanSuccess: &models.PlanSuccess{
+ TerraformOutput: `No match, expect empty`,
+ },
+ },
+ expResult: "",
+ },
+ }
+
+ for _, c := range cases {
+ t.Run(c.expResult, func(t *testing.T) {
+ Equals(t, c.expResult, c.p.PlanSuccess.Summary())
+ })
+ }
+}
diff --git a/server/events/command/result.go b/server/events/command/result.go
new file mode 100644
index 000000000..af264caa6
--- /dev/null
+++ b/server/events/command/result.go
@@ -0,0 +1,26 @@
+package command
+
+// Result is the result of running a Command.
+type Result struct {
+ Error error
+ Failure string
+ ProjectResults []ProjectResult
+ // PlansDeleted is true if all plans created during this command were
+ // deleted. This happens if automerging is enabled and one project has an
+ // error since automerging requires all plans to succeed.
+ PlansDeleted bool
+}
+
+// HasErrors returns true if there were any errors during the execution,
+// even if it was only in one project.
+func (c Result) HasErrors() bool {
+ if c.Error != nil || c.Failure != "" {
+ return true
+ }
+ for _, r := range c.ProjectResults {
+ if !r.IsSuccessful() {
+ return true
+ }
+ }
+ return false
+}
diff --git a/server/events/command_result_test.go b/server/events/command/result_test.go
similarity index 66%
rename from server/events/command_result_test.go
rename to server/events/command/result_test.go
index bcdeae365..0e176f260 100644
--- a/server/events/command_result_test.go
+++ b/server/events/command/result_test.go
@@ -1,40 +1,40 @@
-package events_test
+package command_test
import (
"errors"
"testing"
- "github.com/runatlantis/atlantis/server/events"
+ "github.com/runatlantis/atlantis/server/events/command"
"github.com/runatlantis/atlantis/server/events/models"
. "github.com/runatlantis/atlantis/testing"
)
func TestCommandResult_HasErrors(t *testing.T) {
cases := map[string]struct {
- cr events.CommandResult
+ cr command.Result
exp bool
}{
"error": {
- cr: events.CommandResult{
+ cr: command.Result{
Error: errors.New("err"),
},
exp: true,
},
"failure": {
- cr: events.CommandResult{
+ cr: command.Result{
Failure: "failure",
},
exp: true,
},
"empty results list": {
- cr: events.CommandResult{
- ProjectResults: []models.ProjectResult{},
+ cr: command.Result{
+ ProjectResults: []command.ProjectResult{},
},
exp: false,
},
"successful plan": {
- cr: events.CommandResult{
- ProjectResults: []models.ProjectResult{
+ cr: command.Result{
+ ProjectResults: []command.ProjectResult{
{
PlanSuccess: &models.PlanSuccess{},
},
@@ -43,8 +43,8 @@ func TestCommandResult_HasErrors(t *testing.T) {
exp: false,
},
"successful apply": {
- cr: events.CommandResult{
- ProjectResults: []models.ProjectResult{
+ cr: command.Result{
+ ProjectResults: []command.ProjectResult{
{
ApplySuccess: "success",
},
@@ -53,8 +53,8 @@ func TestCommandResult_HasErrors(t *testing.T) {
exp: false,
},
"single errored project": {
- cr: events.CommandResult{
- ProjectResults: []models.ProjectResult{
+ cr: command.Result{
+ ProjectResults: []command.ProjectResult{
{
Error: errors.New("err"),
},
@@ -63,8 +63,8 @@ func TestCommandResult_HasErrors(t *testing.T) {
exp: true,
},
"single failed project": {
- cr: events.CommandResult{
- ProjectResults: []models.ProjectResult{
+ cr: command.Result{
+ ProjectResults: []command.ProjectResult{
{
Failure: "failure",
},
@@ -73,8 +73,8 @@ func TestCommandResult_HasErrors(t *testing.T) {
exp: true,
},
"two successful projects": {
- cr: events.CommandResult{
- ProjectResults: []models.ProjectResult{
+ cr: command.Result{
+ ProjectResults: []command.ProjectResult{
{
PlanSuccess: &models.PlanSuccess{},
},
@@ -86,8 +86,8 @@ func TestCommandResult_HasErrors(t *testing.T) {
exp: false,
},
"one successful, one failed project": {
- cr: events.CommandResult{
- ProjectResults: []models.ProjectResult{
+ cr: command.Result{
+ ProjectResults: []command.ProjectResult{
{
PlanSuccess: &models.PlanSuccess{},
},
diff --git a/server/events/command_context.go b/server/events/command_context.go
deleted file mode 100644
index 723ade459..000000000
--- a/server/events/command_context.go
+++ /dev/null
@@ -1,52 +0,0 @@
-// Copyright 2017 HootSuite Media Inc.
-//
-// Licensed under the Apache License, Version 2.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-// http://www.apache.org/licenses/LICENSE-2.0
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an AS IS BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-// Modified hereafter by contributors to runatlantis/atlantis.
-package events
-
-import (
- "github.com/runatlantis/atlantis/server/events/models"
- "github.com/runatlantis/atlantis/server/logging"
- "github.com/uber-go/tally"
-)
-
-// CommandTrigger represents the how the command was triggered
-type CommandTrigger int
-
-const (
- // Commands that are automatically triggered (ie. automatic plans)
- Auto CommandTrigger = iota
-
- // Commands that are triggered by comments (ie. atlantis plan)
- Comment
-)
-
-// CommandContext represents the context of a command that should be executed
-// for a pull request.
-type CommandContext struct {
- // HeadRepo is the repository that is getting merged into the BaseRepo.
- // If the pull request branch is from the same repository then HeadRepo will
- // be the same as BaseRepo.
- // See https://help.github.com/articles/about-pull-request-merges/.
- HeadRepo models.Repo
- Pull models.PullRequest
- Scope tally.Scope
- // User is the user that triggered this command.
- User models.User
- Log logging.SimpleLogging
-
- // Current PR state
- PullRequestStatus models.PullReqStatus
-
- PullStatus *models.PullStatus
-
- Trigger CommandTrigger
-}
diff --git a/server/events/command_result.go b/server/events/command_result.go
deleted file mode 100644
index 655bf8a08..000000000
--- a/server/events/command_result.go
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright 2017 HootSuite Media Inc.
-//
-// Licensed under the Apache License, Version 2.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-// http://www.apache.org/licenses/LICENSE-2.0
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an AS IS BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-// Modified hereafter by contributors to runatlantis/atlantis.
-
-package events
-
-import "github.com/runatlantis/atlantis/server/events/models"
-
-// CommandResult is the result of running a Command.
-type CommandResult struct {
- Error error
- Failure string
- ProjectResults []models.ProjectResult
- // PlansDeleted is true if all plans created during this command were
- // deleted. This happens if automerging is enabled and one project has an
- // error since automerging requires all plans to succeed.
- PlansDeleted bool
-}
-
-// HasErrors returns true if there were any errors during the execution,
-// even if it was only in one project.
-func (c CommandResult) HasErrors() bool {
- if c.Error != nil || c.Failure != "" {
- return true
- }
- for _, r := range c.ProjectResults {
- if !r.IsSuccessful() {
- return true
- }
- }
- return false
-}
diff --git a/server/events/command_runner.go b/server/events/command_runner.go
index ebcca2a89..00d1aa932 100644
--- a/server/events/command_runner.go
+++ b/server/events/command_runner.go
@@ -21,6 +21,7 @@ import (
"github.com/mcdafydd/go-azuredevops/azuredevops"
"github.com/pkg/errors"
"github.com/runatlantis/atlantis/server/core/config/valid"
+ "github.com/runatlantis/atlantis/server/events/command"
"github.com/runatlantis/atlantis/server/events/models"
"github.com/runatlantis/atlantis/server/events/vcs"
"github.com/runatlantis/atlantis/server/logging"
@@ -71,12 +72,12 @@ type GitlabMergeRequestGetter interface {
// CommentCommandRunner runs individual command workflows.
type CommentCommandRunner interface {
- Run(*CommandContext, *CommentCommand)
+ Run(*command.Context, *CommentCommand)
}
func buildCommentCommandRunner(
cmdRunner *DefaultCommandRunner,
- cmdName models.CommandName,
+ cmdName command.Name,
) CommentCommandRunner {
// panic here, we want to fail fast and hard since
// this would be an internal service configuration error.
@@ -115,7 +116,7 @@ type DefaultCommandRunner struct {
// this in our error message back to the user on a forked PR so they know
// how to disable error comment
SilenceForkPRErrorsFlag string
- CommentCommandRunnerByCmd map[models.CommandName]CommentCommandRunner
+ CommentCommandRunnerByCmd map[command.Name]CommentCommandRunner
Drainer *Drainer
PreWorkflowHooksCommandRunner PreWorkflowHooksCommandRunner
PostWorkflowHooksCommandRunner PostWorkflowHooksCommandRunner
@@ -126,7 +127,7 @@ type DefaultCommandRunner struct {
// RunAutoplanCommand runs plan and policy_checks when a pull request is opened or updated.
func (c *DefaultCommandRunner) RunAutoplanCommand(baseRepo models.Repo, headRepo models.Repo, pull models.PullRequest, user models.User) {
if opStarted := c.Drainer.StartOp(); !opStarted {
- if commentErr := c.VCSClient.CreateComment(baseRepo, pull.Num, ShutdownComment, models.PlanCommand.String()); commentErr != nil {
+ if commentErr := c.VCSClient.CreateComment(baseRepo, pull.Num, ShutdownComment, command.Plan.String()); commentErr != nil {
c.Logger.Log(logging.Error, "unable to comment that Atlantis is shutting down: %s", commentErr)
}
return
@@ -145,14 +146,14 @@ func (c *DefaultCommandRunner) RunAutoplanCommand(baseRepo models.Repo, headRepo
timer := scope.Timer(metrics.ExecutionTimeMetric).Start()
defer timer.Stop()
- ctx := &CommandContext{
+ ctx := &command.Context{
User: user,
Log: log,
Scope: scope,
Pull: pull,
HeadRepo: headRepo,
PullStatus: status,
- Trigger: Auto,
+ Trigger: command.AutoTrigger,
}
if !c.validateCtxAndComment(ctx) {
return
@@ -164,10 +165,10 @@ func (c *DefaultCommandRunner) RunAutoplanCommand(baseRepo models.Repo, headRepo
err = c.PreWorkflowHooksCommandRunner.RunPreHooks(ctx)
if err != nil {
- ctx.Log.Err("Error running pre-workflow hooks %s. Proceeding with %s command.", err, models.PlanCommand)
+ ctx.Log.Err("Error running pre-workflow hooks %s. Proceeding with %s command.", err, command.Plan)
}
- autoPlanRunner := buildCommentCommandRunner(c, models.PlanCommand)
+ autoPlanRunner := buildCommentCommandRunner(c, command.Plan)
autoPlanRunner.Run(ctx, nil)
@@ -251,14 +252,14 @@ func (c *DefaultCommandRunner) RunCommentCommand(baseRepo models.Repo, maybeHead
log.Err("Unable to fetch pull status, this is likely a bug.", err)
}
- ctx := &CommandContext{
+ ctx := &command.Context{
User: user,
Log: log,
Pull: pull,
PullStatus: status,
HeadRepo: headRepo,
- Trigger: Comment,
Scope: scope,
+ Trigger: command.CommentTrigger,
}
if !c.validateCtxAndComment(ctx) {
@@ -371,7 +372,7 @@ func (c *DefaultCommandRunner) ensureValidRepoMetadata(
return
}
-func (c *DefaultCommandRunner) validateCtxAndComment(ctx *CommandContext) bool {
+func (c *DefaultCommandRunner) validateCtxAndComment(ctx *command.Context) bool {
if !c.AllowForkPRs && ctx.HeadRepo.Owner != ctx.Pull.BaseRepo.Owner {
if c.SilenceForkPRErrors {
return false
diff --git a/server/events/command_runner_internal_test.go b/server/events/command_runner_internal_test.go
index 440002645..5027a2510 100644
--- a/server/events/command_runner_internal_test.go
+++ b/server/events/command_runner_internal_test.go
@@ -3,20 +3,21 @@ package events
import (
"testing"
+ "github.com/runatlantis/atlantis/server/events/command"
"github.com/runatlantis/atlantis/server/events/models"
. "github.com/runatlantis/atlantis/testing"
)
func TestApplyUpdateCommitStatus(t *testing.T) {
cases := map[string]struct {
- cmd models.CommandName
+ cmd command.Name
pullStatus models.PullStatus
expStatus models.CommitStatus
expNumSuccess int
expNumTotal int
}{
"apply, one pending": {
- cmd: models.ApplyCommand,
+ cmd: command.Apply,
pullStatus: models.PullStatus{
Projects: []models.ProjectStatus{
{
@@ -32,7 +33,7 @@ func TestApplyUpdateCommitStatus(t *testing.T) {
expNumTotal: 2,
},
"apply, all successful": {
- cmd: models.ApplyCommand,
+ cmd: command.Apply,
pullStatus: models.PullStatus{
Projects: []models.ProjectStatus{
{
@@ -48,7 +49,7 @@ func TestApplyUpdateCommitStatus(t *testing.T) {
expNumTotal: 2,
},
"apply, one errored, one pending": {
- cmd: models.ApplyCommand,
+ cmd: command.Apply,
pullStatus: models.PullStatus{
Projects: []models.ProjectStatus{
{
@@ -74,7 +75,7 @@ func TestApplyUpdateCommitStatus(t *testing.T) {
cr := &ApplyCommandRunner{
commitStatusUpdater: csu,
}
- cr.updateCommitStatus(&CommandContext{}, c.pullStatus)
+ cr.updateCommitStatus(&command.Context{}, c.pullStatus)
Equals(t, models.Repo{}, csu.CalledRepo)
Equals(t, models.PullRequest{}, csu.CalledPull)
Equals(t, c.expStatus, csu.CalledStatus)
@@ -87,14 +88,14 @@ func TestApplyUpdateCommitStatus(t *testing.T) {
func TestPlanUpdateCommitStatus(t *testing.T) {
cases := map[string]struct {
- cmd models.CommandName
+ cmd command.Name
pullStatus models.PullStatus
expStatus models.CommitStatus
expNumSuccess int
expNumTotal int
}{
"single plan success": {
- cmd: models.PlanCommand,
+ cmd: command.Plan,
pullStatus: models.PullStatus{
Projects: []models.ProjectStatus{
{
@@ -107,7 +108,7 @@ func TestPlanUpdateCommitStatus(t *testing.T) {
expNumTotal: 1,
},
"one plan error, other errors": {
- cmd: models.PlanCommand,
+ cmd: command.Plan,
pullStatus: models.PullStatus{
Projects: []models.ProjectStatus{
{
@@ -136,7 +137,7 @@ func TestPlanUpdateCommitStatus(t *testing.T) {
cr := &PlanCommandRunner{
commitStatusUpdater: csu,
}
- cr.updateCommitStatus(&CommandContext{}, c.pullStatus)
+ cr.updateCommitStatus(&command.Context{}, c.pullStatus)
Equals(t, models.Repo{}, csu.CalledRepo)
Equals(t, models.PullRequest{}, csu.CalledPull)
Equals(t, c.expStatus, csu.CalledStatus)
@@ -151,12 +152,12 @@ type MockCSU struct {
CalledRepo models.Repo
CalledPull models.PullRequest
CalledStatus models.CommitStatus
- CalledCommand models.CommandName
+ CalledCommand command.Name
CalledNumSuccess int
CalledNumTotal int
}
-func (m *MockCSU) UpdateCombinedCount(repo models.Repo, pull models.PullRequest, status models.CommitStatus, command models.CommandName, numSuccess int, numTotal int) error {
+func (m *MockCSU) UpdateCombinedCount(repo models.Repo, pull models.PullRequest, status models.CommitStatus, command command.Name, numSuccess int, numTotal int) error {
m.CalledRepo = repo
m.CalledPull = pull
m.CalledStatus = status
@@ -165,9 +166,9 @@ func (m *MockCSU) UpdateCombinedCount(repo models.Repo, pull models.PullRequest,
m.CalledNumTotal = numTotal
return nil
}
-func (m *MockCSU) UpdateCombined(repo models.Repo, pull models.PullRequest, status models.CommitStatus, command models.CommandName) error {
+func (m *MockCSU) UpdateCombined(repo models.Repo, pull models.PullRequest, status models.CommitStatus, command command.Name) error {
return nil
}
-func (m *MockCSU) UpdateProject(ctx models.ProjectCommandContext, cmdName models.CommandName, status models.CommitStatus, url string) error {
+func (m *MockCSU) UpdateProject(ctx command.ProjectContext, cmdName command.Name, status models.CommitStatus, url string) error {
return nil
}
diff --git a/server/events/command_runner_test.go b/server/events/command_runner_test.go
index ded60c635..8c3634f03 100644
--- a/server/events/command_runner_test.go
+++ b/server/events/command_runner_test.go
@@ -22,6 +22,7 @@ import (
"github.com/runatlantis/atlantis/server/core/config/valid"
"github.com/runatlantis/atlantis/server/core/db"
+ "github.com/runatlantis/atlantis/server/events/command"
"github.com/runatlantis/atlantis/server/events/vcs"
"github.com/runatlantis/atlantis/server/logging"
"github.com/runatlantis/atlantis/server/metrics"
@@ -176,12 +177,12 @@ func setup(t *testing.T) *vcsmocks.MockClient {
SilenceNoProjects,
)
- commentCommandRunnerByCmd := map[models.CommandName]events.CommentCommandRunner{
- models.PlanCommand: planCommandRunner,
- models.ApplyCommand: applyCommandRunner,
- models.ApprovePoliciesCommand: approvePoliciesCommandRunner,
- models.UnlockCommand: unlockCommandRunner,
- models.VersionCommand: versionCommandRunner,
+ commentCommandRunnerByCmd := map[command.Name]events.CommentCommandRunner{
+ command.Plan: planCommandRunner,
+ command.Apply: applyCommandRunner,
+ command.ApprovePolicies: approvePoliciesCommandRunner,
+ command.Unlock: unlockCommandRunner,
+ command.Version: versionCommandRunner,
}
preWorkflowHooksCommandRunner = mocks.NewMockPreWorkflowHooksCommandRunner()
@@ -219,7 +220,7 @@ func TestRunCommentCommand_LogPanics(t *testing.T) {
t.Log("if there is a panic it is commented back on the pull request")
vcsClient := setup(t)
When(githubGetter.GetPullRequest(fixtures.GithubRepo, fixtures.Pull.Num)).ThenPanic("panic test - if you're seeing this in a test failure this isn't the failing test")
- ch.RunCommentCommand(fixtures.GithubRepo, &fixtures.GithubRepo, nil, fixtures.User, 1, &events.CommentCommand{Name: models.PlanCommand})
+ ch.RunCommentCommand(fixtures.GithubRepo, &fixtures.GithubRepo, nil, fixtures.User, 1, &events.CommentCommand{Name: command.Plan})
_, _, comment, _ := vcsClient.VerifyWasCalledOnce().CreateComment(matchers.AnyModelsRepo(), AnyInt(), AnyString(), AnyString()).GetCapturedArguments()
Assert(t, strings.Contains(comment, "Error: goroutine panic"), fmt.Sprintf("comment should be about a goroutine panic but was %q", comment))
}
@@ -264,7 +265,7 @@ func TestRunCommentCommand_TeamAllowListChecker(t *testing.T) {
When(githubGetter.GetPullRequest(fixtures.GithubRepo, fixtures.Pull.Num)).ThenReturn(&pull, nil)
When(eventParsing.ParseGithubPull(&pull)).ThenReturn(modelPull, modelPull.BaseRepo, fixtures.GithubRepo, nil)
- ch.RunCommentCommand(fixtures.GithubRepo, nil, nil, fixtures.User, fixtures.Pull.Num, &events.CommentCommand{Name: models.PlanCommand})
+ ch.RunCommentCommand(fixtures.GithubRepo, nil, nil, fixtures.User, fixtures.Pull.Num, &events.CommentCommand{Name: command.Plan})
vcsClient.VerifyWasCalled(Never()).GetTeamNamesForUser(fixtures.GithubRepo, fixtures.User)
vcsClient.VerifyWasCalledOnce().CreateComment(fixtures.GithubRepo, modelPull.Num, "Ran Plan for 0 projects:\n\n\n\n", "plan")
})
@@ -281,7 +282,7 @@ func TestRunCommentCommand_TeamAllowListChecker(t *testing.T) {
When(githubGetter.GetPullRequest(fixtures.GithubRepo, fixtures.Pull.Num)).ThenReturn(&pull, nil)
When(eventParsing.ParseGithubPull(&pull)).ThenReturn(modelPull, modelPull.BaseRepo, fixtures.GithubRepo, nil)
- ch.RunCommentCommand(fixtures.GithubRepo, nil, nil, fixtures.User, fixtures.Pull.Num, &events.CommentCommand{Name: models.PlanCommand})
+ ch.RunCommentCommand(fixtures.GithubRepo, nil, nil, fixtures.User, fixtures.Pull.Num, &events.CommentCommand{Name: command.Plan})
vcsClient.VerifyWasCalled(Never()).GetTeamNamesForUser(fixtures.GithubRepo, fixtures.User)
vcsClient.VerifyWasCalledOnce().CreateComment(fixtures.GithubRepo, modelPull.Num, "Ran Plan for 0 projects:\n\n\n\n", "plan")
})
@@ -338,13 +339,13 @@ func TestRunCommentCommandPlan_NoProjects_SilenceEnabled(t *testing.T) {
When(githubGetter.GetPullRequest(fixtures.GithubRepo, fixtures.Pull.Num)).ThenReturn(&pull, nil)
When(eventParsing.ParseGithubPull(&pull)).ThenReturn(modelPull, modelPull.BaseRepo, fixtures.GithubRepo, nil)
- ch.RunCommentCommand(fixtures.GithubRepo, nil, nil, fixtures.User, fixtures.Pull.Num, &events.CommentCommand{Name: models.PlanCommand})
+ ch.RunCommentCommand(fixtures.GithubRepo, nil, nil, fixtures.User, fixtures.Pull.Num, &events.CommentCommand{Name: command.Plan})
vcsClient.VerifyWasCalled(Never()).CreateComment(matchers.AnyModelsRepo(), AnyInt(), AnyString(), AnyString())
commitUpdater.VerifyWasCalledOnce().UpdateCombinedCount(
matchers.AnyModelsRepo(),
matchers.AnyModelsPullRequest(),
matchers.EqModelsCommitStatus(models.SuccessCommitStatus),
- matchers.EqModelsCommandName(models.PlanCommand),
+ matchers.EqModelsCommandName(command.Plan),
EqInt(0),
EqInt(0),
)
@@ -359,13 +360,13 @@ func TestRunCommentCommandApply_NoProjects_SilenceEnabled(t *testing.T) {
When(githubGetter.GetPullRequest(fixtures.GithubRepo, fixtures.Pull.Num)).ThenReturn(&pull, nil)
When(eventParsing.ParseGithubPull(&pull)).ThenReturn(modelPull, modelPull.BaseRepo, fixtures.GithubRepo, nil)
- ch.RunCommentCommand(fixtures.GithubRepo, nil, nil, fixtures.User, fixtures.Pull.Num, &events.CommentCommand{Name: models.ApplyCommand})
+ ch.RunCommentCommand(fixtures.GithubRepo, nil, nil, fixtures.User, fixtures.Pull.Num, &events.CommentCommand{Name: command.Apply})
vcsClient.VerifyWasCalled(Never()).CreateComment(matchers.AnyModelsRepo(), AnyInt(), AnyString(), AnyString())
commitUpdater.VerifyWasCalledOnce().UpdateCombinedCount(
matchers.AnyModelsRepo(),
matchers.AnyModelsPullRequest(),
matchers.EqModelsCommitStatus(models.SuccessCommitStatus),
- matchers.EqModelsCommandName(models.ApplyCommand),
+ matchers.EqModelsCommandName(command.Apply),
EqInt(0),
EqInt(0),
)
@@ -380,13 +381,13 @@ func TestRunCommentCommandApprovePolicy_NoProjects_SilenceEnabled(t *testing.T)
When(githubGetter.GetPullRequest(fixtures.GithubRepo, fixtures.Pull.Num)).ThenReturn(&pull, nil)
When(eventParsing.ParseGithubPull(&pull)).ThenReturn(modelPull, modelPull.BaseRepo, fixtures.GithubRepo, nil)
- ch.RunCommentCommand(fixtures.GithubRepo, nil, nil, fixtures.User, fixtures.Pull.Num, &events.CommentCommand{Name: models.ApprovePoliciesCommand})
+ ch.RunCommentCommand(fixtures.GithubRepo, nil, nil, fixtures.User, fixtures.Pull.Num, &events.CommentCommand{Name: command.ApprovePolicies})
vcsClient.VerifyWasCalled(Never()).CreateComment(matchers.AnyModelsRepo(), AnyInt(), AnyString(), AnyString())
commitUpdater.VerifyWasCalledOnce().UpdateCombinedCount(
matchers.AnyModelsRepo(),
matchers.AnyModelsPullRequest(),
matchers.EqModelsCommitStatus(models.SuccessCommitStatus),
- matchers.EqModelsCommandName(models.PolicyCheckCommand),
+ matchers.EqModelsCommandName(command.PolicyCheck),
EqInt(0),
EqInt(0),
)
@@ -401,7 +402,7 @@ func TestRunCommentCommandUnlock_NoProjects_SilenceEnabled(t *testing.T) {
When(githubGetter.GetPullRequest(fixtures.GithubRepo, fixtures.Pull.Num)).ThenReturn(&pull, nil)
When(eventParsing.ParseGithubPull(&pull)).ThenReturn(modelPull, modelPull.BaseRepo, fixtures.GithubRepo, nil)
- ch.RunCommentCommand(fixtures.GithubRepo, nil, nil, fixtures.User, fixtures.Pull.Num, &events.CommentCommand{Name: models.UnlockCommand})
+ ch.RunCommentCommand(fixtures.GithubRepo, nil, nil, fixtures.User, fixtures.Pull.Num, &events.CommentCommand{Name: command.Unlock})
vcsClient.VerifyWasCalled(Never()).CreateComment(matchers.AnyModelsRepo(), AnyInt(), AnyString(), AnyString())
}
@@ -417,7 +418,7 @@ func TestRunCommentCommand_DisableApplyAllDisabled(t *testing.T) {
When(githubGetter.GetPullRequest(fixtures.GithubRepo, fixtures.Pull.Num)).ThenReturn(pull, nil)
When(eventParsing.ParseGithubPull(pull)).ThenReturn(modelPull, modelPull.BaseRepo, fixtures.GithubRepo, nil)
- ch.RunCommentCommand(fixtures.GithubRepo, nil, nil, fixtures.User, modelPull.Num, &events.CommentCommand{Name: models.ApplyCommand})
+ ch.RunCommentCommand(fixtures.GithubRepo, nil, nil, fixtures.User, modelPull.Num, &events.CommentCommand{Name: command.Apply})
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
`, `-w ` or `-p ` flags.", "apply")
}
@@ -428,12 +429,12 @@ func TestRunCommentCommand_DisableDisableAutoplan(t *testing.T) {
defer func() { ch.DisableAutoplan = false }()
When(projectCommandBuilder.BuildAutoplanCommands(matchers.AnyPtrToEventsCommandContext())).
- ThenReturn([]models.ProjectCommandContext{
+ ThenReturn([]command.ProjectContext{
{
- CommandName: models.PlanCommand,
+ CommandName: command.Plan,
},
{
- CommandName: models.PlanCommand,
+ CommandName: command.Plan,
},
}, nil)
@@ -469,7 +470,7 @@ func TestRunCommentCommand_MatchedBranch(t *testing.T) {
When(githubGetter.GetPullRequest(fixtures.GithubRepo, fixtures.Pull.Num)).ThenReturn(&pull, nil)
When(eventParsing.ParseGithubPull(&pull)).ThenReturn(modelPull, modelPull.BaseRepo, fixtures.GithubRepo, nil)
- ch.RunCommentCommand(fixtures.GithubRepo, nil, nil, fixtures.User, fixtures.Pull.Num, &events.CommentCommand{Name: models.PlanCommand})
+ ch.RunCommentCommand(fixtures.GithubRepo, nil, nil, fixtures.User, fixtures.Pull.Num, &events.CommentCommand{Name: command.Plan})
vcsClient.VerifyWasCalledOnce().CreateComment(fixtures.GithubRepo, modelPull.Num, "Ran Plan for 0 projects:\n\n\n\n", "plan")
}
@@ -486,7 +487,7 @@ func TestRunCommentCommand_UnmatchedBranch(t *testing.T) {
When(githubGetter.GetPullRequest(fixtures.GithubRepo, fixtures.Pull.Num)).ThenReturn(&pull, nil)
When(eventParsing.ParseGithubPull(&pull)).ThenReturn(modelPull, modelPull.BaseRepo, fixtures.GithubRepo, nil)
- ch.RunCommentCommand(fixtures.GithubRepo, nil, nil, fixtures.User, fixtures.Pull.Num, &events.CommentCommand{Name: models.PlanCommand})
+ ch.RunCommentCommand(fixtures.GithubRepo, nil, nil, fixtures.User, fixtures.Pull.Num, &events.CommentCommand{Name: command.Plan})
vcsClient.VerifyWasCalled(Never()).CreateComment(matchers.AnyModelsRepo(), AnyInt(), AnyString(), AnyString())
}
@@ -502,7 +503,7 @@ func TestRunUnlockCommand_VCSComment(t *testing.T) {
When(githubGetter.GetPullRequest(fixtures.GithubRepo, fixtures.Pull.Num)).ThenReturn(pull, nil)
When(eventParsing.ParseGithubPull(pull)).ThenReturn(modelPull, modelPull.BaseRepo, fixtures.GithubRepo, nil)
- ch.RunCommentCommand(fixtures.GithubRepo, &fixtures.GithubRepo, nil, fixtures.User, fixtures.Pull.Num, &events.CommentCommand{Name: models.UnlockCommand})
+ ch.RunCommentCommand(fixtures.GithubRepo, &fixtures.GithubRepo, nil, fixtures.User, fixtures.Pull.Num, &events.CommentCommand{Name: command.Unlock})
deleteLockCommand.VerifyWasCalledOnce().DeleteLocksByPull(fixtures.GithubRepo.FullName, fixtures.Pull.Num)
vcsClient.VerifyWasCalledOnce().CreateComment(fixtures.GithubRepo, fixtures.Pull.Num, "All Atlantis locks for this PR have been unlocked and plans discarded", "unlock")
@@ -521,7 +522,7 @@ func TestRunUnlockCommandFail_VCSComment(t *testing.T) {
When(eventParsing.ParseGithubPull(pull)).ThenReturn(modelPull, modelPull.BaseRepo, fixtures.GithubRepo, nil)
When(deleteLockCommand.DeleteLocksByPull(fixtures.GithubRepo.FullName, fixtures.Pull.Num)).ThenReturn(0, errors.New("err"))
- ch.RunCommentCommand(fixtures.GithubRepo, &fixtures.GithubRepo, nil, fixtures.User, fixtures.Pull.Num, &events.CommentCommand{Name: models.UnlockCommand})
+ ch.RunCommentCommand(fixtures.GithubRepo, &fixtures.GithubRepo, nil, fixtures.User, fixtures.Pull.Num, &events.CommentCommand{Name: command.Unlock})
vcsClient.VerifyWasCalledOnce().CreateComment(fixtures.GithubRepo, fixtures.Pull.Num, "Failed to delete PR locks", "unlock")
}
@@ -540,12 +541,12 @@ func TestRunAutoplanCommand_DeletePlans(t *testing.T) {
defer func() { autoMerger.GlobalAutomerge = false }()
When(projectCommandBuilder.BuildAutoplanCommands(matchers.AnyPtrToEventsCommandContext())).
- ThenReturn([]models.ProjectCommandContext{
+ ThenReturn([]command.ProjectContext{
{
- CommandName: models.PlanCommand,
+ CommandName: command.Plan,
},
{
- CommandName: models.PlanCommand,
+ CommandName: command.Plan,
},
}, nil)
callCount := 0
@@ -554,14 +555,14 @@ func TestRunAutoplanCommand_DeletePlans(t *testing.T) {
// The first call, we return a successful result.
callCount++
return ReturnValues{
- models.ProjectResult{
+ command.ProjectResult{
PlanSuccess: &models.PlanSuccess{},
},
}
}
// The second call, we return a failed result.
return ReturnValues{
- models.ProjectResult{
+ command.ProjectResult{
Error: errors.New("err"),
},
}
@@ -598,23 +599,23 @@ func TestFailedApprovalCreatesFailedStatusUpdate(t *testing.T) {
When(githubGetter.GetPullRequest(fixtures.GithubRepo, fixtures.Pull.Num)).ThenReturn(pull, nil)
When(eventParsing.ParseGithubPull(pull)).ThenReturn(modelPull, modelPull.BaseRepo, fixtures.GithubRepo, nil)
- When(projectCommandBuilder.BuildApprovePoliciesCommands(matchers.AnyPtrToEventsCommandContext(), matchers.AnyPtrToEventsCommentCommand())).ThenReturn([]models.ProjectCommandContext{
+ When(projectCommandBuilder.BuildApprovePoliciesCommands(matchers.AnyPtrToEventsCommandContext(), matchers.AnyPtrToEventsCommentCommand())).ThenReturn([]command.ProjectContext{
{
- CommandName: models.ApprovePoliciesCommand,
+ CommandName: command.ApprovePolicies,
},
{
- CommandName: models.ApprovePoliciesCommand,
+ CommandName: command.ApprovePolicies,
},
}, nil)
When(workingDir.GetPullDir(fixtures.GithubRepo, fixtures.Pull)).ThenReturn(tmp, nil)
- ch.RunCommentCommand(fixtures.GithubRepo, &fixtures.GithubRepo, &fixtures.Pull, fixtures.User, fixtures.Pull.Num, &events.CommentCommand{Name: models.ApprovePoliciesCommand})
+ ch.RunCommentCommand(fixtures.GithubRepo, &fixtures.GithubRepo, &fixtures.Pull, fixtures.User, fixtures.Pull.Num, &events.CommentCommand{Name: command.ApprovePolicies})
commitUpdater.VerifyWasCalledOnce().UpdateCombinedCount(
matchers.AnyModelsRepo(),
matchers.AnyModelsPullRequest(),
matchers.EqModelsCommitStatus(models.SuccessCommitStatus),
- matchers.EqModelsCommandName(models.PolicyCheckCommand),
+ matchers.EqModelsCommandName(command.PolicyCheck),
EqInt(0),
EqInt(0),
)
@@ -644,9 +645,9 @@ func TestApprovedPoliciesUpdateFailedPolicyStatus(t *testing.T) {
When(githubGetter.GetPullRequest(fixtures.GithubRepo, fixtures.Pull.Num)).ThenReturn(pull, nil)
When(eventParsing.ParseGithubPull(pull)).ThenReturn(modelPull, modelPull.BaseRepo, fixtures.GithubRepo, nil)
- When(projectCommandBuilder.BuildApprovePoliciesCommands(matchers.AnyPtrToEventsCommandContext(), matchers.AnyPtrToEventsCommentCommand())).ThenReturn([]models.ProjectCommandContext{
+ When(projectCommandBuilder.BuildApprovePoliciesCommands(matchers.AnyPtrToEventsCommandContext(), matchers.AnyPtrToEventsCommentCommand())).ThenReturn([]command.ProjectContext{
{
- CommandName: models.ApprovePoliciesCommand,
+ CommandName: command.ApprovePolicies,
PolicySets: valid.PolicySets{
Owners: valid.PolicyOwners{
Users: []string{fixtures.User.Username},
@@ -658,19 +659,19 @@ func TestApprovedPoliciesUpdateFailedPolicyStatus(t *testing.T) {
When(workingDir.GetPullDir(fixtures.GithubRepo, fixtures.Pull)).ThenReturn(tmp, nil)
When(projectCommandRunner.ApprovePolicies(matchers.AnyModelsProjectCommandContext())).Then(func(_ []Param) ReturnValues {
return ReturnValues{
- models.ProjectResult{
- Command: models.PolicyCheckCommand,
+ command.ProjectResult{
+ Command: command.PolicyCheck,
PolicyCheckSuccess: &models.PolicyCheckSuccess{},
},
}
})
- ch.RunCommentCommand(fixtures.GithubRepo, &fixtures.GithubRepo, &fixtures.Pull, fixtures.User, fixtures.Pull.Num, &events.CommentCommand{Name: models.ApprovePoliciesCommand})
+ ch.RunCommentCommand(fixtures.GithubRepo, &fixtures.GithubRepo, &fixtures.Pull, fixtures.User, fixtures.Pull.Num, &events.CommentCommand{Name: command.ApprovePolicies})
commitUpdater.VerifyWasCalledOnce().UpdateCombinedCount(
matchers.AnyModelsRepo(),
matchers.AnyModelsPullRequest(),
matchers.EqModelsCommitStatus(models.SuccessCommitStatus),
- matchers.EqModelsCommandName(models.PolicyCheckCommand),
+ matchers.EqModelsCommandName(command.PolicyCheck),
EqInt(1),
EqInt(1),
)
@@ -700,9 +701,9 @@ func TestApplyMergeablityWhenPolicyCheckFails(t *testing.T) {
When(githubGetter.GetPullRequest(fixtures.GithubRepo, fixtures.Pull.Num)).ThenReturn(pull, nil)
When(eventParsing.ParseGithubPull(pull)).ThenReturn(modelPull, modelPull.BaseRepo, fixtures.GithubRepo, nil)
- _, _ = boltDB.UpdatePullWithResults(modelPull, []models.ProjectResult{
+ _, _ = boltDB.UpdatePullWithResults(modelPull, []command.ProjectResult{
{
- Command: models.PolicyCheckCommand,
+ Command: command.PolicyCheck,
Error: fmt.Errorf("failing policy"),
ProjectName: "default",
Workspace: "default",
@@ -714,9 +715,9 @@ func TestApplyMergeablityWhenPolicyCheckFails(t *testing.T) {
When(projectCommandBuilder.BuildApplyCommands(matchers.AnyPtrToEventsCommandContext(), matchers.AnyPtrToEventsCommentCommand())).Then(func(args []Param) ReturnValues {
return ReturnValues{
- []models.ProjectCommandContext{
+ []command.ProjectContext{
{
- CommandName: models.ApplyCommand,
+ CommandName: command.Apply,
ProjectName: "default",
Workspace: "default",
RepoRelDir: ".",
@@ -728,7 +729,7 @@ func TestApplyMergeablityWhenPolicyCheckFails(t *testing.T) {
})
When(workingDir.GetPullDir(fixtures.GithubRepo, modelPull)).ThenReturn(tmp, nil)
- ch.RunCommentCommand(fixtures.GithubRepo, &fixtures.GithubRepo, &modelPull, fixtures.User, fixtures.Pull.Num, &events.CommentCommand{Name: models.ApplyCommand})
+ ch.RunCommentCommand(fixtures.GithubRepo, &fixtures.GithubRepo, &modelPull, fixtures.User, fixtures.Pull.Num, &events.CommentCommand{Name: command.Apply})
}
func TestApplyWithAutoMerge_VSCMerge(t *testing.T) {
@@ -748,7 +749,7 @@ func TestApplyWithAutoMerge_VSCMerge(t *testing.T) {
DeleteSourceBranchOnMerge: false,
}
- ch.RunCommentCommand(fixtures.GithubRepo, &fixtures.GithubRepo, nil, fixtures.User, fixtures.Pull.Num, &events.CommentCommand{Name: models.ApplyCommand})
+ ch.RunCommentCommand(fixtures.GithubRepo, &fixtures.GithubRepo, nil, fixtures.User, fixtures.Pull.Num, &events.CommentCommand{Name: command.Apply})
vcsClient.VerifyWasCalledOnce().MergePull(modelPull, pullOptions)
}
@@ -766,9 +767,9 @@ func TestRunApply_DiscardedProjects(t *testing.T) {
applyCommandRunner.DB = boltDB
pull := fixtures.Pull
pull.BaseRepo = fixtures.GithubRepo
- _, err = boltDB.UpdatePullWithResults(pull, []models.ProjectResult{
+ _, err = boltDB.UpdatePullWithResults(pull, []command.ProjectResult{
{
- Command: models.PlanCommand,
+ Command: command.Plan,
RepoRelDir: ".",
Workspace: "default",
PlanSuccess: &models.PlanSuccess{
@@ -786,7 +787,7 @@ func TestRunApply_DiscardedProjects(t *testing.T) {
When(eventParsing.ParseGithubPull(ghPull)).ThenReturn(pull, pull.BaseRepo, fixtures.GithubRepo, nil)
When(workingDir.GetPullDir(matchers.AnyModelsRepo(), matchers.AnyModelsPullRequest())).
ThenReturn(tmp, nil)
- ch.RunCommentCommand(fixtures.GithubRepo, &fixtures.GithubRepo, &pull, fixtures.User, fixtures.Pull.Num, &events.CommentCommand{Name: models.ApplyCommand})
+ ch.RunCommentCommand(fixtures.GithubRepo, &fixtures.GithubRepo, &pull, fixtures.User, fixtures.Pull.Num, &events.CommentCommand{Name: command.Apply})
vcsClient.VerifyWasCalled(Never()).MergePull(matchers.AnyModelsPullRequest(), matchers.AnyModelsPullRequestOptions())
}
diff --git a/server/events/comment_parser.go b/server/events/comment_parser.go
index e8996a71c..a4433e863 100644
--- a/server/events/comment_parser.go
+++ b/server/events/comment_parser.go
@@ -25,6 +25,7 @@ import (
"github.com/flynn-archive/go-shlex"
"github.com/runatlantis/atlantis/server/core/config"
+ "github.com/runatlantis/atlantis/server/events/command"
"github.com/runatlantis/atlantis/server/events/models"
"github.com/spf13/pflag"
)
@@ -162,16 +163,16 @@ func (e *CommentParser) Parse(comment string, vcsHost models.VCSHostType) Commen
if len(args) == 1 {
return CommentParseResult{CommentResponse: e.HelpComment(e.ApplyDisabled)}
}
- command := args[1]
+ cmd := args[1]
// Help output.
- if e.stringInSlice(command, []string{"help", "-h", "--help"}) {
+ if e.stringInSlice(cmd, []string{"help", "-h", "--help"}) {
return CommentParseResult{CommentResponse: e.HelpComment(e.ApplyDisabled)}
}
- // Need plan, apply, unlock, approve_policies, or version at this point.
- if !e.stringInSlice(command, []string{models.PlanCommand.String(), models.ApplyCommand.String(), models.UnlockCommand.String(), models.ApprovePoliciesCommand.String(), models.VersionCommand.String()}) {
- return CommentParseResult{CommentResponse: fmt.Sprintf("```\nError: unknown command %q.\nRun 'atlantis --help' for usage.\n```", command)}
+ // Need to have a plan, apply, approve_policy or unlock at this point.
+ if !e.stringInSlice(cmd, []string{command.Plan.String(), command.Apply.String(), command.Unlock.String(), command.ApprovePolicies.String(), command.Version.String()}) {
+ return CommentParseResult{CommentResponse: fmt.Sprintf("```\nError: unknown command %q.\nRun 'atlantis --help' for usage.\n```", cmd)}
}
var workspace string
@@ -179,58 +180,58 @@ func (e *CommentParser) Parse(comment string, vcsHost models.VCSHostType) Commen
var project string
var verbose, autoMergeDisabled bool
var flagSet *pflag.FlagSet
- var name models.CommandName
+ var name command.Name
// Set up the flag parsing depending on the command.
- switch command {
- case models.PlanCommand.String():
- name = models.PlanCommand
- flagSet = pflag.NewFlagSet(models.PlanCommand.String(), pflag.ContinueOnError)
+ switch cmd {
+ case command.Plan.String():
+ name = command.Plan
+ flagSet = pflag.NewFlagSet(command.Plan.String(), pflag.ContinueOnError)
flagSet.SetOutput(io.Discard)
flagSet.StringVarP(&workspace, workspaceFlagLong, workspaceFlagShort, "", "Switch to this Terraform workspace before planning.")
flagSet.StringVarP(&dir, dirFlagLong, dirFlagShort, "", "Which directory to run plan in relative to root of repo, ex. 'child/dir'.")
flagSet.StringVarP(&project, projectFlagLong, projectFlagShort, "", fmt.Sprintf("Which project to run plan for. Refers to the name of the project configured in %s. Cannot be used at same time as workspace or dir flags.", config.AtlantisYAMLFilename))
flagSet.BoolVarP(&verbose, verboseFlagLong, verboseFlagShort, false, "Append Atlantis log to comment.")
- case models.ApplyCommand.String():
- name = models.ApplyCommand
- flagSet = pflag.NewFlagSet(models.ApplyCommand.String(), pflag.ContinueOnError)
+ case command.Apply.String():
+ name = command.Apply
+ flagSet = pflag.NewFlagSet(command.Apply.String(), pflag.ContinueOnError)
flagSet.SetOutput(io.Discard)
flagSet.StringVarP(&workspace, workspaceFlagLong, workspaceFlagShort, "", "Apply the plan for this Terraform workspace.")
flagSet.StringVarP(&dir, dirFlagLong, dirFlagShort, "", "Apply the plan for this directory, relative to root of repo, ex. 'child/dir'.")
flagSet.StringVarP(&project, projectFlagLong, projectFlagShort, "", fmt.Sprintf("Apply the plan for this project. Refers to the name of the project configured in %s. Cannot be used at same time as workspace or dir flags.", config.AtlantisYAMLFilename))
flagSet.BoolVarP(&autoMergeDisabled, autoMergeDisabledFlagLong, autoMergeDisabledFlagShort, false, "Disable automerge after apply.")
flagSet.BoolVarP(&verbose, verboseFlagLong, verboseFlagShort, false, "Append Atlantis log to comment.")
- case models.ApprovePoliciesCommand.String():
- name = models.ApprovePoliciesCommand
- flagSet = pflag.NewFlagSet(models.ApprovePoliciesCommand.String(), pflag.ContinueOnError)
+ case command.ApprovePolicies.String():
+ name = command.ApprovePolicies
+ flagSet = pflag.NewFlagSet(command.ApprovePolicies.String(), pflag.ContinueOnError)
flagSet.SetOutput(io.Discard)
flagSet.BoolVarP(&verbose, verboseFlagLong, verboseFlagShort, false, "Append Atlantis log to comment.")
- case models.UnlockCommand.String():
- name = models.UnlockCommand
- flagSet = pflag.NewFlagSet(models.UnlockCommand.String(), pflag.ContinueOnError)
+ case command.Unlock.String():
+ name = command.Unlock
+ flagSet = pflag.NewFlagSet(command.Unlock.String(), pflag.ContinueOnError)
flagSet.SetOutput(io.Discard)
- case models.VersionCommand.String():
- name = models.VersionCommand
- flagSet = pflag.NewFlagSet(models.VersionCommand.String(), pflag.ContinueOnError)
+ case command.Version.String():
+ name = command.Version
+ flagSet = pflag.NewFlagSet(command.Version.String(), pflag.ContinueOnError)
flagSet.StringVarP(&workspace, workspaceFlagLong, workspaceFlagShort, "", "Switch to this Terraform workspace before running version.")
flagSet.StringVarP(&dir, dirFlagLong, dirFlagShort, "", "Which directory to run version in relative to root of repo, ex. 'child/dir'.")
flagSet.StringVarP(&project, projectFlagLong, projectFlagShort, "", fmt.Sprintf("Print the version for this project. Refers to the name of the project configured in %s.", config.AtlantisYAMLFilename))
flagSet.BoolVarP(&verbose, verboseFlagLong, verboseFlagShort, false, "Append Atlantis log to comment.")
default:
- return CommentParseResult{CommentResponse: fmt.Sprintf("Error: unknown command %q – this is a bug", command)}
+ return CommentParseResult{CommentResponse: fmt.Sprintf("Error: unknown command %q – this is a bug", cmd)}
}
// Now parse the flags.
// It's safe to use [2:] because we know there's at least 2 elements in args.
err = flagSet.Parse(args[2:])
if err == pflag.ErrHelp {
- return CommentParseResult{CommentResponse: fmt.Sprintf("```\nUsage of %s:\n%s\n```", command, flagSet.FlagUsagesWrapped(usagesCols))}
+ return CommentParseResult{CommentResponse: fmt.Sprintf("```\nUsage of %s:\n%s\n```", cmd, flagSet.FlagUsagesWrapped(usagesCols))}
}
if err != nil {
- if command == models.UnlockCommand.String() {
+ if cmd == command.Unlock.String() {
return CommentParseResult{CommentResponse: UnlockUsage}
}
- return CommentParseResult{CommentResponse: e.errMarkdown(err.Error(), command, flagSet)}
+ return CommentParseResult{CommentResponse: e.errMarkdown(err.Error(), cmd, flagSet)}
}
var unusedArgs []string
@@ -240,7 +241,7 @@ func (e *CommentParser) Parse(comment string, vcsHost models.VCSHostType) Commen
unusedArgs = flagSet.Args()[0:flagSet.ArgsLenAtDash()]
}
if len(unusedArgs) > 0 {
- return CommentParseResult{CommentResponse: e.errMarkdown(fmt.Sprintf("unknown argument(s) – %s", strings.Join(unusedArgs, " ")), command, flagSet)}
+ return CommentParseResult{CommentResponse: e.errMarkdown(fmt.Sprintf("unknown argument(s) – %s", strings.Join(unusedArgs, " ")), cmd, flagSet)}
}
var extraArgs []string
@@ -250,14 +251,14 @@ func (e *CommentParser) Parse(comment string, vcsHost models.VCSHostType) Commen
dir, err = e.validateDir(dir)
if err != nil {
- return CommentParseResult{CommentResponse: e.errMarkdown(err.Error(), command, flagSet)}
+ return CommentParseResult{CommentResponse: e.errMarkdown(err.Error(), cmd, flagSet)}
}
// Use the same validation that Terraform uses: https://git.io/vxGhU. Plus
// we also don't allow '..'. We don't want the workspace to contain a path
// since we create files based on the name.
if workspace != url.PathEscape(workspace) || strings.Contains(workspace, "..") {
- return CommentParseResult{CommentResponse: e.errMarkdown(fmt.Sprintf("invalid workspace: %q", workspace), command, flagSet)}
+ return CommentParseResult{CommentResponse: e.errMarkdown(fmt.Sprintf("invalid workspace: %q", workspace), cmd, flagSet)}
}
// If project is specified, dir or workspace should not be set. Since we
@@ -267,7 +268,7 @@ func (e *CommentParser) Parse(comment string, vcsHost models.VCSHostType) Commen
// an error.
if project != "" && (workspace != "" || dir != "") {
err := fmt.Sprintf("cannot use -%s/--%s at same time as -%s/--%s or -%s/--%s", projectFlagShort, projectFlagLong, dirFlagShort, dirFlagLong, workspaceFlagShort, workspaceFlagLong)
- return CommentParseResult{CommentResponse: e.errMarkdown(err, command, flagSet)}
+ return CommentParseResult{CommentResponse: e.errMarkdown(err, cmd, flagSet)}
}
return CommentParseResult{
@@ -288,19 +289,19 @@ func (e *CommentParser) BuildPlanComment(repoRelDir string, workspace string, pr
}
commentFlags = fmt.Sprintf(" -- %s", strings.Join(flagsWithoutQuotes, " "))
}
- return fmt.Sprintf("%s %s%s%s", atlantisExecutable, models.PlanCommand.String(), flags, commentFlags)
+ return fmt.Sprintf("%s %s%s%s", atlantisExecutable, command.Plan.String(), flags, commentFlags)
}
// BuildApplyComment builds an apply comment for the specified args.
func (e *CommentParser) BuildApplyComment(repoRelDir string, workspace string, project string, autoMergeDisabled bool) string {
flags := e.buildFlags(repoRelDir, workspace, project, autoMergeDisabled)
- return fmt.Sprintf("%s %s%s", atlantisExecutable, models.ApplyCommand.String(), flags)
+ return fmt.Sprintf("%s %s%s", atlantisExecutable, command.Apply.String(), flags)
}
// BuildVersionComment builds a version comment for the specified args.
func (e *CommentParser) BuildVersionComment(repoRelDir string, workspace string, project string) string {
flags := e.buildFlags(repoRelDir, workspace, project, false)
- return fmt.Sprintf("%s %s%s", atlantisExecutable, models.VersionCommand.String(), flags)
+ return fmt.Sprintf("%s %s%s", atlantisExecutable, command.Version.String(), flags)
}
func (e *CommentParser) buildFlags(repoRelDir string, workspace string, project string, autoMergeDisabled bool) string {
@@ -361,8 +362,8 @@ func (e *CommentParser) stringInSlice(a string, list []string) bool {
return false
}
-func (e *CommentParser) errMarkdown(errMsg string, command string, flagSet *pflag.FlagSet) string {
- return fmt.Sprintf("```\nError: %s.\nUsage of %s:\n%s```", errMsg, command, flagSet.FlagUsagesWrapped(usagesCols))
+func (e *CommentParser) errMarkdown(errMsg string, cmd string, flagSet *pflag.FlagSet) string {
+ return fmt.Sprintf("```\nError: %s.\nUsage of %s:\n%s```", errMsg, cmd, flagSet.FlagUsagesWrapped(usagesCols))
}
func (e *CommentParser) HelpComment(applyDisabled bool) string {
diff --git a/server/events/comment_parser_test.go b/server/events/comment_parser_test.go
index 1331f420b..234ff0ecb 100644
--- a/server/events/comment_parser_test.go
+++ b/server/events/comment_parser_test.go
@@ -19,6 +19,7 @@ import (
"testing"
"github.com/runatlantis/atlantis/server/events"
+ "github.com/runatlantis/atlantis/server/events/command"
"github.com/runatlantis/atlantis/server/events/models"
. "github.com/runatlantis/atlantis/testing"
)
@@ -81,57 +82,57 @@ func TestParse_HelpResponseWithApplyDisabled(t *testing.T) {
func TestParse_UnusedArguments(t *testing.T) {
t.Log("if there are unused flags we return an error")
cases := []struct {
- Command models.CommandName
+ Command command.Name
Args string
Unused string
}{
{
- models.PlanCommand,
+ command.Plan,
"-d . arg",
"arg",
},
{
- models.PlanCommand,
+ command.Plan,
"arg -d .",
"arg",
},
{
- models.PlanCommand,
+ command.Plan,
"arg",
"arg",
},
{
- models.PlanCommand,
+ command.Plan,
"arg arg2",
"arg arg2",
},
{
- models.PlanCommand,
+ command.Plan,
"-d . arg -w kjj arg2",
"arg arg2",
},
{
- models.ApplyCommand,
+ command.Apply,
"-d . arg",
"arg",
},
{
- models.ApplyCommand,
+ command.Apply,
"arg arg2",
"arg arg2",
},
{
- models.ApplyCommand,
+ command.Apply,
"arg arg2 -- useful",
"arg arg2",
},
{
- models.ApplyCommand,
+ command.Apply,
"arg arg2 --",
"arg arg2",
},
{
- models.ApprovePoliciesCommand,
+ command.ApprovePolicies,
"arg arg2 --",
"arg arg2",
},
@@ -142,11 +143,11 @@ func TestParse_UnusedArguments(t *testing.T) {
r := commentParser.Parse(comment, models.Github)
var usage string
switch c.Command {
- case models.PlanCommand:
+ case command.Plan:
usage = PlanUsage
- case models.ApplyCommand:
+ case command.Apply:
usage = ApplyUsage
- case models.ApprovePoliciesCommand:
+ case command.ApprovePolicies:
usage = ApprovePolicyUsage
}
Equals(t, fmt.Sprintf("```\nError: unknown argument(s) – %s.\n%s```", c.Unused, usage), r.CommentResponse)
@@ -287,7 +288,7 @@ func TestParse_Multiline(t *testing.T) {
Equals(t, &events.CommentCommand{
RepoRelDir: "",
Flags: nil,
- Name: models.PlanCommand,
+ Name: command.Plan,
Verbose: false,
Workspace: "",
ProjectName: "",
@@ -563,13 +564,13 @@ func TestParse_Parsing(t *testing.T) {
actExtraArgs := strings.Join(r.Command.Flags, " ")
Assert(t, test.expExtraArgs == actExtraArgs, "exp extra args to equal %v but got %v for comment %q", test.expExtraArgs, actExtraArgs, comment)
if cmdName == "plan" {
- Assert(t, r.Command.Name == models.PlanCommand, "did not parse comment %q as plan command", comment)
+ Assert(t, r.Command.Name == command.Plan, "did not parse comment %q as plan command", comment)
}
if cmdName == "apply" {
- Assert(t, r.Command.Name == models.ApplyCommand, "did not parse comment %q as apply command", comment)
+ Assert(t, r.Command.Name == command.Apply, "did not parse comment %q as apply command", comment)
}
if cmdName == "approve_policies" {
- Assert(t, r.Command.Name == models.ApprovePoliciesCommand, "did not parse comment %q as approve_policies command", comment)
+ Assert(t, r.Command.Name == command.ApprovePolicies, "did not parse comment %q as approve_policies command", comment)
}
})
}
@@ -681,15 +682,15 @@ func TestBuildPlanApplyVersionComment(t *testing.T) {
for _, c := range cases {
t.Run(c.expPlanFlags, func(t *testing.T) {
- for _, cmd := range []models.CommandName{models.PlanCommand, models.ApplyCommand, models.VersionCommand} {
+ for _, cmd := range []command.Name{command.Plan, command.Apply, command.Version} {
switch cmd {
- case models.PlanCommand:
+ case command.Plan:
actComment := commentParser.BuildPlanComment(c.repoRelDir, c.workspace, c.project, c.commentArgs)
Equals(t, fmt.Sprintf("atlantis plan %s", c.expPlanFlags), actComment)
- case models.ApplyCommand:
+ case command.Apply:
actComment := commentParser.BuildApplyComment(c.repoRelDir, c.workspace, c.project, c.autoMergeDisabled)
Equals(t, fmt.Sprintf("atlantis apply %s", c.expApplyFlags), actComment)
- case models.VersionCommand:
+ case command.Version:
actComment := commentParser.BuildVersionComment(c.repoRelDir, c.workspace, c.project)
Equals(t, fmt.Sprintf("atlantis version %s", c.expVersionFlags), actComment)
}
diff --git a/server/events/commit_status_updater.go b/server/events/commit_status_updater.go
index 4e197f93c..e193a0c70 100644
--- a/server/events/commit_status_updater.go
+++ b/server/events/commit_status_updater.go
@@ -17,6 +17,7 @@ import (
"fmt"
"strings"
+ "github.com/runatlantis/atlantis/server/events/command"
"github.com/runatlantis/atlantis/server/events/models"
"github.com/runatlantis/atlantis/server/events/vcs"
)
@@ -28,13 +29,13 @@ import (
type CommitStatusUpdater interface {
// UpdateCombined updates the combined status of the head commit of pull.
// A combined status represents all the projects modified in the pull.
- UpdateCombined(repo models.Repo, pull models.PullRequest, status models.CommitStatus, command models.CommandName) error
+ UpdateCombined(repo models.Repo, pull models.PullRequest, status models.CommitStatus, cmdName command.Name) error
// UpdateCombinedCount updates the combined status to reflect the
// numSuccess out of numTotal.
- UpdateCombinedCount(repo models.Repo, pull models.PullRequest, status models.CommitStatus, command models.CommandName, numSuccess int, numTotal int) error
+ UpdateCombinedCount(repo models.Repo, pull models.PullRequest, status models.CommitStatus, cmdName command.Name, numSuccess int, numTotal int) error
// UpdateProject sets the commit status for the project represented by
// ctx.
- UpdateProject(ctx models.ProjectCommandContext, cmdName models.CommandName, status models.CommitStatus, url string) error
+ UpdateProject(ctx command.ProjectContext, cmdName command.Name, status models.CommitStatus, url string) error
}
// DefaultCommitStatusUpdater implements CommitStatusUpdater.
@@ -44,8 +45,8 @@ type DefaultCommitStatusUpdater struct {
StatusName string
}
-func (d *DefaultCommitStatusUpdater) UpdateCombined(repo models.Repo, pull models.PullRequest, status models.CommitStatus, command models.CommandName) error {
- src := fmt.Sprintf("%s/%s", d.StatusName, command.String())
+func (d *DefaultCommitStatusUpdater) UpdateCombined(repo models.Repo, pull models.PullRequest, status models.CommitStatus, cmdName command.Name) error {
+ src := fmt.Sprintf("%s/%s", d.StatusName, cmdName.String())
var descripWords string
switch status {
case models.PendingCommitStatus:
@@ -55,27 +56,27 @@ func (d *DefaultCommitStatusUpdater) UpdateCombined(repo models.Repo, pull model
case models.SuccessCommitStatus:
descripWords = "succeeded."
}
- descrip := fmt.Sprintf("%s %s", strings.Title(command.String()), descripWords)
+ descrip := fmt.Sprintf("%s %s", strings.Title(cmdName.String()), descripWords)
return d.Client.UpdateStatus(repo, pull, status, src, descrip, "")
}
-func (d *DefaultCommitStatusUpdater) UpdateCombinedCount(repo models.Repo, pull models.PullRequest, status models.CommitStatus, command models.CommandName, numSuccess int, numTotal int) error {
- src := fmt.Sprintf("%s/%s", d.StatusName, command.String())
+func (d *DefaultCommitStatusUpdater) UpdateCombinedCount(repo models.Repo, pull models.PullRequest, status models.CommitStatus, cmdName command.Name, numSuccess int, numTotal int) error {
+ src := fmt.Sprintf("%s/%s", d.StatusName, cmdName.String())
cmdVerb := "unknown"
- switch command {
- case models.PlanCommand:
+ switch cmdName {
+ case command.Plan:
cmdVerb = "planned"
- case models.PolicyCheckCommand:
+ case command.PolicyCheck:
cmdVerb = "policies checked"
- case models.ApplyCommand:
+ case command.Apply:
cmdVerb = "applied"
}
return d.Client.UpdateStatus(repo, pull, status, src, fmt.Sprintf("%d/%d projects %s successfully.", numSuccess, numTotal, cmdVerb), "")
}
-func (d *DefaultCommitStatusUpdater) UpdateProject(ctx models.ProjectCommandContext, cmdName models.CommandName, status models.CommitStatus, url string) error {
+func (d *DefaultCommitStatusUpdater) UpdateProject(ctx command.ProjectContext, cmdName command.Name, status models.CommitStatus, url string) error {
projectID := ctx.ProjectName
if projectID == "" {
projectID = fmt.Sprintf("%s/%s", ctx.RepoRelDir, ctx.Workspace)
diff --git a/server/events/commit_status_updater_test.go b/server/events/commit_status_updater_test.go
index 582daf258..3d80d4056 100644
--- a/server/events/commit_status_updater_test.go
+++ b/server/events/commit_status_updater_test.go
@@ -19,6 +19,7 @@ import (
. "github.com/petergtz/pegomock"
"github.com/runatlantis/atlantis/server/events"
+ "github.com/runatlantis/atlantis/server/events/command"
"github.com/runatlantis/atlantis/server/events/models"
"github.com/runatlantis/atlantis/server/events/vcs/mocks"
. "github.com/runatlantis/atlantis/testing"
@@ -27,37 +28,37 @@ import (
func TestUpdateCombined(t *testing.T) {
cases := []struct {
status models.CommitStatus
- command models.CommandName
+ command command.Name
expDescrip string
}{
{
status: models.PendingCommitStatus,
- command: models.PlanCommand,
+ command: command.Plan,
expDescrip: "Plan in progress...",
},
{
status: models.FailedCommitStatus,
- command: models.PlanCommand,
+ command: command.Plan,
expDescrip: "Plan failed.",
},
{
status: models.SuccessCommitStatus,
- command: models.PlanCommand,
+ command: command.Plan,
expDescrip: "Plan succeeded.",
},
{
status: models.PendingCommitStatus,
- command: models.ApplyCommand,
+ command: command.Apply,
expDescrip: "Apply in progress...",
},
{
status: models.FailedCommitStatus,
- command: models.ApplyCommand,
+ command: command.Apply,
expDescrip: "Apply failed.",
},
{
status: models.SuccessCommitStatus,
- command: models.ApplyCommand,
+ command: command.Apply,
expDescrip: "Apply succeeded.",
},
}
@@ -79,49 +80,49 @@ func TestUpdateCombined(t *testing.T) {
func TestUpdateCombinedCount(t *testing.T) {
cases := []struct {
status models.CommitStatus
- command models.CommandName
+ command command.Name
numSuccess int
numTotal int
expDescrip string
}{
{
status: models.PendingCommitStatus,
- command: models.PlanCommand,
+ command: command.Plan,
numSuccess: 0,
numTotal: 2,
expDescrip: "0/2 projects planned successfully.",
},
{
status: models.FailedCommitStatus,
- command: models.PlanCommand,
+ command: command.Plan,
numSuccess: 1,
numTotal: 2,
expDescrip: "1/2 projects planned successfully.",
},
{
status: models.SuccessCommitStatus,
- command: models.PlanCommand,
+ command: command.Plan,
numSuccess: 2,
numTotal: 2,
expDescrip: "2/2 projects planned successfully.",
},
{
status: models.FailedCommitStatus,
- command: models.ApplyCommand,
+ command: command.Apply,
numSuccess: 0,
numTotal: 2,
expDescrip: "0/2 projects applied successfully.",
},
{
status: models.PendingCommitStatus,
- command: models.ApplyCommand,
+ command: command.Apply,
numSuccess: 1,
numTotal: 2,
expDescrip: "1/2 projects applied successfully.",
},
{
status: models.SuccessCommitStatus,
- command: models.ApplyCommand,
+ command: command.Apply,
numSuccess: 2,
numTotal: 2,
expDescrip: "2/2 projects applied successfully.",
@@ -170,12 +171,12 @@ func TestDefaultCommitStatusUpdater_UpdateProjectSrc(t *testing.T) {
t.Run(c.expSrc, func(t *testing.T) {
client := mocks.NewMockClient()
s := events.DefaultCommitStatusUpdater{Client: client, StatusName: "atlantis"}
- err := s.UpdateProject(models.ProjectCommandContext{
+ err := s.UpdateProject(command.ProjectContext{
ProjectName: c.projectName,
RepoRelDir: c.repoRelDir,
Workspace: c.workspace,
},
- models.PlanCommand,
+ command.Plan,
models.PendingCommitStatus,
"url")
Ok(t, err)
@@ -189,37 +190,37 @@ func TestDefaultCommitStatusUpdater_UpdateProject(t *testing.T) {
RegisterMockTestingT(t)
cases := []struct {
status models.CommitStatus
- cmd models.CommandName
+ cmd command.Name
expDescrip string
}{
{
models.PendingCommitStatus,
- models.PlanCommand,
+ command.Plan,
"Plan in progress...",
},
{
models.FailedCommitStatus,
- models.PlanCommand,
+ command.Plan,
"Plan failed.",
},
{
models.SuccessCommitStatus,
- models.PlanCommand,
+ command.Plan,
"Plan succeeded.",
},
{
models.PendingCommitStatus,
- models.ApplyCommand,
+ command.Apply,
"Apply in progress...",
},
{
models.FailedCommitStatus,
- models.ApplyCommand,
+ command.Apply,
"Apply failed.",
},
{
models.SuccessCommitStatus,
- models.ApplyCommand,
+ command.Apply,
"Apply succeeded.",
},
}
@@ -228,7 +229,7 @@ func TestDefaultCommitStatusUpdater_UpdateProject(t *testing.T) {
t.Run(c.expDescrip, func(t *testing.T) {
client := mocks.NewMockClient()
s := events.DefaultCommitStatusUpdater{Client: client, StatusName: "atlantis"}
- err := s.UpdateProject(models.ProjectCommandContext{
+ err := s.UpdateProject(command.ProjectContext{
RepoRelDir: ".",
Workspace: "default",
},
@@ -246,11 +247,11 @@ func TestDefaultCommitStatusUpdater_UpdateProjectCustomStatusName(t *testing.T)
RegisterMockTestingT(t)
client := mocks.NewMockClient()
s := events.DefaultCommitStatusUpdater{Client: client, StatusName: "custom"}
- err := s.UpdateProject(models.ProjectCommandContext{
+ err := s.UpdateProject(command.ProjectContext{
RepoRelDir: ".",
Workspace: "default",
},
- models.ApplyCommand,
+ command.Apply,
models.SuccessCommitStatus,
"url")
Ok(t, err)
diff --git a/server/events/db_updater.go b/server/events/db_updater.go
index 230b646b3..eaa0712dc 100644
--- a/server/events/db_updater.go
+++ b/server/events/db_updater.go
@@ -2,6 +2,7 @@ package events
import (
"github.com/runatlantis/atlantis/server/core/db"
+ "github.com/runatlantis/atlantis/server/events/command"
"github.com/runatlantis/atlantis/server/events/models"
)
@@ -9,11 +10,11 @@ type DBUpdater struct {
DB *db.BoltDB
}
-func (c *DBUpdater) updateDB(ctx *CommandContext, pull models.PullRequest, results []models.ProjectResult) (models.PullStatus, error) {
+func (c *DBUpdater) updateDB(ctx *command.Context, pull models.PullRequest, results []command.ProjectResult) (models.PullStatus, error) {
// Filter out results that errored due to the directory not existing. We
// don't store these in the database because they would never be "apply-able"
// and so the pull request would always have errors.
- var filtered []models.ProjectResult
+ var filtered []command.ProjectResult
for _, r := range results {
if _, ok := r.Error.(DirNotExistErr); ok {
ctx.Log.Debug("ignoring error result from project at dir %q workspace %q because it is dir not exist error", r.RepoRelDir, r.Workspace)
diff --git a/server/events/event_parser.go b/server/events/event_parser.go
index ac1d4360f..d3130ceda 100644
--- a/server/events/event_parser.go
+++ b/server/events/event_parser.go
@@ -23,6 +23,7 @@ import (
"github.com/google/go-github/v31/github"
"github.com/mcdafydd/go-azuredevops/azuredevops"
"github.com/pkg/errors"
+ "github.com/runatlantis/atlantis/server/events/command"
"github.com/runatlantis/atlantis/server/events/models"
"github.com/runatlantis/atlantis/server/events/vcs/bitbucketcloud"
"github.com/runatlantis/atlantis/server/events/vcs/bitbucketserver"
@@ -36,7 +37,7 @@ const usagesCols = 90
// PullCommand is a command to run on a pull request.
type PullCommand interface {
// CommandName is the name of the command we're running.
- CommandName() models.CommandName
+ CommandName() command.Name
// IsVerbose is true if the output of this command should be verbose.
IsVerbose() bool
// IsAutoplan is true if this is an autoplan command vs. a comment command.
@@ -48,8 +49,8 @@ type PullCommand interface {
type PolicyCheckCommand struct{}
// CommandName is policy_check.
-func (c PolicyCheckCommand) CommandName() models.CommandName {
- return models.PolicyCheckCommand
+func (c PolicyCheckCommand) CommandName() command.Name {
+ return command.PolicyCheck
}
// IsVerbose is false for policy_check commands.
@@ -67,8 +68,8 @@ func (c PolicyCheckCommand) IsAutoplan() bool {
type AutoplanCommand struct{}
// CommandName is plan.
-func (c AutoplanCommand) CommandName() models.CommandName {
- return models.PlanCommand
+func (c AutoplanCommand) CommandName() command.Name {
+ return command.Plan
}
// IsVerbose is false for autoplan commands.
@@ -90,7 +91,7 @@ type CommentCommand struct {
// ex. atlantis plan -- -target=resource
Flags []string
// Name is the name of the command the comment specified.
- Name models.CommandName
+ Name command.Name
// AutoMergeDisabled is true if the command should not automerge after apply.
AutoMergeDisabled bool
// Verbose is true if the command should output verbosely.
@@ -112,7 +113,7 @@ func (c CommentCommand) IsForSpecificProject() bool {
}
// CommandName returns the name of this command.
-func (c CommentCommand) CommandName() models.CommandName {
+func (c CommentCommand) CommandName() command.Name {
return c.Name
}
@@ -132,7 +133,7 @@ func (c CommentCommand) String() string {
}
// NewCommentCommand constructs a CommentCommand, setting all missing fields to defaults.
-func NewCommentCommand(repoRelDir string, flags []string, name models.CommandName, verbose, autoMergeDisabled bool, workspace string, project string) *CommentCommand {
+func NewCommentCommand(repoRelDir string, flags []string, name command.Name, verbose, autoMergeDisabled bool, workspace string, project string) *CommentCommand {
// If repoRelDir was empty we want to keep it that way to indicate that it
// wasn't specified in the comment.
if repoRelDir != "" {
diff --git a/server/events/event_parser_test.go b/server/events/event_parser_test.go
index 653be3700..3c5d6412c 100644
--- a/server/events/event_parser_test.go
+++ b/server/events/event_parser_test.go
@@ -25,6 +25,7 @@ import (
"github.com/mcdafydd/go-azuredevops/azuredevops"
"github.com/mohae/deepcopy"
"github.com/runatlantis/atlantis/server/events"
+ "github.com/runatlantis/atlantis/server/events/command"
"github.com/runatlantis/atlantis/server/events/models"
. "github.com/runatlantis/atlantis/server/events/vcs/fixtures"
. "github.com/runatlantis/atlantis/testing"
@@ -650,18 +651,18 @@ func TestNewCommand_CleansDir(t *testing.T) {
for _, c := range cases {
t.Run(c.RepoRelDir, func(t *testing.T) {
- cmd := events.NewCommentCommand(c.RepoRelDir, nil, models.PlanCommand, false, false, "workspace", "")
+ cmd := events.NewCommentCommand(c.RepoRelDir, nil, command.Plan, false, false, "workspace", "")
Equals(t, c.ExpDir, cmd.RepoRelDir)
})
}
}
func TestNewCommand_EmptyDirWorkspaceProject(t *testing.T) {
- cmd := events.NewCommentCommand("", nil, models.PlanCommand, false, false, "", "")
+ cmd := events.NewCommentCommand("", nil, command.Plan, false, false, "", "")
Equals(t, events.CommentCommand{
RepoRelDir: "",
Flags: nil,
- Name: models.PlanCommand,
+ Name: command.Plan,
Verbose: false,
Workspace: "",
ProjectName: "",
@@ -669,19 +670,19 @@ func TestNewCommand_EmptyDirWorkspaceProject(t *testing.T) {
}
func TestNewCommand_AllFieldsSet(t *testing.T) {
- cmd := events.NewCommentCommand("dir", []string{"a", "b"}, models.PlanCommand, true, false, "workspace", "project")
+ cmd := events.NewCommentCommand("dir", []string{"a", "b"}, command.Plan, true, false, "workspace", "project")
Equals(t, events.CommentCommand{
Workspace: "workspace",
RepoRelDir: "dir",
Verbose: true,
Flags: []string{"a", "b"},
- Name: models.PlanCommand,
+ Name: command.Plan,
ProjectName: "project",
}, *cmd)
}
func TestAutoplanCommand_CommandName(t *testing.T) {
- Equals(t, models.PlanCommand, (events.AutoplanCommand{}).CommandName())
+ Equals(t, command.Plan, (events.AutoplanCommand{}).CommandName())
}
func TestAutoplanCommand_IsVerbose(t *testing.T) {
@@ -693,11 +694,11 @@ func TestAutoplanCommand_IsAutoplan(t *testing.T) {
}
func TestCommentCommand_CommandName(t *testing.T) {
- Equals(t, models.PlanCommand, (events.CommentCommand{
- Name: models.PlanCommand,
+ Equals(t, command.Plan, (events.CommentCommand{
+ Name: command.Plan,
}).CommandName())
- Equals(t, models.ApplyCommand, (events.CommentCommand{
- Name: models.ApplyCommand,
+ Equals(t, command.Apply, (events.CommentCommand{
+ Name: command.Apply,
}).CommandName())
}
@@ -719,7 +720,7 @@ func TestCommentCommand_String(t *testing.T) {
Equals(t, exp, (events.CommentCommand{
RepoRelDir: "mydir",
Flags: []string{"flag1", "flag2"},
- Name: models.PlanCommand,
+ Name: command.Plan,
Verbose: true,
Workspace: "myworkspace",
ProjectName: "myproject",
diff --git a/server/events/instrumented_project_command_builder.go b/server/events/instrumented_project_command_builder.go
index e51cbe5c9..b1bfbc9b4 100644
--- a/server/events/instrumented_project_command_builder.go
+++ b/server/events/instrumented_project_command_builder.go
@@ -1,7 +1,7 @@
package events
import (
- "github.com/runatlantis/atlantis/server/events/models"
+ "github.com/runatlantis/atlantis/server/events/command"
"github.com/runatlantis/atlantis/server/logging"
"github.com/runatlantis/atlantis/server/metrics"
)
@@ -11,7 +11,7 @@ type InstrumentedProjectCommandBuilder struct {
Logger logging.SimpleLogging
}
-func (b *InstrumentedProjectCommandBuilder) BuildApplyCommands(ctx *CommandContext, comment *CommentCommand) ([]models.ProjectCommandContext, error) {
+func (b *InstrumentedProjectCommandBuilder) BuildApplyCommands(ctx *command.Context, comment *CommentCommand) ([]command.ProjectContext, error) {
scope := ctx.Scope.SubScope("builder")
timer := scope.Timer(metrics.ExecutionTimeMetric).Start()
@@ -32,7 +32,7 @@ func (b *InstrumentedProjectCommandBuilder) BuildApplyCommands(ctx *CommandConte
return projectCmds, err
}
-func (b *InstrumentedProjectCommandBuilder) BuildAutoplanCommands(ctx *CommandContext) ([]models.ProjectCommandContext, error) {
+func (b *InstrumentedProjectCommandBuilder) BuildAutoplanCommands(ctx *command.Context) ([]command.ProjectContext, error) {
scope := ctx.Scope.SubScope("builder")
timer := scope.Timer(metrics.ExecutionTimeMetric).Start()
@@ -53,7 +53,7 @@ func (b *InstrumentedProjectCommandBuilder) BuildAutoplanCommands(ctx *CommandCo
return projectCmds, err
}
-func (b *InstrumentedProjectCommandBuilder) BuildPlanCommands(ctx *CommandContext, comment *CommentCommand) ([]models.ProjectCommandContext, error) {
+func (b *InstrumentedProjectCommandBuilder) BuildPlanCommands(ctx *command.Context, comment *CommentCommand) ([]command.ProjectContext, error) {
scope := ctx.Scope.SubScope("builder")
timer := scope.Timer(metrics.ExecutionTimeMetric).Start()
diff --git a/server/events/instrumented_project_command_runner.go b/server/events/instrumented_project_command_runner.go
index 98df05d2b..a3cedbf6f 100644
--- a/server/events/instrumented_project_command_runner.go
+++ b/server/events/instrumented_project_command_runner.go
@@ -1,7 +1,7 @@
package events
import (
- "github.com/runatlantis/atlantis/server/events/models"
+ "github.com/runatlantis/atlantis/server/events/command"
"github.com/runatlantis/atlantis/server/metrics"
)
@@ -9,19 +9,19 @@ type InstrumentedProjectCommandRunner struct {
ProjectCommandRunner
}
-func (p *InstrumentedProjectCommandRunner) Plan(ctx models.ProjectCommandContext) models.ProjectResult {
+func (p *InstrumentedProjectCommandRunner) Plan(ctx command.ProjectContext) command.ProjectResult {
return RunAndEmitStats("plan", ctx, p.ProjectCommandRunner.Plan)
}
-func (p *InstrumentedProjectCommandRunner) PolicyCheck(ctx models.ProjectCommandContext) models.ProjectResult {
+func (p *InstrumentedProjectCommandRunner) PolicyCheck(ctx command.ProjectContext) command.ProjectResult {
return RunAndEmitStats("policy check", ctx, p.ProjectCommandRunner.PolicyCheck)
}
-func (p *InstrumentedProjectCommandRunner) Apply(ctx models.ProjectCommandContext) models.ProjectResult {
+func (p *InstrumentedProjectCommandRunner) Apply(ctx command.ProjectContext) command.ProjectResult {
return RunAndEmitStats("apply", ctx, p.ProjectCommandRunner.Apply)
}
-func RunAndEmitStats(commandName string, ctx models.ProjectCommandContext, execute func(ctx models.ProjectCommandContext) models.ProjectResult) models.ProjectResult {
+func RunAndEmitStats(commandName string, ctx command.ProjectContext, execute func(ctx command.ProjectContext) command.ProjectResult) command.ProjectResult {
// ensures we are differentiating between project level command and overall command
ctx.SetScope("project")
diff --git a/server/events/markdown_renderer.go b/server/events/markdown_renderer.go
index 9dfe07e3d..c9605004c 100644
--- a/server/events/markdown_renderer.go
+++ b/server/events/markdown_renderer.go
@@ -20,15 +20,16 @@ import (
"text/template"
"github.com/Masterminds/sprig/v3"
+ "github.com/runatlantis/atlantis/server/events/command"
"github.com/runatlantis/atlantis/server/events/models"
)
var (
- planCommandTitle = models.PlanCommand.TitleString()
- applyCommandTitle = models.ApplyCommand.TitleString()
- policyCheckCommandTitle = models.PolicyCheckCommand.TitleString()
- approvePoliciesCommandTitle = models.ApprovePoliciesCommand.TitleString()
- versionCommandTitle = models.VersionCommand.TitleString()
+ planCommandTitle = command.Plan.TitleString()
+ applyCommandTitle = command.Apply.TitleString()
+ policyCheckCommandTitle = command.PolicyCheck.TitleString()
+ approvePoliciesCommandTitle = command.ApprovePolicies.TitleString()
+ versionCommandTitle = command.Version.TitleString()
// maxUnwrappedLines is the maximum number of lines the Terraform output
// can be before we wrap it in an expandable template.
maxUnwrappedLines = 12
@@ -99,7 +100,7 @@ type projectResultTmplData struct {
// Render formats the data into a markdown string.
// nolint: interfacer
-func (m *MarkdownRenderer) Render(res CommandResult, cmdName models.CommandName, log string, verbose bool, vcsHost models.VCSHostType) string {
+func (m *MarkdownRenderer) Render(res command.Result, cmdName command.Name, log string, verbose bool, vcsHost models.VCSHostType) string {
commandStr := strings.Title(strings.Replace(cmdName.String(), "_", " ", -1))
common := commonData{
Command: commandStr,
@@ -120,7 +121,7 @@ func (m *MarkdownRenderer) Render(res CommandResult, cmdName models.CommandName,
return m.renderProjectResults(res.ProjectResults, common, vcsHost)
}
-func (m *MarkdownRenderer) renderProjectResults(results []models.ProjectResult, common commonData, vcsHost models.VCSHostType) string {
+func (m *MarkdownRenderer) renderProjectResults(results []command.ProjectResult, common commonData, vcsHost models.VCSHostType) string {
var resultsTmplData []projectResultTmplData
numPlanSuccesses := 0
numPolicyCheckSuccesses := 0
diff --git a/server/events/markdown_renderer_test.go b/server/events/markdown_renderer_test.go
index 65a61d281..9a5caf839 100644
--- a/server/events/markdown_renderer_test.go
+++ b/server/events/markdown_renderer_test.go
@@ -20,6 +20,7 @@ import (
"testing"
"github.com/runatlantis/atlantis/server/events"
+ "github.com/runatlantis/atlantis/server/events/command"
"github.com/runatlantis/atlantis/server/events/models"
. "github.com/runatlantis/atlantis/testing"
)
@@ -28,25 +29,25 @@ func TestRenderErr(t *testing.T) {
err := errors.New("err")
cases := []struct {
Description string
- Command models.CommandName
+ Command command.Name
Error error
Expected string
}{
{
"apply error",
- models.ApplyCommand,
+ command.Apply,
err,
"**Apply Error**\n```\nerr\n```\n",
},
{
"plan error",
- models.PlanCommand,
+ command.Plan,
err,
"**Plan Error**\n```\nerr\n```\n",
},
{
"policy check error",
- models.PolicyCheckCommand,
+ command.PolicyCheck,
err,
"**Policy Check Error**\n```\nerr\n```" +
"\n* :heavy_check_mark: To **approve** failing policies an authorized approver can comment:\n" +
@@ -57,7 +58,7 @@ func TestRenderErr(t *testing.T) {
r := events.MarkdownRenderer{}
for _, c := range cases {
- res := events.CommandResult{
+ res := command.Result{
Error: c.Error,
}
for _, verbose := range []bool{true, false} {
@@ -76,25 +77,25 @@ func TestRenderErr(t *testing.T) {
func TestRenderFailure(t *testing.T) {
cases := []struct {
Description string
- Command models.CommandName
+ Command command.Name
Failure string
Expected string
}{
{
"apply failure",
- models.ApplyCommand,
+ command.Apply,
"failure",
"**Apply Failed**: failure\n",
},
{
"plan failure",
- models.PlanCommand,
+ command.Plan,
"failure",
"**Plan Failed**: failure\n",
},
{
"policy check failure",
- models.PolicyCheckCommand,
+ command.PolicyCheck,
"failure",
"**Policy Check Failed**: failure\n",
},
@@ -102,7 +103,7 @@ func TestRenderFailure(t *testing.T) {
r := events.MarkdownRenderer{}
for _, c := range cases {
- res := events.CommandResult{
+ res := command.Result{
Failure: c.Failure,
}
for _, verbose := range []bool{true, false} {
@@ -120,33 +121,33 @@ func TestRenderFailure(t *testing.T) {
func TestRenderErrAndFailure(t *testing.T) {
r := events.MarkdownRenderer{}
- res := events.CommandResult{
+ res := command.Result{
Error: errors.New("error"),
Failure: "failure",
}
- s := r.Render(res, models.PlanCommand, "", false, models.Github)
+ s := r.Render(res, command.Plan, "", false, models.Github)
Equals(t, "**Plan Error**\n```\nerror\n```\n", s)
}
func TestRenderProjectResults(t *testing.T) {
cases := []struct {
Description string
- Command models.CommandName
- ProjectResults []models.ProjectResult
+ Command command.Name
+ ProjectResults []command.ProjectResult
VCSHost models.VCSHostType
Expected string
}{
{
"no projects",
- models.PlanCommand,
- []models.ProjectResult{},
+ command.Plan,
+ []command.ProjectResult{},
models.Github,
"Ran Plan for 0 projects:\n\n\n\n",
},
{
"single successful plan",
- models.PlanCommand,
- []models.ProjectResult{
+ command.Plan,
+ []command.ProjectResult{
{
PlanSuccess: &models.PlanSuccess{
TerraformOutput: "terraform-output",
@@ -180,8 +181,8 @@ $$$
},
{
"single successful plan with master ahead",
- models.PlanCommand,
- []models.ProjectResult{
+ command.Plan,
+ []command.ProjectResult{
{
PlanSuccess: &models.PlanSuccess{
TerraformOutput: "terraform-output",
@@ -218,8 +219,8 @@ $$$
},
{
"single successful plan with project name",
- models.PlanCommand,
- []models.ProjectResult{
+ command.Plan,
+ []command.ProjectResult{
{
PlanSuccess: &models.PlanSuccess{
TerraformOutput: "terraform-output",
@@ -254,8 +255,8 @@ $$$
},
{
"single successful policy check with project name",
- models.PolicyCheckCommand,
- []models.ProjectResult{
+ command.PolicyCheck,
+ []command.ProjectResult{
{
PolicyCheckSuccess: &models.PolicyCheckSuccess{
PolicyCheckOutput: "2 tests, 1 passed, 0 warnings, 0 failure, 0 exceptions",
@@ -290,8 +291,8 @@ $$$
},
{
"single successful apply",
- models.ApplyCommand,
- []models.ProjectResult{
+ command.Apply,
+ []command.ProjectResult{
{
ApplySuccess: "success",
Workspace: "workspace",
@@ -309,8 +310,8 @@ $$$
},
{
"single successful apply with project name",
- models.ApplyCommand,
- []models.ProjectResult{
+ command.Apply,
+ []command.ProjectResult{
{
ApplySuccess: "success",
Workspace: "workspace",
@@ -329,8 +330,8 @@ $$$
},
{
"multiple successful plans",
- models.PlanCommand,
- []models.ProjectResult{
+ command.Plan,
+ []command.ProjectResult{
{
Workspace: "workspace",
RepoRelDir: "path",
@@ -391,8 +392,8 @@ $$$
},
{
"multiple successful policy checks",
- models.PolicyCheckCommand,
- []models.ProjectResult{
+ command.PolicyCheck,
+ []command.ProjectResult{
{
Workspace: "workspace",
RepoRelDir: "path",
@@ -453,8 +454,8 @@ $$$
},
{
"multiple successful applies",
- models.ApplyCommand,
- []models.ProjectResult{
+ command.Apply,
+ []command.ProjectResult{
{
RepoRelDir: "path",
Workspace: "workspace",
@@ -490,8 +491,8 @@ $$$
},
{
"single errored plan",
- models.PlanCommand,
- []models.ProjectResult{
+ command.Plan,
+ []command.ProjectResult{
{
Error: errors.New("error"),
RepoRelDir: "path",
@@ -510,8 +511,8 @@ $$$
},
{
"single failed plan",
- models.PlanCommand,
- []models.ProjectResult{
+ command.Plan,
+ []command.ProjectResult{
{
RepoRelDir: "path",
Workspace: "workspace",
@@ -527,8 +528,8 @@ $$$
},
{
"successful, failed, and errored plan",
- models.PlanCommand,
- []models.ProjectResult{
+ command.Plan,
+ []command.ProjectResult{
{
Workspace: "workspace",
RepoRelDir: "path",
@@ -589,8 +590,8 @@ $$$
},
{
"successful, failed, and errored policy check",
- models.PolicyCheckCommand,
- []models.ProjectResult{
+ command.PolicyCheck,
+ []command.ProjectResult{
{
Workspace: "workspace",
RepoRelDir: "path",
@@ -655,8 +656,8 @@ $$$
},
{
"successful, failed, and errored apply",
- models.ApplyCommand,
- []models.ProjectResult{
+ command.Apply,
+ []command.ProjectResult{
{
Workspace: "workspace",
RepoRelDir: "path",
@@ -702,8 +703,8 @@ $$$
},
{
"successful, failed, and errored apply",
- models.ApplyCommand,
- []models.ProjectResult{
+ command.Apply,
+ []command.ProjectResult{
{
Workspace: "workspace",
RepoRelDir: "path",
@@ -752,7 +753,7 @@ $$$
r := events.MarkdownRenderer{}
for _, c := range cases {
t.Run(c.Description, func(t *testing.T) {
- res := events.CommandResult{
+ res := command.Result{
ProjectResults: c.ProjectResults,
}
for _, verbose := range []bool{true, false} {
@@ -774,15 +775,15 @@ $$$
func TestRenderProjectResultsDisableApplyAll(t *testing.T) {
cases := []struct {
Description string
- Command models.CommandName
- ProjectResults []models.ProjectResult
+ Command command.Name
+ ProjectResults []command.ProjectResult
VCSHost models.VCSHostType
Expected string
}{
{
"single successful plan with disable apply all set",
- models.PlanCommand,
- []models.ProjectResult{
+ command.Plan,
+ []command.ProjectResult{
{
PlanSuccess: &models.PlanSuccess{
TerraformOutput: "terraform-output",
@@ -812,8 +813,8 @@ $$$
},
{
"single successful plan with project name with disable apply all set",
- models.PlanCommand,
- []models.ProjectResult{
+ command.Plan,
+ []command.ProjectResult{
{
PlanSuccess: &models.PlanSuccess{
TerraformOutput: "terraform-output",
@@ -844,8 +845,8 @@ $$$
},
{
"multiple successful plans, disable apply all set",
- models.PlanCommand,
- []models.ProjectResult{
+ command.Plan,
+ []command.ProjectResult{
{
Workspace: "workspace",
RepoRelDir: "path",
@@ -905,7 +906,7 @@ $$$
}
for _, c := range cases {
t.Run(c.Description, func(t *testing.T) {
- res := events.CommandResult{
+ res := command.Result{
ProjectResults: c.ProjectResults,
}
for _, verbose := range []bool{true, false} {
@@ -927,15 +928,15 @@ $$$
func TestRenderProjectResultsDisableApply(t *testing.T) {
cases := []struct {
Description string
- Command models.CommandName
- ProjectResults []models.ProjectResult
+ Command command.Name
+ ProjectResults []command.ProjectResult
VCSHost models.VCSHostType
Expected string
}{
{
"single successful plan with disable apply set",
- models.PlanCommand,
- []models.ProjectResult{
+ command.Plan,
+ []command.ProjectResult{
{
PlanSuccess: &models.PlanSuccess{
TerraformOutput: "terraform-output",
@@ -963,8 +964,8 @@ $$$
},
{
"single successful plan with project name with disable apply set",
- models.PlanCommand,
- []models.ProjectResult{
+ command.Plan,
+ []command.ProjectResult{
{
PlanSuccess: &models.PlanSuccess{
TerraformOutput: "terraform-output",
@@ -993,8 +994,8 @@ $$$
},
{
"multiple successful plans, disable apply set",
- models.PlanCommand,
- []models.ProjectResult{
+ command.Plan,
+ []command.ProjectResult{
{
Workspace: "workspace",
RepoRelDir: "path",
@@ -1051,7 +1052,7 @@ $$$
}
for _, c := range cases {
t.Run(c.Description, func(t *testing.T) {
- res := events.CommandResult{
+ res := command.Result{
ProjectResults: c.ProjectResults,
}
for _, verbose := range []bool{true, false} {
@@ -1075,15 +1076,15 @@ func TestRenderProjectResults_DisableFolding(t *testing.T) {
DisableMarkdownFolding: true,
}
- rendered := mr.Render(events.CommandResult{
- ProjectResults: []models.ProjectResult{
+ rendered := mr.Render(command.Result{
+ ProjectResults: []command.ProjectResult{
{
RepoRelDir: ".",
Workspace: "default",
Error: errors.New(strings.Repeat("line\n", 13)),
},
},
- }, models.PlanCommand, "log", false, models.Github)
+ }, command.Plan, "log", false, models.Github)
Equals(t, false, strings.Contains(rendered, ""))
}
@@ -1159,15 +1160,15 @@ func TestRenderProjectResults_WrappedErr(t *testing.T) {
GitlabSupportsCommonMark: c.GitlabCommonMarkSupport,
}
- rendered := mr.Render(events.CommandResult{
- ProjectResults: []models.ProjectResult{
+ rendered := mr.Render(command.Result{
+ ProjectResults: []command.ProjectResult{
{
RepoRelDir: ".",
Workspace: "default",
Error: errors.New(c.Output),
},
},
- }, models.PlanCommand, "log", false, c.VCSHost)
+ }, command.Plan, "log", false, c.VCSHost)
var exp string
if c.ShouldWrap {
exp = `Ran Plan for dir: $.$ workspace: $default$
@@ -1264,16 +1265,16 @@ func TestRenderProjectResults_WrapSingleProject(t *testing.T) {
}
for _, c := range cases {
- for _, cmd := range []models.CommandName{models.PlanCommand, models.ApplyCommand} {
+ for _, cmd := range []command.Name{command.Plan, command.Apply} {
t.Run(fmt.Sprintf("%s_%s_%v", c.VCSHost.String(), cmd.String(), c.ShouldWrap),
func(t *testing.T) {
mr := events.MarkdownRenderer{
GitlabSupportsCommonMark: c.GitlabCommonMarkSupport,
}
- var pr models.ProjectResult
+ var pr command.ProjectResult
switch cmd {
- case models.PlanCommand:
- pr = models.ProjectResult{
+ case command.Plan:
+ pr = command.ProjectResult{
RepoRelDir: ".",
Workspace: "default",
PlanSuccess: &models.PlanSuccess{
@@ -1283,21 +1284,21 @@ func TestRenderProjectResults_WrapSingleProject(t *testing.T) {
ApplyCmd: "applycmd",
},
}
- case models.ApplyCommand:
- pr = models.ProjectResult{
+ case command.Apply:
+ pr = command.ProjectResult{
RepoRelDir: ".",
Workspace: "default",
ApplySuccess: c.Output,
}
}
- rendered := mr.Render(events.CommandResult{
- ProjectResults: []models.ProjectResult{pr},
+ rendered := mr.Render(command.Result{
+ ProjectResults: []command.ProjectResult{pr},
}, cmd, "log", false, c.VCSHost)
// Check result.
var exp string
switch cmd {
- case models.PlanCommand:
+ case command.Plan:
if c.ShouldWrap {
exp = `Ran Plan for dir: $.$ workspace: $default$
@@ -1341,7 +1342,7 @@ $$$
* $atlantis unlock$
`
}
- case models.ApplyCommand:
+ case command.Apply:
if c.ShouldWrap {
exp = `Ran Apply for dir: $.$ workspace: $default$
@@ -1374,8 +1375,8 @@ $$$
func TestRenderProjectResults_MultiProjectApplyWrapped(t *testing.T) {
mr := events.MarkdownRenderer{}
tfOut := strings.Repeat("line\n", 13)
- rendered := mr.Render(events.CommandResult{
- ProjectResults: []models.ProjectResult{
+ rendered := mr.Render(command.Result{
+ ProjectResults: []command.ProjectResult{
{
RepoRelDir: ".",
Workspace: "staging",
@@ -1387,7 +1388,7 @@ func TestRenderProjectResults_MultiProjectApplyWrapped(t *testing.T) {
ApplySuccess: tfOut,
},
},
- }, models.ApplyCommand, "log", false, models.Github)
+ }, command.Apply, "log", false, models.Github)
exp := `Ran Apply for 2 projects:
1. dir: $.$ workspace: $staging$
@@ -1420,8 +1421,8 @@ $$$
func TestRenderProjectResults_MultiProjectPlanWrapped(t *testing.T) {
mr := events.MarkdownRenderer{}
tfOut := strings.Repeat("line\n", 13) + "Plan: 1 to add, 0 to change, 0 to destroy."
- rendered := mr.Render(events.CommandResult{
- ProjectResults: []models.ProjectResult{
+ rendered := mr.Render(command.Result{
+ ProjectResults: []command.ProjectResult{
{
RepoRelDir: ".",
Workspace: "staging",
@@ -1443,7 +1444,7 @@ func TestRenderProjectResults_MultiProjectPlanWrapped(t *testing.T) {
},
},
},
- }, models.PlanCommand, "log", false, models.Github)
+ }, command.Plan, "log", false, models.Github)
exp := `Ran Plan for 2 projects:
1. dir: $.$ workspace: $staging$
@@ -1494,12 +1495,12 @@ Plan: 1 to add, 0 to change, 0 to destroy.
// all the plans as a result.
func TestRenderProjectResults_PlansDeleted(t *testing.T) {
cases := map[string]struct {
- cr events.CommandResult
+ cr command.Result
exp string
}{
"one failure": {
- cr: events.CommandResult{
- ProjectResults: []models.ProjectResult{
+ cr: command.Result{
+ ProjectResults: []command.ProjectResult{
{
RepoRelDir: ".",
Workspace: "staging",
@@ -1515,8 +1516,8 @@ func TestRenderProjectResults_PlansDeleted(t *testing.T) {
`,
},
"two failures": {
- cr: events.CommandResult{
- ProjectResults: []models.ProjectResult{
+ cr: command.Result{
+ ProjectResults: []command.ProjectResult{
{
RepoRelDir: ".",
Workspace: "staging",
@@ -1547,8 +1548,8 @@ func TestRenderProjectResults_PlansDeleted(t *testing.T) {
`,
},
"one failure, one success": {
- cr: events.CommandResult{
- ProjectResults: []models.ProjectResult{
+ cr: command.Result{
+ ProjectResults: []command.ProjectResult{
{
RepoRelDir: ".",
Workspace: "staging",
@@ -1592,7 +1593,7 @@ This plan was not saved because one or more projects failed and automerge requir
for name, c := range cases {
t.Run(name, func(t *testing.T) {
mr := events.MarkdownRenderer{}
- rendered := mr.Render(c.cr, models.PlanCommand, "log", false, models.Github)
+ rendered := mr.Render(c.cr, command.Plan, "log", false, models.Github)
expWithBackticks := strings.Replace(c.exp, "$", "`", -1)
Equals(t, expWithBackticks, rendered)
})
@@ -1603,22 +1604,22 @@ This plan was not saved because one or more projects failed and automerge requir
func TestRenderProjectResultsWithRepoLockingDisabled(t *testing.T) {
cases := []struct {
Description string
- Command models.CommandName
- ProjectResults []models.ProjectResult
+ Command command.Name
+ ProjectResults []command.ProjectResult
VCSHost models.VCSHostType
Expected string
}{
{
"no projects",
- models.PlanCommand,
- []models.ProjectResult{},
+ command.Plan,
+ []command.ProjectResult{},
models.Github,
"Ran Plan for 0 projects:\n\n\n\n",
},
{
"single successful plan",
- models.PlanCommand,
- []models.ProjectResult{
+ command.Plan,
+ []command.ProjectResult{
{
PlanSuccess: &models.PlanSuccess{
TerraformOutput: "terraform-output",
@@ -1651,8 +1652,8 @@ $$$
},
{
"single successful plan with master ahead",
- models.PlanCommand,
- []models.ProjectResult{
+ command.Plan,
+ []command.ProjectResult{
{
PlanSuccess: &models.PlanSuccess{
TerraformOutput: "terraform-output",
@@ -1688,8 +1689,8 @@ $$$
},
{
"single successful plan with project name",
- models.PlanCommand,
- []models.ProjectResult{
+ command.Plan,
+ []command.ProjectResult{
{
PlanSuccess: &models.PlanSuccess{
TerraformOutput: "terraform-output",
@@ -1723,8 +1724,8 @@ $$$
},
{
"single successful apply",
- models.ApplyCommand,
- []models.ProjectResult{
+ command.Apply,
+ []command.ProjectResult{
{
ApplySuccess: "success",
Workspace: "workspace",
@@ -1742,8 +1743,8 @@ $$$
},
{
"single successful apply with project name",
- models.ApplyCommand,
- []models.ProjectResult{
+ command.Apply,
+ []command.ProjectResult{
{
ApplySuccess: "success",
Workspace: "workspace",
@@ -1762,8 +1763,8 @@ $$$
},
{
"multiple successful plans",
- models.PlanCommand,
- []models.ProjectResult{
+ command.Plan,
+ []command.ProjectResult{
{
Workspace: "workspace",
RepoRelDir: "path",
@@ -1822,8 +1823,8 @@ $$$
},
{
"multiple successful applies",
- models.ApplyCommand,
- []models.ProjectResult{
+ command.Apply,
+ []command.ProjectResult{
{
RepoRelDir: "path",
Workspace: "workspace",
@@ -1859,8 +1860,8 @@ $$$
},
{
"single errored plan",
- models.PlanCommand,
- []models.ProjectResult{
+ command.Plan,
+ []command.ProjectResult{
{
Error: errors.New("error"),
RepoRelDir: "path",
@@ -1879,8 +1880,8 @@ $$$
},
{
"single failed plan",
- models.PlanCommand,
- []models.ProjectResult{
+ command.Plan,
+ []command.ProjectResult{
{
RepoRelDir: "path",
Workspace: "workspace",
@@ -1896,8 +1897,8 @@ $$$
},
{
"successful, failed, and errored plan",
- models.PlanCommand,
- []models.ProjectResult{
+ command.Plan,
+ []command.ProjectResult{
{
Workspace: "workspace",
RepoRelDir: "path",
@@ -1957,8 +1958,8 @@ $$$
},
{
"successful, failed, and errored apply",
- models.ApplyCommand,
- []models.ProjectResult{
+ command.Apply,
+ []command.ProjectResult{
{
Workspace: "workspace",
RepoRelDir: "path",
@@ -2004,8 +2005,8 @@ $$$
},
{
"successful, failed, and errored apply",
- models.ApplyCommand,
- []models.ProjectResult{
+ command.Apply,
+ []command.ProjectResult{
{
Workspace: "workspace",
RepoRelDir: "path",
@@ -2055,7 +2056,7 @@ $$$
r.DisableRepoLocking = true
for _, c := range cases {
t.Run(c.Description, func(t *testing.T) {
- res := events.CommandResult{
+ res := command.Result{
ProjectResults: c.ProjectResults,
}
for _, verbose := range []bool{true, false} {
@@ -2183,15 +2184,15 @@ Plan: 1 to add, 1 to change, 1 to destroy.
`
cases := []struct {
Description string
- Command models.CommandName
- ProjectResults []models.ProjectResult
+ Command command.Name
+ ProjectResults []command.ProjectResult
VCSHost models.VCSHostType
Expected string
}{
{
"single successful plan with diff markdown formatted",
- models.PlanCommand,
- []models.ProjectResult{
+ command.Plan,
+ []command.ProjectResult{
{
PlanSuccess: &models.PlanSuccess{
TerraformOutput: tfOutput,
@@ -2335,7 +2336,7 @@ Plan: 1 to add, 1 to change, 1 to destroy.
}
for _, c := range cases {
t.Run(c.Description, func(t *testing.T) {
- res := events.CommandResult{
+ res := command.Result{
ProjectResults: c.ProjectResults,
}
for _, verbose := range []bool{true, false} {
diff --git a/server/events/mocks/matchers/azuredevops_event.go b/server/events/mocks/matchers/azuredevops_event.go
index c6b599082..64df2a4ff 100644
--- a/server/events/mocks/matchers/azuredevops_event.go
+++ b/server/events/mocks/matchers/azuredevops_event.go
@@ -2,9 +2,10 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+ "github.com/petergtz/pegomock"
+
azuredevops "github.com/mcdafydd/go-azuredevops/azuredevops"
)
diff --git a/server/events/mocks/matchers/events_commentparseresult.go b/server/events/mocks/matchers/events_commentparseresult.go
index 194da76f3..a94641eb6 100644
--- a/server/events/mocks/matchers/events_commentparseresult.go
+++ b/server/events/mocks/matchers/events_commentparseresult.go
@@ -2,9 +2,10 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+ "github.com/petergtz/pegomock"
+
events "github.com/runatlantis/atlantis/server/events"
)
diff --git a/server/events/mocks/matchers/go_gitlab_mergecommentevent.go b/server/events/mocks/matchers/go_gitlab_mergecommentevent.go
index 37e79a883..55b1550aa 100644
--- a/server/events/mocks/matchers/go_gitlab_mergecommentevent.go
+++ b/server/events/mocks/matchers/go_gitlab_mergecommentevent.go
@@ -2,9 +2,10 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+ "github.com/petergtz/pegomock"
+
go_gitlab "github.com/xanzy/go-gitlab"
)
diff --git a/server/events/mocks/matchers/go_gitlab_mergeevent.go b/server/events/mocks/matchers/go_gitlab_mergeevent.go
index 4276b1f06..364df9b4b 100644
--- a/server/events/mocks/matchers/go_gitlab_mergeevent.go
+++ b/server/events/mocks/matchers/go_gitlab_mergeevent.go
@@ -2,9 +2,10 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+ "github.com/petergtz/pegomock"
+
go_gitlab "github.com/xanzy/go-gitlab"
)
diff --git a/server/events/mocks/matchers/jobs_pullinfo.go b/server/events/mocks/matchers/jobs_pullinfo.go
index 95e16a16f..64141c6b3 100644
--- a/server/events/mocks/matchers/jobs_pullinfo.go
+++ b/server/events/mocks/matchers/jobs_pullinfo.go
@@ -2,9 +2,10 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+ "github.com/petergtz/pegomock"
+
jobs "github.com/runatlantis/atlantis/server/jobs"
)
diff --git a/server/events/mocks/matchers/logging_simplelogging.go b/server/events/mocks/matchers/logging_simplelogging.go
index 502456e7c..c3b96f61f 100644
--- a/server/events/mocks/matchers/logging_simplelogging.go
+++ b/server/events/mocks/matchers/logging_simplelogging.go
@@ -2,9 +2,10 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+ "github.com/petergtz/pegomock"
+
logging "github.com/runatlantis/atlantis/server/logging"
)
diff --git a/server/events/mocks/matchers/map_of_string_to_string.go b/server/events/mocks/matchers/map_of_string_to_string.go
index 65175de1a..e1683b5df 100644
--- a/server/events/mocks/matchers/map_of_string_to_string.go
+++ b/server/events/mocks/matchers/map_of_string_to_string.go
@@ -2,8 +2,9 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+
+ "github.com/petergtz/pegomock"
)
func AnyMapOfStringToString() map[string]string {
diff --git a/server/events/mocks/matchers/models_commandname.go b/server/events/mocks/matchers/models_commandname.go
index f586b4d21..aec79b126 100644
--- a/server/events/mocks/matchers/models_commandname.go
+++ b/server/events/mocks/matchers/models_commandname.go
@@ -2,32 +2,32 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
- models "github.com/runatlantis/atlantis/server/events/models"
+ "github.com/petergtz/pegomock"
+ "github.com/runatlantis/atlantis/server/events/command"
)
-func AnyModelsCommandName() models.CommandName {
- pegomock.RegisterMatcher(pegomock.NewAnyMatcher(reflect.TypeOf((*(models.CommandName))(nil)).Elem()))
- var nullValue models.CommandName
+func AnyModelsCommandName() command.Name {
+ pegomock.RegisterMatcher(pegomock.NewAnyMatcher(reflect.TypeOf((*(command.Name))(nil)).Elem()))
+ var nullValue command.Name
return nullValue
}
-func EqModelsCommandName(value models.CommandName) models.CommandName {
+func EqModelsCommandName(value command.Name) command.Name {
pegomock.RegisterMatcher(&pegomock.EqMatcher{Value: value})
- var nullValue models.CommandName
+ var nullValue command.Name
return nullValue
}
-func NotEqModelsCommandName(value models.CommandName) models.CommandName {
+func NotEqModelsCommandName(value command.Name) command.Name {
pegomock.RegisterMatcher(&pegomock.NotEqMatcher{Value: value})
- var nullValue models.CommandName
+ var nullValue command.Name
return nullValue
}
-func ModelsCommandNameThat(matcher pegomock.ArgumentMatcher) models.CommandName {
+func ModelsCommandNameThat(matcher pegomock.ArgumentMatcher) command.Name {
pegomock.RegisterMatcher(matcher)
- var nullValue models.CommandName
+ var nullValue command.Name
return nullValue
}
diff --git a/server/events/mocks/matchers/models_commitstatus.go b/server/events/mocks/matchers/models_commitstatus.go
index 1e10ed782..5ebf733ee 100644
--- a/server/events/mocks/matchers/models_commitstatus.go
+++ b/server/events/mocks/matchers/models_commitstatus.go
@@ -2,9 +2,10 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+ "github.com/petergtz/pegomock"
+
models "github.com/runatlantis/atlantis/server/events/models"
)
diff --git a/server/events/mocks/matchers/models_project.go b/server/events/mocks/matchers/models_project.go
index a5a87e6f0..0cc4104e5 100644
--- a/server/events/mocks/matchers/models_project.go
+++ b/server/events/mocks/matchers/models_project.go
@@ -2,9 +2,10 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+ "github.com/petergtz/pegomock"
+
models "github.com/runatlantis/atlantis/server/events/models"
)
diff --git a/server/events/mocks/matchers/models_projectcommandcontext.go b/server/events/mocks/matchers/models_projectcommandcontext.go
index 535f8b967..90db05bac 100644
--- a/server/events/mocks/matchers/models_projectcommandcontext.go
+++ b/server/events/mocks/matchers/models_projectcommandcontext.go
@@ -2,32 +2,32 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
- models "github.com/runatlantis/atlantis/server/events/models"
+ "github.com/petergtz/pegomock"
+ "github.com/runatlantis/atlantis/server/events/command"
)
-func AnyModelsProjectCommandContext() models.ProjectCommandContext {
- pegomock.RegisterMatcher(pegomock.NewAnyMatcher(reflect.TypeOf((*(models.ProjectCommandContext))(nil)).Elem()))
- var nullValue models.ProjectCommandContext
+func AnyModelsProjectCommandContext() command.ProjectContext {
+ pegomock.RegisterMatcher(pegomock.NewAnyMatcher(reflect.TypeOf((*(command.ProjectContext))(nil)).Elem()))
+ var nullValue command.ProjectContext
return nullValue
}
-func EqModelsProjectCommandContext(value models.ProjectCommandContext) models.ProjectCommandContext {
+func EqModelsProjectCommandContext(value command.ProjectContext) command.ProjectContext {
pegomock.RegisterMatcher(&pegomock.EqMatcher{Value: value})
- var nullValue models.ProjectCommandContext
+ var nullValue command.ProjectContext
return nullValue
}
-func NotEqModelsProjectCommandContext(value models.ProjectCommandContext) models.ProjectCommandContext {
+func NotEqModelsProjectCommandContext(value command.ProjectContext) command.ProjectContext {
pegomock.RegisterMatcher(&pegomock.NotEqMatcher{Value: value})
- var nullValue models.ProjectCommandContext
+ var nullValue command.ProjectContext
return nullValue
}
-func ModelsProjectCommandContextThat(matcher pegomock.ArgumentMatcher) models.ProjectCommandContext {
+func ModelsProjectCommandContextThat(matcher pegomock.ArgumentMatcher) command.ProjectContext {
pegomock.RegisterMatcher(matcher)
- var nullValue models.ProjectCommandContext
+ var nullValue command.ProjectContext
return nullValue
}
diff --git a/server/events/mocks/matchers/models_projectresult.go b/server/events/mocks/matchers/models_projectresult.go
index 0eee757ef..8ceee5c06 100644
--- a/server/events/mocks/matchers/models_projectresult.go
+++ b/server/events/mocks/matchers/models_projectresult.go
@@ -2,32 +2,32 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
- models "github.com/runatlantis/atlantis/server/events/models"
+ "github.com/petergtz/pegomock"
+ "github.com/runatlantis/atlantis/server/events/command"
)
-func AnyModelsProjectResult() models.ProjectResult {
- pegomock.RegisterMatcher(pegomock.NewAnyMatcher(reflect.TypeOf((*(models.ProjectResult))(nil)).Elem()))
- var nullValue models.ProjectResult
+func AnyModelsProjectResult() command.ProjectResult {
+ pegomock.RegisterMatcher(pegomock.NewAnyMatcher(reflect.TypeOf((*(command.ProjectResult))(nil)).Elem()))
+ var nullValue command.ProjectResult
return nullValue
}
-func EqModelsProjectResult(value models.ProjectResult) models.ProjectResult {
+func EqModelsProjectResult(value command.ProjectResult) command.ProjectResult {
pegomock.RegisterMatcher(&pegomock.EqMatcher{Value: value})
- var nullValue models.ProjectResult
+ var nullValue command.ProjectResult
return nullValue
}
-func NotEqModelsProjectResult(value models.ProjectResult) models.ProjectResult {
+func NotEqModelsProjectResult(value command.ProjectResult) command.ProjectResult {
pegomock.RegisterMatcher(&pegomock.NotEqMatcher{Value: value})
- var nullValue models.ProjectResult
+ var nullValue command.ProjectResult
return nullValue
}
-func ModelsProjectResultThat(matcher pegomock.ArgumentMatcher) models.ProjectResult {
+func ModelsProjectResultThat(matcher pegomock.ArgumentMatcher) command.ProjectResult {
pegomock.RegisterMatcher(matcher)
- var nullValue models.ProjectResult
+ var nullValue command.ProjectResult
return nullValue
}
diff --git a/server/events/mocks/matchers/models_pullrequest.go b/server/events/mocks/matchers/models_pullrequest.go
index 9ae2a7e92..db2666f02 100644
--- a/server/events/mocks/matchers/models_pullrequest.go
+++ b/server/events/mocks/matchers/models_pullrequest.go
@@ -2,9 +2,10 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+ "github.com/petergtz/pegomock"
+
models "github.com/runatlantis/atlantis/server/events/models"
)
diff --git a/server/events/mocks/matchers/models_pullrequesteventtype.go b/server/events/mocks/matchers/models_pullrequesteventtype.go
index 5952b4189..70d8f9e98 100644
--- a/server/events/mocks/matchers/models_pullrequesteventtype.go
+++ b/server/events/mocks/matchers/models_pullrequesteventtype.go
@@ -2,9 +2,10 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+ "github.com/petergtz/pegomock"
+
models "github.com/runatlantis/atlantis/server/events/models"
)
diff --git a/server/events/mocks/matchers/models_repo.go b/server/events/mocks/matchers/models_repo.go
index fd44665f8..2ca60819c 100644
--- a/server/events/mocks/matchers/models_repo.go
+++ b/server/events/mocks/matchers/models_repo.go
@@ -2,9 +2,10 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+ "github.com/petergtz/pegomock"
+
models "github.com/runatlantis/atlantis/server/events/models"
)
diff --git a/server/events/mocks/matchers/models_user.go b/server/events/mocks/matchers/models_user.go
index 0aa92b5d8..e9bf1384b 100644
--- a/server/events/mocks/matchers/models_user.go
+++ b/server/events/mocks/matchers/models_user.go
@@ -2,9 +2,10 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+ "github.com/petergtz/pegomock"
+
models "github.com/runatlantis/atlantis/server/events/models"
)
diff --git a/server/events/mocks/matchers/models_vcshosttype.go b/server/events/mocks/matchers/models_vcshosttype.go
index a54447f7d..e9af870aa 100644
--- a/server/events/mocks/matchers/models_vcshosttype.go
+++ b/server/events/mocks/matchers/models_vcshosttype.go
@@ -2,9 +2,10 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+ "github.com/petergtz/pegomock"
+
models "github.com/runatlantis/atlantis/server/events/models"
)
diff --git a/server/events/mocks/matchers/ptr_to_azuredevops_gitpullrequest.go b/server/events/mocks/matchers/ptr_to_azuredevops_gitpullrequest.go
index 7a3bf3a69..e6dcaa96a 100644
--- a/server/events/mocks/matchers/ptr_to_azuredevops_gitpullrequest.go
+++ b/server/events/mocks/matchers/ptr_to_azuredevops_gitpullrequest.go
@@ -2,9 +2,10 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+ "github.com/petergtz/pegomock"
+
azuredevops "github.com/mcdafydd/go-azuredevops/azuredevops"
)
diff --git a/server/events/mocks/matchers/ptr_to_azuredevops_gitrepository.go b/server/events/mocks/matchers/ptr_to_azuredevops_gitrepository.go
index d9f81edff..8b0fd47ab 100644
--- a/server/events/mocks/matchers/ptr_to_azuredevops_gitrepository.go
+++ b/server/events/mocks/matchers/ptr_to_azuredevops_gitrepository.go
@@ -2,9 +2,10 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+ "github.com/petergtz/pegomock"
+
azuredevops "github.com/mcdafydd/go-azuredevops/azuredevops"
)
diff --git a/server/events/mocks/matchers/ptr_to_events_commandcontext.go b/server/events/mocks/matchers/ptr_to_events_commandcontext.go
index 60fe56924..98eee775b 100644
--- a/server/events/mocks/matchers/ptr_to_events_commandcontext.go
+++ b/server/events/mocks/matchers/ptr_to_events_commandcontext.go
@@ -2,32 +2,32 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
- events "github.com/runatlantis/atlantis/server/events"
+ "github.com/petergtz/pegomock"
+ "github.com/runatlantis/atlantis/server/events/command"
)
-func AnyPtrToEventsCommandContext() *events.CommandContext {
- pegomock.RegisterMatcher(pegomock.NewAnyMatcher(reflect.TypeOf((*(*events.CommandContext))(nil)).Elem()))
- var nullValue *events.CommandContext
+func AnyPtrToEventsCommandContext() *command.Context {
+ pegomock.RegisterMatcher(pegomock.NewAnyMatcher(reflect.TypeOf((*(*command.Context))(nil)).Elem()))
+ var nullValue *command.Context
return nullValue
}
-func EqPtrToEventsCommandContext(value *events.CommandContext) *events.CommandContext {
+func EqPtrToEventsCommandContext(value *command.Context) *command.Context {
pegomock.RegisterMatcher(&pegomock.EqMatcher{Value: value})
- var nullValue *events.CommandContext
+ var nullValue *command.Context
return nullValue
}
-func NotEqPtrToEventsCommandContext(value *events.CommandContext) *events.CommandContext {
+func NotEqPtrToEventsCommandContext(value *command.Context) *command.Context {
pegomock.RegisterMatcher(&pegomock.NotEqMatcher{Value: value})
- var nullValue *events.CommandContext
+ var nullValue *command.Context
return nullValue
}
-func PtrToEventsCommandContextThat(matcher pegomock.ArgumentMatcher) *events.CommandContext {
+func PtrToEventsCommandContextThat(matcher pegomock.ArgumentMatcher) *command.Context {
pegomock.RegisterMatcher(matcher)
- var nullValue *events.CommandContext
+ var nullValue *command.Context
return nullValue
}
diff --git a/server/events/mocks/matchers/ptr_to_events_commentcommand.go b/server/events/mocks/matchers/ptr_to_events_commentcommand.go
index 55b3b5ba6..23d7794d0 100644
--- a/server/events/mocks/matchers/ptr_to_events_commentcommand.go
+++ b/server/events/mocks/matchers/ptr_to_events_commentcommand.go
@@ -2,9 +2,10 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+ "github.com/petergtz/pegomock"
+
events "github.com/runatlantis/atlantis/server/events"
)
diff --git a/server/events/mocks/matchers/ptr_to_events_trylockresponse.go b/server/events/mocks/matchers/ptr_to_events_trylockresponse.go
index 71d8a4721..7abec1dcf 100644
--- a/server/events/mocks/matchers/ptr_to_events_trylockresponse.go
+++ b/server/events/mocks/matchers/ptr_to_events_trylockresponse.go
@@ -2,9 +2,10 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+ "github.com/petergtz/pegomock"
+
events "github.com/runatlantis/atlantis/server/events"
)
diff --git a/server/events/mocks/matchers/ptr_to_github_issuecommentevent.go b/server/events/mocks/matchers/ptr_to_github_issuecommentevent.go
index 919b42f26..dfc9029af 100644
--- a/server/events/mocks/matchers/ptr_to_github_issuecommentevent.go
+++ b/server/events/mocks/matchers/ptr_to_github_issuecommentevent.go
@@ -2,9 +2,10 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+ "github.com/petergtz/pegomock"
+
github "github.com/google/go-github/v31/github"
)
diff --git a/server/events/mocks/matchers/ptr_to_github_pullrequest.go b/server/events/mocks/matchers/ptr_to_github_pullrequest.go
index d7cc48f64..0ac17c2a2 100644
--- a/server/events/mocks/matchers/ptr_to_github_pullrequest.go
+++ b/server/events/mocks/matchers/ptr_to_github_pullrequest.go
@@ -2,9 +2,10 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+ "github.com/petergtz/pegomock"
+
github "github.com/google/go-github/v31/github"
)
diff --git a/server/events/mocks/matchers/ptr_to_github_pullrequestevent.go b/server/events/mocks/matchers/ptr_to_github_pullrequestevent.go
index 5a247a90c..9bf4f7947 100644
--- a/server/events/mocks/matchers/ptr_to_github_pullrequestevent.go
+++ b/server/events/mocks/matchers/ptr_to_github_pullrequestevent.go
@@ -2,9 +2,10 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+ "github.com/petergtz/pegomock"
+
github "github.com/google/go-github/v31/github"
)
diff --git a/server/events/mocks/matchers/ptr_to_github_repository.go b/server/events/mocks/matchers/ptr_to_github_repository.go
index 322d3d0fd..34a0529af 100644
--- a/server/events/mocks/matchers/ptr_to_github_repository.go
+++ b/server/events/mocks/matchers/ptr_to_github_repository.go
@@ -2,9 +2,10 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+ "github.com/petergtz/pegomock"
+
github "github.com/google/go-github/v31/github"
)
diff --git a/server/events/mocks/matchers/ptr_to_go_gitlab_mergerequest.go b/server/events/mocks/matchers/ptr_to_go_gitlab_mergerequest.go
index 245737cfa..bece355ab 100644
--- a/server/events/mocks/matchers/ptr_to_go_gitlab_mergerequest.go
+++ b/server/events/mocks/matchers/ptr_to_go_gitlab_mergerequest.go
@@ -2,9 +2,10 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+ "github.com/petergtz/pegomock"
+
go_gitlab "github.com/xanzy/go-gitlab"
)
diff --git a/server/events/mocks/matchers/ptr_to_logging_simplelogger.go b/server/events/mocks/matchers/ptr_to_logging_simplelogger.go
index cf9bb5453..e7c8b942f 100644
--- a/server/events/mocks/matchers/ptr_to_logging_simplelogger.go
+++ b/server/events/mocks/matchers/ptr_to_logging_simplelogger.go
@@ -2,9 +2,10 @@
package matchers
import (
+ "reflect"
+
"github.com/petergtz/pegomock"
logging "github.com/runatlantis/atlantis/server/logging"
- "reflect"
)
func AnyPtrToLoggingSimpleLogger() logging.SimpleLogging {
diff --git a/server/events/mocks/matchers/ptr_to_models_commandcontext.go b/server/events/mocks/matchers/ptr_to_models_commandcontext.go
index ca6abf31d..bab386e87 100644
--- a/server/events/mocks/matchers/ptr_to_models_commandcontext.go
+++ b/server/events/mocks/matchers/ptr_to_models_commandcontext.go
@@ -2,19 +2,20 @@
package matchers
import (
- "github.com/petergtz/pegomock"
- events "github.com/runatlantis/atlantis/server/events"
"reflect"
+
+ "github.com/petergtz/pegomock"
+ "github.com/runatlantis/atlantis/server/events/command"
)
-func AnyPtrToModelsCommandContext() *events.CommandContext {
- pegomock.RegisterMatcher(pegomock.NewAnyMatcher(reflect.TypeOf((*(*events.CommandContext))(nil)).Elem()))
- var nullValue *events.CommandContext
+func AnyPtrToModelsCommandContext() *command.Context {
+ pegomock.RegisterMatcher(pegomock.NewAnyMatcher(reflect.TypeOf((*(*command.Context))(nil)).Elem()))
+ var nullValue *command.Context
return nullValue
}
-func EqPtrToModelsCommandContext(value *events.CommandContext) *events.CommandContext {
+func EqPtrToModelsCommandContext(value *command.Context) *command.Context {
pegomock.RegisterMatcher(&pegomock.EqMatcher{Value: value})
- var nullValue *events.CommandContext
+ var nullValue *command.Context
return nullValue
}
diff --git a/server/events/mocks/matchers/ptr_to_models_projectlock.go b/server/events/mocks/matchers/ptr_to_models_projectlock.go
index 7b0b6f108..c33537f97 100644
--- a/server/events/mocks/matchers/ptr_to_models_projectlock.go
+++ b/server/events/mocks/matchers/ptr_to_models_projectlock.go
@@ -2,9 +2,10 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+ "github.com/petergtz/pegomock"
+
models "github.com/runatlantis/atlantis/server/events/models"
)
diff --git a/server/events/mocks/matchers/ptr_to_models_pullrequest.go b/server/events/mocks/matchers/ptr_to_models_pullrequest.go
index 1f8678a09..435081d1a 100644
--- a/server/events/mocks/matchers/ptr_to_models_pullrequest.go
+++ b/server/events/mocks/matchers/ptr_to_models_pullrequest.go
@@ -2,9 +2,10 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+ "github.com/petergtz/pegomock"
+
models "github.com/runatlantis/atlantis/server/events/models"
)
diff --git a/server/events/mocks/matchers/ptr_to_models_repo.go b/server/events/mocks/matchers/ptr_to_models_repo.go
index a85a0629a..720b22214 100644
--- a/server/events/mocks/matchers/ptr_to_models_repo.go
+++ b/server/events/mocks/matchers/ptr_to_models_repo.go
@@ -2,9 +2,10 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+ "github.com/petergtz/pegomock"
+
models "github.com/runatlantis/atlantis/server/events/models"
)
diff --git a/server/events/mocks/matchers/slice_of_byte.go b/server/events/mocks/matchers/slice_of_byte.go
index 951531345..7ff2e45ca 100644
--- a/server/events/mocks/matchers/slice_of_byte.go
+++ b/server/events/mocks/matchers/slice_of_byte.go
@@ -2,8 +2,9 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+
+ "github.com/petergtz/pegomock"
)
func AnySliceOfByte() []byte {
diff --git a/server/events/mocks/matchers/slice_of_events_pendingplan.go b/server/events/mocks/matchers/slice_of_events_pendingplan.go
index 59eb3d579..b7523e455 100644
--- a/server/events/mocks/matchers/slice_of_events_pendingplan.go
+++ b/server/events/mocks/matchers/slice_of_events_pendingplan.go
@@ -2,9 +2,10 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+ "github.com/petergtz/pegomock"
+
events "github.com/runatlantis/atlantis/server/events"
)
diff --git a/server/events/mocks/matchers/slice_of_models_projectcommandcontext.go b/server/events/mocks/matchers/slice_of_models_projectcommandcontext.go
index 2eb2ecbfd..1e43301e2 100644
--- a/server/events/mocks/matchers/slice_of_models_projectcommandcontext.go
+++ b/server/events/mocks/matchers/slice_of_models_projectcommandcontext.go
@@ -2,32 +2,32 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
- models "github.com/runatlantis/atlantis/server/events/models"
+ "github.com/petergtz/pegomock"
+ "github.com/runatlantis/atlantis/server/events/command"
)
-func AnySliceOfModelsProjectCommandContext() []models.ProjectCommandContext {
- pegomock.RegisterMatcher(pegomock.NewAnyMatcher(reflect.TypeOf((*([]models.ProjectCommandContext))(nil)).Elem()))
- var nullValue []models.ProjectCommandContext
+func AnySliceOfModelsProjectCommandContext() []command.ProjectContext {
+ pegomock.RegisterMatcher(pegomock.NewAnyMatcher(reflect.TypeOf((*([]command.ProjectContext))(nil)).Elem()))
+ var nullValue []command.ProjectContext
return nullValue
}
-func EqSliceOfModelsProjectCommandContext(value []models.ProjectCommandContext) []models.ProjectCommandContext {
+func EqSliceOfModelsProjectCommandContext(value []command.ProjectContext) []command.ProjectContext {
pegomock.RegisterMatcher(&pegomock.EqMatcher{Value: value})
- var nullValue []models.ProjectCommandContext
+ var nullValue []command.ProjectContext
return nullValue
}
-func NotEqSliceOfModelsProjectCommandContext(value []models.ProjectCommandContext) []models.ProjectCommandContext {
+func NotEqSliceOfModelsProjectCommandContext(value []command.ProjectContext) []command.ProjectContext {
pegomock.RegisterMatcher(&pegomock.NotEqMatcher{Value: value})
- var nullValue []models.ProjectCommandContext
+ var nullValue []command.ProjectContext
return nullValue
}
-func SliceOfModelsProjectCommandContextThat(matcher pegomock.ArgumentMatcher) []models.ProjectCommandContext {
+func SliceOfModelsProjectCommandContextThat(matcher pegomock.ArgumentMatcher) []command.ProjectContext {
pegomock.RegisterMatcher(matcher)
- var nullValue []models.ProjectCommandContext
+ var nullValue []command.ProjectContext
return nullValue
}
diff --git a/server/events/mocks/matchers/slice_of_string.go b/server/events/mocks/matchers/slice_of_string.go
index f9281819d..8bfc2792f 100644
--- a/server/events/mocks/matchers/slice_of_string.go
+++ b/server/events/mocks/matchers/slice_of_string.go
@@ -2,8 +2,9 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+
+ "github.com/petergtz/pegomock"
)
func AnySliceOfString() []string {
diff --git a/server/events/mocks/matchers/webhooks_applyresult.go b/server/events/mocks/matchers/webhooks_applyresult.go
index adbcf9817..6b1878e32 100644
--- a/server/events/mocks/matchers/webhooks_applyresult.go
+++ b/server/events/mocks/matchers/webhooks_applyresult.go
@@ -2,9 +2,10 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+ "github.com/petergtz/pegomock"
+
webhooks "github.com/runatlantis/atlantis/server/events/webhooks"
)
diff --git a/server/events/mocks/mock_apply_command_locker.go b/server/events/mocks/mock_apply_command_locker.go
index 37fc004d7..28c3cd441 100644
--- a/server/events/mocks/mock_apply_command_locker.go
+++ b/server/events/mocks/mock_apply_command_locker.go
@@ -4,10 +4,11 @@
package mocks
import (
- pegomock "github.com/petergtz/pegomock"
- events "github.com/runatlantis/atlantis/server/events"
"reflect"
"time"
+
+ pegomock "github.com/petergtz/pegomock"
+ "github.com/runatlantis/atlantis/server/events/command"
)
type MockApplyCommandLocker struct {
@@ -25,7 +26,7 @@ func NewMockApplyCommandLocker(options ...pegomock.Option) *MockApplyCommandLock
func (mock *MockApplyCommandLocker) SetFailHandler(fh pegomock.FailHandler) { mock.fail = fh }
func (mock *MockApplyCommandLocker) FailHandler() pegomock.FailHandler { return mock.fail }
-func (mock *MockApplyCommandLocker) IsDisabled(ctx *events.CommandContext) bool {
+func (mock *MockApplyCommandLocker) IsDisabled(ctx *command.Context) bool {
if mock == nil {
panic("mock must not be nil. Use myMock := NewMockApplyCommandLocker().")
}
@@ -77,7 +78,7 @@ type VerifierMockApplyCommandLocker struct {
timeout time.Duration
}
-func (verifier *VerifierMockApplyCommandLocker) IsDisabled(ctx *events.CommandContext) *MockApplyCommandLocker_IsDisabled_OngoingVerification {
+func (verifier *VerifierMockApplyCommandLocker) IsDisabled(ctx *command.Context) *MockApplyCommandLocker_IsDisabled_OngoingVerification {
params := []pegomock.Param{ctx}
methodInvocations := pegomock.GetGenericMockFrom(verifier.mock).Verify(verifier.inOrderContext, verifier.invocationCountMatcher, "IsDisabled", params, verifier.timeout)
return &MockApplyCommandLocker_IsDisabled_OngoingVerification{mock: verifier.mock, methodInvocations: methodInvocations}
@@ -88,17 +89,17 @@ type MockApplyCommandLocker_IsDisabled_OngoingVerification struct {
methodInvocations []pegomock.MethodInvocation
}
-func (c *MockApplyCommandLocker_IsDisabled_OngoingVerification) GetCapturedArguments() *events.CommandContext {
+func (c *MockApplyCommandLocker_IsDisabled_OngoingVerification) GetCapturedArguments() *command.Context {
ctx := c.GetAllCapturedArguments()
return ctx[len(ctx)-1]
}
-func (c *MockApplyCommandLocker_IsDisabled_OngoingVerification) GetAllCapturedArguments() (_param0 []*events.CommandContext) {
+func (c *MockApplyCommandLocker_IsDisabled_OngoingVerification) GetAllCapturedArguments() (_param0 []*command.Context) {
params := pegomock.GetGenericMockFrom(c.mock).GetInvocationParams(c.methodInvocations)
if len(params) > 0 {
- _param0 = make([]*events.CommandContext, len(c.methodInvocations))
+ _param0 = make([]*command.Context, len(c.methodInvocations))
for u, param := range params[0] {
- _param0[u] = param.(*events.CommandContext)
+ _param0[u] = param.(*command.Context)
}
}
return
diff --git a/server/events/mocks/mock_apply_handler.go b/server/events/mocks/mock_apply_handler.go
index d9a62b29f..3bb8b2b01 100644
--- a/server/events/mocks/mock_apply_handler.go
+++ b/server/events/mocks/mock_apply_handler.go
@@ -4,10 +4,11 @@
package mocks
import (
- pegomock "github.com/petergtz/pegomock"
- models "github.com/runatlantis/atlantis/server/events/models"
"reflect"
"time"
+
+ pegomock "github.com/petergtz/pegomock"
+ "github.com/runatlantis/atlantis/server/events/command"
)
type MockApplyRequirement struct {
@@ -25,7 +26,7 @@ func NewMockApplyRequirement(options ...pegomock.Option) *MockApplyRequirement {
func (mock *MockApplyRequirement) SetFailHandler(fh pegomock.FailHandler) { mock.fail = fh }
func (mock *MockApplyRequirement) FailHandler() pegomock.FailHandler { return mock.fail }
-func (mock *MockApplyRequirement) ValidateProject(_param0 string, _param1 models.ProjectCommandContext) (string, error) {
+func (mock *MockApplyRequirement) ValidateProject(_param0 string, _param1 command.ProjectContext) (string, error) {
if mock == nil {
panic("mock must not be nil. Use myMock := NewMockApplyRequirement().")
}
@@ -81,7 +82,7 @@ type VerifierMockApplyRequirement struct {
timeout time.Duration
}
-func (verifier *VerifierMockApplyRequirement) ValidateProject(_param0 string, _param1 models.ProjectCommandContext) *MockApplyRequirement_ValidateProject_OngoingVerification {
+func (verifier *VerifierMockApplyRequirement) ValidateProject(_param0 string, _param1 command.ProjectContext) *MockApplyRequirement_ValidateProject_OngoingVerification {
params := []pegomock.Param{_param0, _param1}
methodInvocations := pegomock.GetGenericMockFrom(verifier.mock).Verify(verifier.inOrderContext, verifier.invocationCountMatcher, "ValidateProject", params, verifier.timeout)
return &MockApplyRequirement_ValidateProject_OngoingVerification{mock: verifier.mock, methodInvocations: methodInvocations}
@@ -92,21 +93,21 @@ type MockApplyRequirement_ValidateProject_OngoingVerification struct {
methodInvocations []pegomock.MethodInvocation
}
-func (c *MockApplyRequirement_ValidateProject_OngoingVerification) GetCapturedArguments() (string, models.ProjectCommandContext) {
+func (c *MockApplyRequirement_ValidateProject_OngoingVerification) GetCapturedArguments() (string, command.ProjectContext) {
_param0, _param1 := c.GetAllCapturedArguments()
return _param0[len(_param0)-1], _param1[len(_param1)-1]
}
-func (c *MockApplyRequirement_ValidateProject_OngoingVerification) GetAllCapturedArguments() (_param0 []string, _param1 []models.ProjectCommandContext) {
+func (c *MockApplyRequirement_ValidateProject_OngoingVerification) GetAllCapturedArguments() (_param0 []string, _param1 []command.ProjectContext) {
params := pegomock.GetGenericMockFrom(c.mock).GetInvocationParams(c.methodInvocations)
if len(params) > 0 {
_param0 = make([]string, len(c.methodInvocations))
for u, param := range params[0] {
_param0[u] = param.(string)
}
- _param1 = make([]models.ProjectCommandContext, len(c.methodInvocations))
+ _param1 = make([]command.ProjectContext, len(c.methodInvocations))
for u, param := range params[1] {
- _param1[u] = param.(models.ProjectCommandContext)
+ _param1[u] = param.(command.ProjectContext)
}
}
return
diff --git a/server/events/mocks/mock_azuredevops_pull_getter.go b/server/events/mocks/mock_azuredevops_pull_getter.go
index 5f7dde582..03aa6267e 100644
--- a/server/events/mocks/mock_azuredevops_pull_getter.go
+++ b/server/events/mocks/mock_azuredevops_pull_getter.go
@@ -4,11 +4,12 @@
package mocks
import (
+ "reflect"
+ "time"
+
azuredevops "github.com/mcdafydd/go-azuredevops/azuredevops"
pegomock "github.com/petergtz/pegomock"
models "github.com/runatlantis/atlantis/server/events/models"
- "reflect"
- "time"
)
type MockAzureDevopsPullGetter struct {
diff --git a/server/events/mocks/mock_command_runner.go b/server/events/mocks/mock_command_runner.go
index b4d0e4c2e..5be177db1 100644
--- a/server/events/mocks/mock_command_runner.go
+++ b/server/events/mocks/mock_command_runner.go
@@ -4,11 +4,12 @@
package mocks
import (
+ "reflect"
+ "time"
+
pegomock "github.com/petergtz/pegomock"
events "github.com/runatlantis/atlantis/server/events"
models "github.com/runatlantis/atlantis/server/events/models"
- "reflect"
- "time"
)
type MockCommandRunner struct {
diff --git a/server/events/mocks/mock_comment_building.go b/server/events/mocks/mock_comment_building.go
index 422140205..59c3ecbbb 100644
--- a/server/events/mocks/mock_comment_building.go
+++ b/server/events/mocks/mock_comment_building.go
@@ -4,9 +4,10 @@
package mocks
import (
- pegomock "github.com/petergtz/pegomock"
"reflect"
"time"
+
+ pegomock "github.com/petergtz/pegomock"
)
type MockCommentBuilder struct {
diff --git a/server/events/mocks/mock_comment_parsing.go b/server/events/mocks/mock_comment_parsing.go
index f92f3abaa..dc50085b5 100644
--- a/server/events/mocks/mock_comment_parsing.go
+++ b/server/events/mocks/mock_comment_parsing.go
@@ -4,11 +4,12 @@
package mocks
import (
+ "reflect"
+ "time"
+
pegomock "github.com/petergtz/pegomock"
events "github.com/runatlantis/atlantis/server/events"
models "github.com/runatlantis/atlantis/server/events/models"
- "reflect"
- "time"
)
type MockCommentParsing struct {
diff --git a/server/events/mocks/mock_commit_status_updater.go b/server/events/mocks/mock_commit_status_updater.go
index 67395a36e..081ed61c6 100644
--- a/server/events/mocks/mock_commit_status_updater.go
+++ b/server/events/mocks/mock_commit_status_updater.go
@@ -4,10 +4,12 @@
package mocks
import (
- pegomock "github.com/petergtz/pegomock"
- models "github.com/runatlantis/atlantis/server/events/models"
"reflect"
"time"
+
+ pegomock "github.com/petergtz/pegomock"
+ "github.com/runatlantis/atlantis/server/events/command"
+ models "github.com/runatlantis/atlantis/server/events/models"
)
type MockCommitStatusUpdater struct {
@@ -25,7 +27,7 @@ func NewMockCommitStatusUpdater(options ...pegomock.Option) *MockCommitStatusUpd
func (mock *MockCommitStatusUpdater) SetFailHandler(fh pegomock.FailHandler) { mock.fail = fh }
func (mock *MockCommitStatusUpdater) FailHandler() pegomock.FailHandler { return mock.fail }
-func (mock *MockCommitStatusUpdater) UpdateCombined(repo models.Repo, pull models.PullRequest, status models.CommitStatus, command models.CommandName) error {
+func (mock *MockCommitStatusUpdater) UpdateCombined(repo models.Repo, pull models.PullRequest, status models.CommitStatus, command command.Name) error {
if mock == nil {
panic("mock must not be nil. Use myMock := NewMockCommitStatusUpdater().")
}
@@ -40,7 +42,7 @@ func (mock *MockCommitStatusUpdater) UpdateCombined(repo models.Repo, pull model
return ret0
}
-func (mock *MockCommitStatusUpdater) UpdateCombinedCount(repo models.Repo, pull models.PullRequest, status models.CommitStatus, command models.CommandName, numSuccess int, numTotal int) error {
+func (mock *MockCommitStatusUpdater) UpdateCombinedCount(repo models.Repo, pull models.PullRequest, status models.CommitStatus, command command.Name, numSuccess int, numTotal int) error {
if mock == nil {
panic("mock must not be nil. Use myMock := NewMockCommitStatusUpdater().")
}
@@ -55,7 +57,7 @@ func (mock *MockCommitStatusUpdater) UpdateCombinedCount(repo models.Repo, pull
return ret0
}
-func (mock *MockCommitStatusUpdater) UpdateProject(ctx models.ProjectCommandContext, cmdName models.CommandName, status models.CommitStatus, url string) error {
+func (mock *MockCommitStatusUpdater) UpdateProject(ctx command.ProjectContext, cmdName command.Name, status models.CommitStatus, url string) error {
if mock == nil {
panic("mock must not be nil. Use myMock := NewMockCommitStatusUpdater().")
}
@@ -107,7 +109,7 @@ type VerifierMockCommitStatusUpdater struct {
timeout time.Duration
}
-func (verifier *VerifierMockCommitStatusUpdater) UpdateCombined(repo models.Repo, pull models.PullRequest, status models.CommitStatus, command models.CommandName) *MockCommitStatusUpdater_UpdateCombined_OngoingVerification {
+func (verifier *VerifierMockCommitStatusUpdater) UpdateCombined(repo models.Repo, pull models.PullRequest, status models.CommitStatus, command command.Name) *MockCommitStatusUpdater_UpdateCombined_OngoingVerification {
params := []pegomock.Param{repo, pull, status, command}
methodInvocations := pegomock.GetGenericMockFrom(verifier.mock).Verify(verifier.inOrderContext, verifier.invocationCountMatcher, "UpdateCombined", params, verifier.timeout)
return &MockCommitStatusUpdater_UpdateCombined_OngoingVerification{mock: verifier.mock, methodInvocations: methodInvocations}
@@ -118,12 +120,12 @@ type MockCommitStatusUpdater_UpdateCombined_OngoingVerification struct {
methodInvocations []pegomock.MethodInvocation
}
-func (c *MockCommitStatusUpdater_UpdateCombined_OngoingVerification) GetCapturedArguments() (models.Repo, models.PullRequest, models.CommitStatus, models.CommandName) {
+func (c *MockCommitStatusUpdater_UpdateCombined_OngoingVerification) GetCapturedArguments() (models.Repo, models.PullRequest, models.CommitStatus, command.Name) {
repo, pull, status, command := c.GetAllCapturedArguments()
return repo[len(repo)-1], pull[len(pull)-1], status[len(status)-1], command[len(command)-1]
}
-func (c *MockCommitStatusUpdater_UpdateCombined_OngoingVerification) GetAllCapturedArguments() (_param0 []models.Repo, _param1 []models.PullRequest, _param2 []models.CommitStatus, _param3 []models.CommandName) {
+func (c *MockCommitStatusUpdater_UpdateCombined_OngoingVerification) GetAllCapturedArguments() (_param0 []models.Repo, _param1 []models.PullRequest, _param2 []models.CommitStatus, _param3 []command.Name) {
params := pegomock.GetGenericMockFrom(c.mock).GetInvocationParams(c.methodInvocations)
if len(params) > 0 {
_param0 = make([]models.Repo, len(c.methodInvocations))
@@ -138,16 +140,16 @@ func (c *MockCommitStatusUpdater_UpdateCombined_OngoingVerification) GetAllCaptu
for u, param := range params[2] {
_param2[u] = param.(models.CommitStatus)
}
- _param3 = make([]models.CommandName, len(c.methodInvocations))
+ _param3 = make([]command.Name, len(c.methodInvocations))
for u, param := range params[3] {
- _param3[u] = param.(models.CommandName)
+ _param3[u] = param.(command.Name)
}
}
return
}
-func (verifier *VerifierMockCommitStatusUpdater) UpdateCombinedCount(repo models.Repo, pull models.PullRequest, status models.CommitStatus, command models.CommandName, numSuccess int, numTotal int) *MockCommitStatusUpdater_UpdateCombinedCount_OngoingVerification {
- params := []pegomock.Param{repo, pull, status, command, numSuccess, numTotal}
+func (verifier *VerifierMockCommitStatusUpdater) UpdateCombinedCount(repo models.Repo, pull models.PullRequest, status models.CommitStatus, cmd command.Name, numSuccess int, numTotal int) *MockCommitStatusUpdater_UpdateCombinedCount_OngoingVerification {
+ params := []pegomock.Param{repo, pull, status, cmd, numSuccess, numTotal}
methodInvocations := pegomock.GetGenericMockFrom(verifier.mock).Verify(verifier.inOrderContext, verifier.invocationCountMatcher, "UpdateCombinedCount", params, verifier.timeout)
return &MockCommitStatusUpdater_UpdateCombinedCount_OngoingVerification{mock: verifier.mock, methodInvocations: methodInvocations}
}
@@ -157,12 +159,12 @@ type MockCommitStatusUpdater_UpdateCombinedCount_OngoingVerification struct {
methodInvocations []pegomock.MethodInvocation
}
-func (c *MockCommitStatusUpdater_UpdateCombinedCount_OngoingVerification) GetCapturedArguments() (models.Repo, models.PullRequest, models.CommitStatus, models.CommandName, int, int) {
+func (c *MockCommitStatusUpdater_UpdateCombinedCount_OngoingVerification) GetCapturedArguments() (models.Repo, models.PullRequest, models.CommitStatus, command.Name, int, int) {
repo, pull, status, command, numSuccess, numTotal := c.GetAllCapturedArguments()
return repo[len(repo)-1], pull[len(pull)-1], status[len(status)-1], command[len(command)-1], numSuccess[len(numSuccess)-1], numTotal[len(numTotal)-1]
}
-func (c *MockCommitStatusUpdater_UpdateCombinedCount_OngoingVerification) GetAllCapturedArguments() (_param0 []models.Repo, _param1 []models.PullRequest, _param2 []models.CommitStatus, _param3 []models.CommandName, _param4 []int, _param5 []int) {
+func (c *MockCommitStatusUpdater_UpdateCombinedCount_OngoingVerification) GetAllCapturedArguments() (_param0 []models.Repo, _param1 []models.PullRequest, _param2 []models.CommitStatus, _param3 []command.Name, _param4 []int, _param5 []int) {
params := pegomock.GetGenericMockFrom(c.mock).GetInvocationParams(c.methodInvocations)
if len(params) > 0 {
_param0 = make([]models.Repo, len(c.methodInvocations))
@@ -177,9 +179,9 @@ func (c *MockCommitStatusUpdater_UpdateCombinedCount_OngoingVerification) GetAll
for u, param := range params[2] {
_param2[u] = param.(models.CommitStatus)
}
- _param3 = make([]models.CommandName, len(c.methodInvocations))
+ _param3 = make([]command.Name, len(c.methodInvocations))
for u, param := range params[3] {
- _param3[u] = param.(models.CommandName)
+ _param3[u] = param.(command.Name)
}
_param4 = make([]int, len(c.methodInvocations))
for u, param := range params[4] {
@@ -193,7 +195,7 @@ func (c *MockCommitStatusUpdater_UpdateCombinedCount_OngoingVerification) GetAll
return
}
-func (verifier *VerifierMockCommitStatusUpdater) UpdateProject(ctx models.ProjectCommandContext, cmdName models.CommandName, status models.CommitStatus, url string) *MockCommitStatusUpdater_UpdateProject_OngoingVerification {
+func (verifier *VerifierMockCommitStatusUpdater) UpdateProject(ctx command.ProjectContext, cmdName command.Name, status models.CommitStatus, url string) *MockCommitStatusUpdater_UpdateProject_OngoingVerification {
params := []pegomock.Param{ctx, cmdName, status, url}
methodInvocations := pegomock.GetGenericMockFrom(verifier.mock).Verify(verifier.inOrderContext, verifier.invocationCountMatcher, "UpdateProject", params, verifier.timeout)
return &MockCommitStatusUpdater_UpdateProject_OngoingVerification{mock: verifier.mock, methodInvocations: methodInvocations}
@@ -204,21 +206,21 @@ type MockCommitStatusUpdater_UpdateProject_OngoingVerification struct {
methodInvocations []pegomock.MethodInvocation
}
-func (c *MockCommitStatusUpdater_UpdateProject_OngoingVerification) GetCapturedArguments() (models.ProjectCommandContext, models.CommandName, models.CommitStatus, string) {
+func (c *MockCommitStatusUpdater_UpdateProject_OngoingVerification) GetCapturedArguments() (command.ProjectContext, command.Name, models.CommitStatus, string) {
ctx, cmdName, status, url := c.GetAllCapturedArguments()
return ctx[len(ctx)-1], cmdName[len(cmdName)-1], status[len(status)-1], url[len(url)-1]
}
-func (c *MockCommitStatusUpdater_UpdateProject_OngoingVerification) GetAllCapturedArguments() (_param0 []models.ProjectCommandContext, _param1 []models.CommandName, _param2 []models.CommitStatus, _param3 []string) {
+func (c *MockCommitStatusUpdater_UpdateProject_OngoingVerification) GetAllCapturedArguments() (_param0 []command.ProjectContext, _param1 []command.Name, _param2 []models.CommitStatus, _param3 []string) {
params := pegomock.GetGenericMockFrom(c.mock).GetInvocationParams(c.methodInvocations)
if len(params) > 0 {
- _param0 = make([]models.ProjectCommandContext, len(c.methodInvocations))
+ _param0 = make([]command.ProjectContext, len(c.methodInvocations))
for u, param := range params[0] {
- _param0[u] = param.(models.ProjectCommandContext)
+ _param0[u] = param.(command.ProjectContext)
}
- _param1 = make([]models.CommandName, len(c.methodInvocations))
+ _param1 = make([]command.Name, len(c.methodInvocations))
for u, param := range params[1] {
- _param1[u] = param.(models.CommandName)
+ _param1[u] = param.(command.Name)
}
_param2 = make([]models.CommitStatus, len(c.methodInvocations))
for u, param := range params[2] {
diff --git a/server/events/mocks/mock_custom_step_runner.go b/server/events/mocks/mock_custom_step_runner.go
index 21d1fffa8..649066066 100644
--- a/server/events/mocks/mock_custom_step_runner.go
+++ b/server/events/mocks/mock_custom_step_runner.go
@@ -4,10 +4,11 @@
package mocks
import (
- pegomock "github.com/petergtz/pegomock"
- models "github.com/runatlantis/atlantis/server/events/models"
"reflect"
"time"
+
+ pegomock "github.com/petergtz/pegomock"
+ "github.com/runatlantis/atlantis/server/events/command"
)
type MockCustomStepRunner struct {
@@ -25,7 +26,7 @@ func NewMockCustomStepRunner(options ...pegomock.Option) *MockCustomStepRunner {
func (mock *MockCustomStepRunner) SetFailHandler(fh pegomock.FailHandler) { mock.fail = fh }
func (mock *MockCustomStepRunner) FailHandler() pegomock.FailHandler { return mock.fail }
-func (mock *MockCustomStepRunner) Run(ctx models.ProjectCommandContext, cmd string, path string, envs map[string]string) (string, error) {
+func (mock *MockCustomStepRunner) Run(ctx command.ProjectContext, cmd string, path string, envs map[string]string) (string, error) {
if mock == nil {
panic("mock must not be nil. Use myMock := NewMockCustomStepRunner().")
}
@@ -81,7 +82,7 @@ type VerifierMockCustomStepRunner struct {
timeout time.Duration
}
-func (verifier *VerifierMockCustomStepRunner) Run(ctx models.ProjectCommandContext, cmd string, path string, envs map[string]string) *MockCustomStepRunner_Run_OngoingVerification {
+func (verifier *VerifierMockCustomStepRunner) Run(ctx command.ProjectContext, cmd string, path string, envs map[string]string) *MockCustomStepRunner_Run_OngoingVerification {
params := []pegomock.Param{ctx, cmd, path, envs}
methodInvocations := pegomock.GetGenericMockFrom(verifier.mock).Verify(verifier.inOrderContext, verifier.invocationCountMatcher, "Run", params, verifier.timeout)
return &MockCustomStepRunner_Run_OngoingVerification{mock: verifier.mock, methodInvocations: methodInvocations}
@@ -92,17 +93,17 @@ type MockCustomStepRunner_Run_OngoingVerification struct {
methodInvocations []pegomock.MethodInvocation
}
-func (c *MockCustomStepRunner_Run_OngoingVerification) GetCapturedArguments() (models.ProjectCommandContext, string, string, map[string]string) {
+func (c *MockCustomStepRunner_Run_OngoingVerification) GetCapturedArguments() (command.ProjectContext, string, string, map[string]string) {
ctx, cmd, path, envs := c.GetAllCapturedArguments()
return ctx[len(ctx)-1], cmd[len(cmd)-1], path[len(path)-1], envs[len(envs)-1]
}
-func (c *MockCustomStepRunner_Run_OngoingVerification) GetAllCapturedArguments() (_param0 []models.ProjectCommandContext, _param1 []string, _param2 []string, _param3 []map[string]string) {
+func (c *MockCustomStepRunner_Run_OngoingVerification) GetAllCapturedArguments() (_param0 []command.ProjectContext, _param1 []string, _param2 []string, _param3 []map[string]string) {
params := pegomock.GetGenericMockFrom(c.mock).GetInvocationParams(c.methodInvocations)
if len(params) > 0 {
- _param0 = make([]models.ProjectCommandContext, len(c.methodInvocations))
+ _param0 = make([]command.ProjectContext, len(c.methodInvocations))
for u, param := range params[0] {
- _param0[u] = param.(models.ProjectCommandContext)
+ _param0[u] = param.(command.ProjectContext)
}
_param1 = make([]string, len(c.methodInvocations))
for u, param := range params[1] {
diff --git a/server/events/mocks/mock_delete_lock_command.go b/server/events/mocks/mock_delete_lock_command.go
index 42fb42b2f..405e03983 100644
--- a/server/events/mocks/mock_delete_lock_command.go
+++ b/server/events/mocks/mock_delete_lock_command.go
@@ -4,10 +4,11 @@
package mocks
import (
- pegomock "github.com/petergtz/pegomock"
- models "github.com/runatlantis/atlantis/server/events/models"
"reflect"
"time"
+
+ pegomock "github.com/petergtz/pegomock"
+ models "github.com/runatlantis/atlantis/server/events/models"
)
type MockDeleteLockCommand struct {
diff --git a/server/events/mocks/mock_env_step_runner.go b/server/events/mocks/mock_env_step_runner.go
index 23c17624a..02772ff94 100644
--- a/server/events/mocks/mock_env_step_runner.go
+++ b/server/events/mocks/mock_env_step_runner.go
@@ -4,10 +4,11 @@
package mocks
import (
- pegomock "github.com/petergtz/pegomock"
- models "github.com/runatlantis/atlantis/server/events/models"
"reflect"
"time"
+
+ pegomock "github.com/petergtz/pegomock"
+ "github.com/runatlantis/atlantis/server/events/command"
)
type MockEnvStepRunner struct {
@@ -25,7 +26,7 @@ func NewMockEnvStepRunner(options ...pegomock.Option) *MockEnvStepRunner {
func (mock *MockEnvStepRunner) SetFailHandler(fh pegomock.FailHandler) { mock.fail = fh }
func (mock *MockEnvStepRunner) FailHandler() pegomock.FailHandler { return mock.fail }
-func (mock *MockEnvStepRunner) Run(ctx models.ProjectCommandContext, cmd string, value string, path string, envs map[string]string) (string, error) {
+func (mock *MockEnvStepRunner) Run(ctx command.ProjectContext, cmd string, value string, path string, envs map[string]string) (string, error) {
if mock == nil {
panic("mock must not be nil. Use myMock := NewMockEnvStepRunner().")
}
@@ -81,7 +82,7 @@ type VerifierMockEnvStepRunner struct {
timeout time.Duration
}
-func (verifier *VerifierMockEnvStepRunner) Run(ctx models.ProjectCommandContext, cmd string, value string, path string, envs map[string]string) *MockEnvStepRunner_Run_OngoingVerification {
+func (verifier *VerifierMockEnvStepRunner) Run(ctx command.ProjectContext, cmd string, value string, path string, envs map[string]string) *MockEnvStepRunner_Run_OngoingVerification {
params := []pegomock.Param{ctx, cmd, value, path, envs}
methodInvocations := pegomock.GetGenericMockFrom(verifier.mock).Verify(verifier.inOrderContext, verifier.invocationCountMatcher, "Run", params, verifier.timeout)
return &MockEnvStepRunner_Run_OngoingVerification{mock: verifier.mock, methodInvocations: methodInvocations}
@@ -92,17 +93,17 @@ type MockEnvStepRunner_Run_OngoingVerification struct {
methodInvocations []pegomock.MethodInvocation
}
-func (c *MockEnvStepRunner_Run_OngoingVerification) GetCapturedArguments() (models.ProjectCommandContext, string, string, string, map[string]string) {
+func (c *MockEnvStepRunner_Run_OngoingVerification) GetCapturedArguments() (command.ProjectContext, string, string, string, map[string]string) {
ctx, cmd, value, path, envs := c.GetAllCapturedArguments()
return ctx[len(ctx)-1], cmd[len(cmd)-1], value[len(value)-1], path[len(path)-1], envs[len(envs)-1]
}
-func (c *MockEnvStepRunner_Run_OngoingVerification) GetAllCapturedArguments() (_param0 []models.ProjectCommandContext, _param1 []string, _param2 []string, _param3 []string, _param4 []map[string]string) {
+func (c *MockEnvStepRunner_Run_OngoingVerification) GetAllCapturedArguments() (_param0 []command.ProjectContext, _param1 []string, _param2 []string, _param3 []string, _param4 []map[string]string) {
params := pegomock.GetGenericMockFrom(c.mock).GetInvocationParams(c.methodInvocations)
if len(params) > 0 {
- _param0 = make([]models.ProjectCommandContext, len(c.methodInvocations))
+ _param0 = make([]command.ProjectContext, len(c.methodInvocations))
for u, param := range params[0] {
- _param0[u] = param.(models.ProjectCommandContext)
+ _param0[u] = param.(command.ProjectContext)
}
_param1 = make([]string, len(c.methodInvocations))
for u, param := range params[1] {
diff --git a/server/events/mocks/mock_event_parsing.go b/server/events/mocks/mock_event_parsing.go
index 8aabb4291..0a0b4aad1 100644
--- a/server/events/mocks/mock_event_parsing.go
+++ b/server/events/mocks/mock_event_parsing.go
@@ -4,13 +4,14 @@
package mocks
import (
+ "reflect"
+ "time"
+
github "github.com/google/go-github/v31/github"
azuredevops "github.com/mcdafydd/go-azuredevops/azuredevops"
pegomock "github.com/petergtz/pegomock"
models "github.com/runatlantis/atlantis/server/events/models"
go_gitlab "github.com/xanzy/go-gitlab"
- "reflect"
- "time"
)
type MockEventParsing struct {
diff --git a/server/events/mocks/mock_github_pull_getter.go b/server/events/mocks/mock_github_pull_getter.go
index 6eac00167..357e727b9 100644
--- a/server/events/mocks/mock_github_pull_getter.go
+++ b/server/events/mocks/mock_github_pull_getter.go
@@ -4,11 +4,12 @@
package mocks
import (
+ "reflect"
+ "time"
+
github "github.com/google/go-github/v31/github"
pegomock "github.com/petergtz/pegomock"
models "github.com/runatlantis/atlantis/server/events/models"
- "reflect"
- "time"
)
type MockGithubPullGetter struct {
diff --git a/server/events/mocks/mock_gitlab_merge_request_getter.go b/server/events/mocks/mock_gitlab_merge_request_getter.go
index 96d509eb3..188559730 100644
--- a/server/events/mocks/mock_gitlab_merge_request_getter.go
+++ b/server/events/mocks/mock_gitlab_merge_request_getter.go
@@ -4,10 +4,11 @@
package mocks
import (
- pegomock "github.com/petergtz/pegomock"
- go_gitlab "github.com/xanzy/go-gitlab"
"reflect"
"time"
+
+ pegomock "github.com/petergtz/pegomock"
+ go_gitlab "github.com/xanzy/go-gitlab"
)
type MockGitlabMergeRequestGetter struct {
diff --git a/server/events/mocks/mock_job_id_generator.go b/server/events/mocks/mock_job_id_generator.go
index 001d437f7..6d17130ee 100644
--- a/server/events/mocks/mock_job_id_generator.go
+++ b/server/events/mocks/mock_job_id_generator.go
@@ -4,9 +4,10 @@
package mocks
import (
- pegomock "github.com/petergtz/pegomock"
"reflect"
"time"
+
+ pegomock "github.com/petergtz/pegomock"
)
type MockJobIDGenerator struct {
diff --git a/server/events/mocks/mock_job_message_sender.go b/server/events/mocks/mock_job_message_sender.go
index e4d0c8fef..c8620913c 100644
--- a/server/events/mocks/mock_job_message_sender.go
+++ b/server/events/mocks/mock_job_message_sender.go
@@ -4,10 +4,11 @@
package mocks
import (
- pegomock "github.com/petergtz/pegomock"
- models "github.com/runatlantis/atlantis/server/events/models"
"reflect"
"time"
+
+ pegomock "github.com/petergtz/pegomock"
+ "github.com/runatlantis/atlantis/server/events/command"
)
type MockJobMessageSender struct {
@@ -25,7 +26,7 @@ func NewMockJobMessageSender(options ...pegomock.Option) *MockJobMessageSender {
func (mock *MockJobMessageSender) SetFailHandler(fh pegomock.FailHandler) { mock.fail = fh }
func (mock *MockJobMessageSender) FailHandler() pegomock.FailHandler { return mock.fail }
-func (mock *MockJobMessageSender) Send(_param0 models.ProjectCommandContext, _param1 string, _param2 bool) {
+func (mock *MockJobMessageSender) Send(_param0 command.ProjectContext, _param1 string, _param2 bool) {
if mock == nil {
panic("mock must not be nil. Use myMock := NewMockJobMessageSender().")
}
@@ -70,7 +71,7 @@ type VerifierMockJobMessageSender struct {
timeout time.Duration
}
-func (verifier *VerifierMockJobMessageSender) Send(_param0 models.ProjectCommandContext, _param1 string, _param2 bool) *MockJobMessageSender_Send_OngoingVerification {
+func (verifier *VerifierMockJobMessageSender) Send(_param0 command.ProjectContext, _param1 string, _param2 bool) *MockJobMessageSender_Send_OngoingVerification {
params := []pegomock.Param{_param0, _param1, _param2}
methodInvocations := pegomock.GetGenericMockFrom(verifier.mock).Verify(verifier.inOrderContext, verifier.invocationCountMatcher, "Send", params, verifier.timeout)
return &MockJobMessageSender_Send_OngoingVerification{mock: verifier.mock, methodInvocations: methodInvocations}
@@ -81,17 +82,17 @@ type MockJobMessageSender_Send_OngoingVerification struct {
methodInvocations []pegomock.MethodInvocation
}
-func (c *MockJobMessageSender_Send_OngoingVerification) GetCapturedArguments() (models.ProjectCommandContext, string, bool) {
+func (c *MockJobMessageSender_Send_OngoingVerification) GetCapturedArguments() (command.ProjectContext, string, bool) {
_param0, _param1, _param2 := c.GetAllCapturedArguments()
return _param0[len(_param0)-1], _param1[len(_param1)-1], _param2[len(_param2)-1]
}
-func (c *MockJobMessageSender_Send_OngoingVerification) GetAllCapturedArguments() (_param0 []models.ProjectCommandContext, _param1 []string, _param2 []bool) {
+func (c *MockJobMessageSender_Send_OngoingVerification) GetAllCapturedArguments() (_param0 []command.ProjectContext, _param1 []string, _param2 []bool) {
params := pegomock.GetGenericMockFrom(c.mock).GetInvocationParams(c.methodInvocations)
if len(params) > 0 {
- _param0 = make([]models.ProjectCommandContext, len(c.methodInvocations))
+ _param0 = make([]command.ProjectContext, len(c.methodInvocations))
for u, param := range params[0] {
- _param0[u] = param.(models.ProjectCommandContext)
+ _param0[u] = param.(command.ProjectContext)
}
_param1 = make([]string, len(c.methodInvocations))
for u, param := range params[1] {
diff --git a/server/events/mocks/mock_job_url_setter.go b/server/events/mocks/mock_job_url_setter.go
index b1df846f1..eff992d57 100644
--- a/server/events/mocks/mock_job_url_setter.go
+++ b/server/events/mocks/mock_job_url_setter.go
@@ -4,10 +4,12 @@
package mocks
import (
- pegomock "github.com/petergtz/pegomock"
- models "github.com/runatlantis/atlantis/server/events/models"
"reflect"
"time"
+
+ pegomock "github.com/petergtz/pegomock"
+ "github.com/runatlantis/atlantis/server/events/command"
+ models "github.com/runatlantis/atlantis/server/events/models"
)
type MockJobURLSetter struct {
@@ -25,7 +27,7 @@ func NewMockJobURLSetter(options ...pegomock.Option) *MockJobURLSetter {
func (mock *MockJobURLSetter) SetFailHandler(fh pegomock.FailHandler) { mock.fail = fh }
func (mock *MockJobURLSetter) FailHandler() pegomock.FailHandler { return mock.fail }
-func (mock *MockJobURLSetter) SetJobURLWithStatus(_param0 models.ProjectCommandContext, _param1 models.CommandName, _param2 models.CommitStatus) error {
+func (mock *MockJobURLSetter) SetJobURLWithStatus(_param0 command.ProjectContext, _param1 command.Name, _param2 models.CommitStatus) error {
if mock == nil {
panic("mock must not be nil. Use myMock := NewMockJobURLSetter().")
}
@@ -77,7 +79,7 @@ type VerifierMockJobURLSetter struct {
timeout time.Duration
}
-func (verifier *VerifierMockJobURLSetter) SetJobURLWithStatus(_param0 models.ProjectCommandContext, _param1 models.CommandName, _param2 models.CommitStatus) *MockJobURLSetter_SetJobURLWithStatus_OngoingVerification {
+func (verifier *VerifierMockJobURLSetter) SetJobURLWithStatus(_param0 command.ProjectContext, _param1 command.Name, _param2 models.CommitStatus) *MockJobURLSetter_SetJobURLWithStatus_OngoingVerification {
params := []pegomock.Param{_param0, _param1, _param2}
methodInvocations := pegomock.GetGenericMockFrom(verifier.mock).Verify(verifier.inOrderContext, verifier.invocationCountMatcher, "SetJobURLWithStatus", params, verifier.timeout)
return &MockJobURLSetter_SetJobURLWithStatus_OngoingVerification{mock: verifier.mock, methodInvocations: methodInvocations}
@@ -88,21 +90,21 @@ type MockJobURLSetter_SetJobURLWithStatus_OngoingVerification struct {
methodInvocations []pegomock.MethodInvocation
}
-func (c *MockJobURLSetter_SetJobURLWithStatus_OngoingVerification) GetCapturedArguments() (models.ProjectCommandContext, models.CommandName, models.CommitStatus) {
+func (c *MockJobURLSetter_SetJobURLWithStatus_OngoingVerification) GetCapturedArguments() (command.ProjectContext, command.Name, models.CommitStatus) {
_param0, _param1, _param2 := c.GetAllCapturedArguments()
return _param0[len(_param0)-1], _param1[len(_param1)-1], _param2[len(_param2)-1]
}
-func (c *MockJobURLSetter_SetJobURLWithStatus_OngoingVerification) GetAllCapturedArguments() (_param0 []models.ProjectCommandContext, _param1 []models.CommandName, _param2 []models.CommitStatus) {
+func (c *MockJobURLSetter_SetJobURLWithStatus_OngoingVerification) GetAllCapturedArguments() (_param0 []command.ProjectContext, _param1 []command.Name, _param2 []models.CommitStatus) {
params := pegomock.GetGenericMockFrom(c.mock).GetInvocationParams(c.methodInvocations)
if len(params) > 0 {
- _param0 = make([]models.ProjectCommandContext, len(c.methodInvocations))
+ _param0 = make([]command.ProjectContext, len(c.methodInvocations))
for u, param := range params[0] {
- _param0[u] = param.(models.ProjectCommandContext)
+ _param0[u] = param.(command.ProjectContext)
}
- _param1 = make([]models.CommandName, len(c.methodInvocations))
+ _param1 = make([]command.Name, len(c.methodInvocations))
for u, param := range params[1] {
- _param1[u] = param.(models.CommandName)
+ _param1[u] = param.(command.Name)
}
_param2 = make([]models.CommitStatus, len(c.methodInvocations))
for u, param := range params[2] {
diff --git a/server/events/mocks/mock_lock_url_generator.go b/server/events/mocks/mock_lock_url_generator.go
index a126da24f..5598ba2d7 100644
--- a/server/events/mocks/mock_lock_url_generator.go
+++ b/server/events/mocks/mock_lock_url_generator.go
@@ -4,9 +4,10 @@
package mocks
import (
- pegomock "github.com/petergtz/pegomock"
"reflect"
"time"
+
+ pegomock "github.com/petergtz/pegomock"
)
type MockLockURLGenerator struct {
diff --git a/server/events/mocks/mock_log_stream_url_generator.go b/server/events/mocks/mock_log_stream_url_generator.go
index 2742aa801..ee95820b9 100644
--- a/server/events/mocks/mock_log_stream_url_generator.go
+++ b/server/events/mocks/mock_log_stream_url_generator.go
@@ -4,10 +4,12 @@
package mocks
import (
- pegomock "github.com/petergtz/pegomock"
- models "github.com/runatlantis/atlantis/server/events/models"
"reflect"
"time"
+
+ pegomock "github.com/petergtz/pegomock"
+ "github.com/runatlantis/atlantis/server/events/command"
+ models "github.com/runatlantis/atlantis/server/events/models"
)
type MockJobsUrlGenerator struct {
@@ -25,7 +27,7 @@ func NewMockJobsUrlGenerator(options ...pegomock.Option) *MockJobsUrlGenerator {
func (mock *MockJobsUrlGenerator) SetFailHandler(fh pegomock.FailHandler) { mock.fail = fh }
func (mock *MockJobsUrlGenerator) FailHandler() pegomock.FailHandler { return mock.fail }
-func (mock *MockJobsUrlGenerator) GenerateProjectJobsUrl(pull models.PullRequest, p models.ProjectCommandContext) string {
+func (mock *MockJobsUrlGenerator) GenerateProjectJobsUrl(pull models.PullRequest, p command.ProjectContext) string {
if mock == nil {
panic("mock must not be nil. Use myMock := NewMockJobsUrlGenerator().")
}
@@ -77,7 +79,7 @@ type VerifierMockJobsUrlGenerator struct {
timeout time.Duration
}
-func (verifier *VerifierMockJobsUrlGenerator) GenerateProjectJobsUrl(pull models.PullRequest, p models.ProjectCommandContext) *MockJobsUrlGenerator_GenerateProjectJobsUrl_OngoingVerification {
+func (verifier *VerifierMockJobsUrlGenerator) GenerateProjectJobsUrl(pull models.PullRequest, p command.ProjectContext) *MockJobsUrlGenerator_GenerateProjectJobsUrl_OngoingVerification {
params := []pegomock.Param{pull, p}
methodInvocations := pegomock.GetGenericMockFrom(verifier.mock).Verify(verifier.inOrderContext, verifier.invocationCountMatcher, "GenerateProjectJobsUrl", params, verifier.timeout)
return &MockJobsUrlGenerator_GenerateProjectJobsUrl_OngoingVerification{mock: verifier.mock, methodInvocations: methodInvocations}
@@ -88,21 +90,21 @@ type MockJobsUrlGenerator_GenerateProjectJobsUrl_OngoingVerification struct {
methodInvocations []pegomock.MethodInvocation
}
-func (c *MockJobsUrlGenerator_GenerateProjectJobsUrl_OngoingVerification) GetCapturedArguments() (models.PullRequest, models.ProjectCommandContext) {
+func (c *MockJobsUrlGenerator_GenerateProjectJobsUrl_OngoingVerification) GetCapturedArguments() (models.PullRequest, command.ProjectContext) {
pull, p := c.GetAllCapturedArguments()
return pull[len(pull)-1], p[len(p)-1]
}
-func (c *MockJobsUrlGenerator_GenerateProjectJobsUrl_OngoingVerification) GetAllCapturedArguments() (_param0 []models.PullRequest, _param1 []models.ProjectCommandContext) {
+func (c *MockJobsUrlGenerator_GenerateProjectJobsUrl_OngoingVerification) GetAllCapturedArguments() (_param0 []models.PullRequest, _param1 []command.ProjectContext) {
params := pegomock.GetGenericMockFrom(c.mock).GetInvocationParams(c.methodInvocations)
if len(params) > 0 {
_param0 = make([]models.PullRequest, len(c.methodInvocations))
for u, param := range params[0] {
_param0[u] = param.(models.PullRequest)
}
- _param1 = make([]models.ProjectCommandContext, len(c.methodInvocations))
+ _param1 = make([]command.ProjectContext, len(c.methodInvocations))
for u, param := range params[1] {
- _param1[u] = param.(models.ProjectCommandContext)
+ _param1[u] = param.(command.ProjectContext)
}
}
return
diff --git a/server/events/mocks/mock_pending_plan_finder.go b/server/events/mocks/mock_pending_plan_finder.go
index 7a2974dc5..31be58463 100644
--- a/server/events/mocks/mock_pending_plan_finder.go
+++ b/server/events/mocks/mock_pending_plan_finder.go
@@ -4,10 +4,11 @@
package mocks
import (
- pegomock "github.com/petergtz/pegomock"
- events "github.com/runatlantis/atlantis/server/events"
"reflect"
"time"
+
+ pegomock "github.com/petergtz/pegomock"
+ events "github.com/runatlantis/atlantis/server/events"
)
type MockPendingPlanFinder struct {
diff --git a/server/events/mocks/mock_post_workflows_hooks_command_runner.go b/server/events/mocks/mock_post_workflows_hooks_command_runner.go
index fd42ae3ce..9ff923e41 100644
--- a/server/events/mocks/mock_post_workflows_hooks_command_runner.go
+++ b/server/events/mocks/mock_post_workflows_hooks_command_runner.go
@@ -4,10 +4,11 @@
package mocks
import (
- pegomock "github.com/petergtz/pegomock"
- events "github.com/runatlantis/atlantis/server/events"
"reflect"
"time"
+
+ pegomock "github.com/petergtz/pegomock"
+ "github.com/runatlantis/atlantis/server/events/command"
)
type MockPostWorkflowHooksCommandRunner struct {
@@ -27,7 +28,7 @@ func (mock *MockPostWorkflowHooksCommandRunner) SetFailHandler(fh pegomock.FailH
}
func (mock *MockPostWorkflowHooksCommandRunner) FailHandler() pegomock.FailHandler { return mock.fail }
-func (mock *MockPostWorkflowHooksCommandRunner) RunPostHooks(ctx *events.CommandContext) error {
+func (mock *MockPostWorkflowHooksCommandRunner) RunPostHooks(ctx *command.Context) error {
if mock == nil {
panic("mock must not be nil. Use myMock := NewMockPostWorkflowHooksCommandRunner().")
}
@@ -79,7 +80,7 @@ type VerifierMockPostWorkflowHooksCommandRunner struct {
timeout time.Duration
}
-func (verifier *VerifierMockPostWorkflowHooksCommandRunner) RunPostHooks(ctx *events.CommandContext) *MockPostWorkflowHooksCommandRunner_RunPostHooks_OngoingVerification {
+func (verifier *VerifierMockPostWorkflowHooksCommandRunner) RunPostHooks(ctx *command.Context) *MockPostWorkflowHooksCommandRunner_RunPostHooks_OngoingVerification {
params := []pegomock.Param{ctx}
methodInvocations := pegomock.GetGenericMockFrom(verifier.mock).Verify(verifier.inOrderContext, verifier.invocationCountMatcher, "RunPostHooks", params, verifier.timeout)
return &MockPostWorkflowHooksCommandRunner_RunPostHooks_OngoingVerification{mock: verifier.mock, methodInvocations: methodInvocations}
@@ -90,17 +91,17 @@ type MockPostWorkflowHooksCommandRunner_RunPostHooks_OngoingVerification struct
methodInvocations []pegomock.MethodInvocation
}
-func (c *MockPostWorkflowHooksCommandRunner_RunPostHooks_OngoingVerification) GetCapturedArguments() *events.CommandContext {
+func (c *MockPostWorkflowHooksCommandRunner_RunPostHooks_OngoingVerification) GetCapturedArguments() *command.Context {
ctx := c.GetAllCapturedArguments()
return ctx[len(ctx)-1]
}
-func (c *MockPostWorkflowHooksCommandRunner_RunPostHooks_OngoingVerification) GetAllCapturedArguments() (_param0 []*events.CommandContext) {
+func (c *MockPostWorkflowHooksCommandRunner_RunPostHooks_OngoingVerification) GetAllCapturedArguments() (_param0 []*command.Context) {
params := pegomock.GetGenericMockFrom(c.mock).GetInvocationParams(c.methodInvocations)
if len(params) > 0 {
- _param0 = make([]*events.CommandContext, len(c.methodInvocations))
+ _param0 = make([]*command.Context, len(c.methodInvocations))
for u, param := range params[0] {
- _param0[u] = param.(*events.CommandContext)
+ _param0[u] = param.(*command.Context)
}
}
return
diff --git a/server/events/mocks/mock_pre_workflows_hooks_command_runner.go b/server/events/mocks/mock_pre_workflows_hooks_command_runner.go
index ebbb9f876..9c3cb3316 100644
--- a/server/events/mocks/mock_pre_workflows_hooks_command_runner.go
+++ b/server/events/mocks/mock_pre_workflows_hooks_command_runner.go
@@ -4,10 +4,11 @@
package mocks
import (
- pegomock "github.com/petergtz/pegomock"
- events "github.com/runatlantis/atlantis/server/events"
"reflect"
"time"
+
+ pegomock "github.com/petergtz/pegomock"
+ command "github.com/runatlantis/atlantis/server/events/command"
)
type MockPreWorkflowHooksCommandRunner struct {
@@ -27,7 +28,7 @@ func (mock *MockPreWorkflowHooksCommandRunner) SetFailHandler(fh pegomock.FailHa
}
func (mock *MockPreWorkflowHooksCommandRunner) FailHandler() pegomock.FailHandler { return mock.fail }
-func (mock *MockPreWorkflowHooksCommandRunner) RunPreHooks(ctx *events.CommandContext) error {
+func (mock *MockPreWorkflowHooksCommandRunner) RunPreHooks(ctx *command.Context) error {
if mock == nil {
panic("mock must not be nil. Use myMock := NewMockPreWorkflowHooksCommandRunner().")
}
@@ -79,7 +80,7 @@ type VerifierMockPreWorkflowHooksCommandRunner struct {
timeout time.Duration
}
-func (verifier *VerifierMockPreWorkflowHooksCommandRunner) RunPreHooks(ctx *events.CommandContext) *MockPreWorkflowHooksCommandRunner_RunPreHooks_OngoingVerification {
+func (verifier *VerifierMockPreWorkflowHooksCommandRunner) RunPreHooks(ctx *command.Context) *MockPreWorkflowHooksCommandRunner_RunPreHooks_OngoingVerification {
params := []pegomock.Param{ctx}
methodInvocations := pegomock.GetGenericMockFrom(verifier.mock).Verify(verifier.inOrderContext, verifier.invocationCountMatcher, "RunPreHooks", params, verifier.timeout)
return &MockPreWorkflowHooksCommandRunner_RunPreHooks_OngoingVerification{mock: verifier.mock, methodInvocations: methodInvocations}
@@ -90,17 +91,17 @@ type MockPreWorkflowHooksCommandRunner_RunPreHooks_OngoingVerification struct {
methodInvocations []pegomock.MethodInvocation
}
-func (c *MockPreWorkflowHooksCommandRunner_RunPreHooks_OngoingVerification) GetCapturedArguments() *events.CommandContext {
+func (c *MockPreWorkflowHooksCommandRunner_RunPreHooks_OngoingVerification) GetCapturedArguments() *command.Context {
ctx := c.GetAllCapturedArguments()
return ctx[len(ctx)-1]
}
-func (c *MockPreWorkflowHooksCommandRunner_RunPreHooks_OngoingVerification) GetAllCapturedArguments() (_param0 []*events.CommandContext) {
+func (c *MockPreWorkflowHooksCommandRunner_RunPreHooks_OngoingVerification) GetAllCapturedArguments() (_param0 []*command.Context) {
params := pegomock.GetGenericMockFrom(c.mock).GetInvocationParams(c.methodInvocations)
if len(params) > 0 {
- _param0 = make([]*events.CommandContext, len(c.methodInvocations))
+ _param0 = make([]*command.Context, len(c.methodInvocations))
for u, param := range params[0] {
- _param0[u] = param.(*events.CommandContext)
+ _param0[u] = param.(*command.Context)
}
}
return
diff --git a/server/events/mocks/mock_project_command_builder.go b/server/events/mocks/mock_project_command_builder.go
index 60b3bec18..1b3482359 100644
--- a/server/events/mocks/mock_project_command_builder.go
+++ b/server/events/mocks/mock_project_command_builder.go
@@ -4,11 +4,12 @@
package mocks
import (
- pegomock "github.com/petergtz/pegomock"
- events "github.com/runatlantis/atlantis/server/events"
- models "github.com/runatlantis/atlantis/server/events/models"
"reflect"
"time"
+
+ pegomock "github.com/petergtz/pegomock"
+ events "github.com/runatlantis/atlantis/server/events"
+ "github.com/runatlantis/atlantis/server/events/command"
)
type MockProjectCommandBuilder struct {
@@ -26,17 +27,17 @@ func NewMockProjectCommandBuilder(options ...pegomock.Option) *MockProjectComman
func (mock *MockProjectCommandBuilder) SetFailHandler(fh pegomock.FailHandler) { mock.fail = fh }
func (mock *MockProjectCommandBuilder) FailHandler() pegomock.FailHandler { return mock.fail }
-func (mock *MockProjectCommandBuilder) BuildAutoplanCommands(ctx *events.CommandContext) ([]models.ProjectCommandContext, error) {
+func (mock *MockProjectCommandBuilder) BuildAutoplanCommands(ctx *command.Context) ([]command.ProjectContext, error) {
if mock == nil {
panic("mock must not be nil. Use myMock := NewMockProjectCommandBuilder().")
}
params := []pegomock.Param{ctx}
- result := pegomock.GetGenericMockFrom(mock).Invoke("BuildAutoplanCommands", params, []reflect.Type{reflect.TypeOf((*[]models.ProjectCommandContext)(nil)).Elem(), reflect.TypeOf((*error)(nil)).Elem()})
- var ret0 []models.ProjectCommandContext
+ result := pegomock.GetGenericMockFrom(mock).Invoke("BuildAutoplanCommands", params, []reflect.Type{reflect.TypeOf((*[]command.ProjectContext)(nil)).Elem(), reflect.TypeOf((*error)(nil)).Elem()})
+ var ret0 []command.ProjectContext
var ret1 error
if len(result) != 0 {
if result[0] != nil {
- ret0 = result[0].([]models.ProjectCommandContext)
+ ret0 = result[0].([]command.ProjectContext)
}
if result[1] != nil {
ret1 = result[1].(error)
@@ -45,17 +46,17 @@ func (mock *MockProjectCommandBuilder) BuildAutoplanCommands(ctx *events.Command
return ret0, ret1
}
-func (mock *MockProjectCommandBuilder) BuildPlanCommands(ctx *events.CommandContext, comment *events.CommentCommand) ([]models.ProjectCommandContext, error) {
+func (mock *MockProjectCommandBuilder) BuildPlanCommands(ctx *command.Context, comment *events.CommentCommand) ([]command.ProjectContext, error) {
if mock == nil {
panic("mock must not be nil. Use myMock := NewMockProjectCommandBuilder().")
}
params := []pegomock.Param{ctx, comment}
- result := pegomock.GetGenericMockFrom(mock).Invoke("BuildPlanCommands", params, []reflect.Type{reflect.TypeOf((*[]models.ProjectCommandContext)(nil)).Elem(), reflect.TypeOf((*error)(nil)).Elem()})
- var ret0 []models.ProjectCommandContext
+ result := pegomock.GetGenericMockFrom(mock).Invoke("BuildPlanCommands", params, []reflect.Type{reflect.TypeOf((*[]command.ProjectContext)(nil)).Elem(), reflect.TypeOf((*error)(nil)).Elem()})
+ var ret0 []command.ProjectContext
var ret1 error
if len(result) != 0 {
if result[0] != nil {
- ret0 = result[0].([]models.ProjectCommandContext)
+ ret0 = result[0].([]command.ProjectContext)
}
if result[1] != nil {
ret1 = result[1].(error)
@@ -64,17 +65,17 @@ func (mock *MockProjectCommandBuilder) BuildPlanCommands(ctx *events.CommandCont
return ret0, ret1
}
-func (mock *MockProjectCommandBuilder) BuildApplyCommands(ctx *events.CommandContext, comment *events.CommentCommand) ([]models.ProjectCommandContext, error) {
+func (mock *MockProjectCommandBuilder) BuildApplyCommands(ctx *command.Context, comment *events.CommentCommand) ([]command.ProjectContext, error) {
if mock == nil {
panic("mock must not be nil. Use myMock := NewMockProjectCommandBuilder().")
}
params := []pegomock.Param{ctx, comment}
- result := pegomock.GetGenericMockFrom(mock).Invoke("BuildApplyCommands", params, []reflect.Type{reflect.TypeOf((*[]models.ProjectCommandContext)(nil)).Elem(), reflect.TypeOf((*error)(nil)).Elem()})
- var ret0 []models.ProjectCommandContext
+ result := pegomock.GetGenericMockFrom(mock).Invoke("BuildApplyCommands", params, []reflect.Type{reflect.TypeOf((*[]command.ProjectContext)(nil)).Elem(), reflect.TypeOf((*error)(nil)).Elem()})
+ var ret0 []command.ProjectContext
var ret1 error
if len(result) != 0 {
if result[0] != nil {
- ret0 = result[0].([]models.ProjectCommandContext)
+ ret0 = result[0].([]command.ProjectContext)
}
if result[1] != nil {
ret1 = result[1].(error)
@@ -83,17 +84,17 @@ func (mock *MockProjectCommandBuilder) BuildApplyCommands(ctx *events.CommandCon
return ret0, ret1
}
-func (mock *MockProjectCommandBuilder) BuildApprovePoliciesCommands(ctx *events.CommandContext, comment *events.CommentCommand) ([]models.ProjectCommandContext, error) {
+func (mock *MockProjectCommandBuilder) BuildApprovePoliciesCommands(ctx *command.Context, comment *events.CommentCommand) ([]command.ProjectContext, error) {
if mock == nil {
panic("mock must not be nil. Use myMock := NewMockProjectCommandBuilder().")
}
params := []pegomock.Param{ctx, comment}
- result := pegomock.GetGenericMockFrom(mock).Invoke("BuildApprovePoliciesCommands", params, []reflect.Type{reflect.TypeOf((*[]models.ProjectCommandContext)(nil)).Elem(), reflect.TypeOf((*error)(nil)).Elem()})
- var ret0 []models.ProjectCommandContext
+ result := pegomock.GetGenericMockFrom(mock).Invoke("BuildApprovePoliciesCommands", params, []reflect.Type{reflect.TypeOf((*[]command.ProjectContext)(nil)).Elem(), reflect.TypeOf((*error)(nil)).Elem()})
+ var ret0 []command.ProjectContext
var ret1 error
if len(result) != 0 {
if result[0] != nil {
- ret0 = result[0].([]models.ProjectCommandContext)
+ ret0 = result[0].([]command.ProjectContext)
}
if result[1] != nil {
ret1 = result[1].(error)
@@ -102,17 +103,17 @@ func (mock *MockProjectCommandBuilder) BuildApprovePoliciesCommands(ctx *events.
return ret0, ret1
}
-func (mock *MockProjectCommandBuilder) BuildVersionCommands(ctx *events.CommandContext, comment *events.CommentCommand) ([]models.ProjectCommandContext, error) {
+func (mock *MockProjectCommandBuilder) BuildVersionCommands(ctx *command.Context, comment *events.CommentCommand) ([]command.ProjectContext, error) {
if mock == nil {
panic("mock must not be nil. Use myMock := NewMockProjectCommandBuilder().")
}
params := []pegomock.Param{ctx, comment}
- result := pegomock.GetGenericMockFrom(mock).Invoke("BuildVersionCommands", params, []reflect.Type{reflect.TypeOf((*[]models.ProjectCommandContext)(nil)).Elem(), reflect.TypeOf((*error)(nil)).Elem()})
- var ret0 []models.ProjectCommandContext
+ result := pegomock.GetGenericMockFrom(mock).Invoke("BuildVersionCommands", params, []reflect.Type{reflect.TypeOf((*[]command.ProjectContext)(nil)).Elem(), reflect.TypeOf((*error)(nil)).Elem()})
+ var ret0 []command.ProjectContext
var ret1 error
if len(result) != 0 {
if result[0] != nil {
- ret0 = result[0].([]models.ProjectCommandContext)
+ ret0 = result[0].([]command.ProjectContext)
}
if result[1] != nil {
ret1 = result[1].(error)
@@ -158,7 +159,7 @@ type VerifierMockProjectCommandBuilder struct {
timeout time.Duration
}
-func (verifier *VerifierMockProjectCommandBuilder) BuildAutoplanCommands(ctx *events.CommandContext) *MockProjectCommandBuilder_BuildAutoplanCommands_OngoingVerification {
+func (verifier *VerifierMockProjectCommandBuilder) BuildAutoplanCommands(ctx *command.Context) *MockProjectCommandBuilder_BuildAutoplanCommands_OngoingVerification {
params := []pegomock.Param{ctx}
methodInvocations := pegomock.GetGenericMockFrom(verifier.mock).Verify(verifier.inOrderContext, verifier.invocationCountMatcher, "BuildAutoplanCommands", params, verifier.timeout)
return &MockProjectCommandBuilder_BuildAutoplanCommands_OngoingVerification{mock: verifier.mock, methodInvocations: methodInvocations}
@@ -169,23 +170,23 @@ type MockProjectCommandBuilder_BuildAutoplanCommands_OngoingVerification struct
methodInvocations []pegomock.MethodInvocation
}
-func (c *MockProjectCommandBuilder_BuildAutoplanCommands_OngoingVerification) GetCapturedArguments() *events.CommandContext {
+func (c *MockProjectCommandBuilder_BuildAutoplanCommands_OngoingVerification) GetCapturedArguments() *command.Context {
ctx := c.GetAllCapturedArguments()
return ctx[len(ctx)-1]
}
-func (c *MockProjectCommandBuilder_BuildAutoplanCommands_OngoingVerification) GetAllCapturedArguments() (_param0 []*events.CommandContext) {
+func (c *MockProjectCommandBuilder_BuildAutoplanCommands_OngoingVerification) GetAllCapturedArguments() (_param0 []*command.Context) {
params := pegomock.GetGenericMockFrom(c.mock).GetInvocationParams(c.methodInvocations)
if len(params) > 0 {
- _param0 = make([]*events.CommandContext, len(c.methodInvocations))
+ _param0 = make([]*command.Context, len(c.methodInvocations))
for u, param := range params[0] {
- _param0[u] = param.(*events.CommandContext)
+ _param0[u] = param.(*command.Context)
}
}
return
}
-func (verifier *VerifierMockProjectCommandBuilder) BuildPlanCommands(ctx *events.CommandContext, comment *events.CommentCommand) *MockProjectCommandBuilder_BuildPlanCommands_OngoingVerification {
+func (verifier *VerifierMockProjectCommandBuilder) BuildPlanCommands(ctx *command.Context, comment *events.CommentCommand) *MockProjectCommandBuilder_BuildPlanCommands_OngoingVerification {
params := []pegomock.Param{ctx, comment}
methodInvocations := pegomock.GetGenericMockFrom(verifier.mock).Verify(verifier.inOrderContext, verifier.invocationCountMatcher, "BuildPlanCommands", params, verifier.timeout)
return &MockProjectCommandBuilder_BuildPlanCommands_OngoingVerification{mock: verifier.mock, methodInvocations: methodInvocations}
@@ -196,17 +197,17 @@ type MockProjectCommandBuilder_BuildPlanCommands_OngoingVerification struct {
methodInvocations []pegomock.MethodInvocation
}
-func (c *MockProjectCommandBuilder_BuildPlanCommands_OngoingVerification) GetCapturedArguments() (*events.CommandContext, *events.CommentCommand) {
+func (c *MockProjectCommandBuilder_BuildPlanCommands_OngoingVerification) GetCapturedArguments() (*command.Context, *events.CommentCommand) {
ctx, comment := c.GetAllCapturedArguments()
return ctx[len(ctx)-1], comment[len(comment)-1]
}
-func (c *MockProjectCommandBuilder_BuildPlanCommands_OngoingVerification) GetAllCapturedArguments() (_param0 []*events.CommandContext, _param1 []*events.CommentCommand) {
+func (c *MockProjectCommandBuilder_BuildPlanCommands_OngoingVerification) GetAllCapturedArguments() (_param0 []*command.Context, _param1 []*events.CommentCommand) {
params := pegomock.GetGenericMockFrom(c.mock).GetInvocationParams(c.methodInvocations)
if len(params) > 0 {
- _param0 = make([]*events.CommandContext, len(c.methodInvocations))
+ _param0 = make([]*command.Context, len(c.methodInvocations))
for u, param := range params[0] {
- _param0[u] = param.(*events.CommandContext)
+ _param0[u] = param.(*command.Context)
}
_param1 = make([]*events.CommentCommand, len(c.methodInvocations))
for u, param := range params[1] {
@@ -216,7 +217,7 @@ func (c *MockProjectCommandBuilder_BuildPlanCommands_OngoingVerification) GetAll
return
}
-func (verifier *VerifierMockProjectCommandBuilder) BuildApplyCommands(ctx *events.CommandContext, comment *events.CommentCommand) *MockProjectCommandBuilder_BuildApplyCommands_OngoingVerification {
+func (verifier *VerifierMockProjectCommandBuilder) BuildApplyCommands(ctx *command.Context, comment *events.CommentCommand) *MockProjectCommandBuilder_BuildApplyCommands_OngoingVerification {
params := []pegomock.Param{ctx, comment}
methodInvocations := pegomock.GetGenericMockFrom(verifier.mock).Verify(verifier.inOrderContext, verifier.invocationCountMatcher, "BuildApplyCommands", params, verifier.timeout)
return &MockProjectCommandBuilder_BuildApplyCommands_OngoingVerification{mock: verifier.mock, methodInvocations: methodInvocations}
@@ -227,17 +228,17 @@ type MockProjectCommandBuilder_BuildApplyCommands_OngoingVerification struct {
methodInvocations []pegomock.MethodInvocation
}
-func (c *MockProjectCommandBuilder_BuildApplyCommands_OngoingVerification) GetCapturedArguments() (*events.CommandContext, *events.CommentCommand) {
+func (c *MockProjectCommandBuilder_BuildApplyCommands_OngoingVerification) GetCapturedArguments() (*command.Context, *events.CommentCommand) {
ctx, comment := c.GetAllCapturedArguments()
return ctx[len(ctx)-1], comment[len(comment)-1]
}
-func (c *MockProjectCommandBuilder_BuildApplyCommands_OngoingVerification) GetAllCapturedArguments() (_param0 []*events.CommandContext, _param1 []*events.CommentCommand) {
+func (c *MockProjectCommandBuilder_BuildApplyCommands_OngoingVerification) GetAllCapturedArguments() (_param0 []*command.Context, _param1 []*events.CommentCommand) {
params := pegomock.GetGenericMockFrom(c.mock).GetInvocationParams(c.methodInvocations)
if len(params) > 0 {
- _param0 = make([]*events.CommandContext, len(c.methodInvocations))
+ _param0 = make([]*command.Context, len(c.methodInvocations))
for u, param := range params[0] {
- _param0[u] = param.(*events.CommandContext)
+ _param0[u] = param.(*command.Context)
}
_param1 = make([]*events.CommentCommand, len(c.methodInvocations))
for u, param := range params[1] {
@@ -247,7 +248,7 @@ func (c *MockProjectCommandBuilder_BuildApplyCommands_OngoingVerification) GetAl
return
}
-func (verifier *VerifierMockProjectCommandBuilder) BuildApprovePoliciesCommands(ctx *events.CommandContext, comment *events.CommentCommand) *MockProjectCommandBuilder_BuildApprovePoliciesCommands_OngoingVerification {
+func (verifier *VerifierMockProjectCommandBuilder) BuildApprovePoliciesCommands(ctx *command.Context, comment *events.CommentCommand) *MockProjectCommandBuilder_BuildApprovePoliciesCommands_OngoingVerification {
params := []pegomock.Param{ctx, comment}
methodInvocations := pegomock.GetGenericMockFrom(verifier.mock).Verify(verifier.inOrderContext, verifier.invocationCountMatcher, "BuildApprovePoliciesCommands", params, verifier.timeout)
return &MockProjectCommandBuilder_BuildApprovePoliciesCommands_OngoingVerification{mock: verifier.mock, methodInvocations: methodInvocations}
@@ -258,17 +259,17 @@ type MockProjectCommandBuilder_BuildApprovePoliciesCommands_OngoingVerification
methodInvocations []pegomock.MethodInvocation
}
-func (c *MockProjectCommandBuilder_BuildApprovePoliciesCommands_OngoingVerification) GetCapturedArguments() (*events.CommandContext, *events.CommentCommand) {
+func (c *MockProjectCommandBuilder_BuildApprovePoliciesCommands_OngoingVerification) GetCapturedArguments() (*command.Context, *events.CommentCommand) {
ctx, comment := c.GetAllCapturedArguments()
return ctx[len(ctx)-1], comment[len(comment)-1]
}
-func (c *MockProjectCommandBuilder_BuildApprovePoliciesCommands_OngoingVerification) GetAllCapturedArguments() (_param0 []*events.CommandContext, _param1 []*events.CommentCommand) {
+func (c *MockProjectCommandBuilder_BuildApprovePoliciesCommands_OngoingVerification) GetAllCapturedArguments() (_param0 []*command.Context, _param1 []*events.CommentCommand) {
params := pegomock.GetGenericMockFrom(c.mock).GetInvocationParams(c.methodInvocations)
if len(params) > 0 {
- _param0 = make([]*events.CommandContext, len(c.methodInvocations))
+ _param0 = make([]*command.Context, len(c.methodInvocations))
for u, param := range params[0] {
- _param0[u] = param.(*events.CommandContext)
+ _param0[u] = param.(*command.Context)
}
_param1 = make([]*events.CommentCommand, len(c.methodInvocations))
for u, param := range params[1] {
@@ -278,7 +279,7 @@ func (c *MockProjectCommandBuilder_BuildApprovePoliciesCommands_OngoingVerificat
return
}
-func (verifier *VerifierMockProjectCommandBuilder) BuildVersionCommands(ctx *events.CommandContext, comment *events.CommentCommand) *MockProjectCommandBuilder_BuildVersionCommands_OngoingVerification {
+func (verifier *VerifierMockProjectCommandBuilder) BuildVersionCommands(ctx *command.Context, comment *events.CommentCommand) *MockProjectCommandBuilder_BuildVersionCommands_OngoingVerification {
params := []pegomock.Param{ctx, comment}
methodInvocations := pegomock.GetGenericMockFrom(verifier.mock).Verify(verifier.inOrderContext, verifier.invocationCountMatcher, "BuildVersionCommands", params, verifier.timeout)
return &MockProjectCommandBuilder_BuildVersionCommands_OngoingVerification{mock: verifier.mock, methodInvocations: methodInvocations}
@@ -289,17 +290,17 @@ type MockProjectCommandBuilder_BuildVersionCommands_OngoingVerification struct {
methodInvocations []pegomock.MethodInvocation
}
-func (c *MockProjectCommandBuilder_BuildVersionCommands_OngoingVerification) GetCapturedArguments() (*events.CommandContext, *events.CommentCommand) {
+func (c *MockProjectCommandBuilder_BuildVersionCommands_OngoingVerification) GetCapturedArguments() (*command.Context, *events.CommentCommand) {
ctx, comment := c.GetAllCapturedArguments()
return ctx[len(ctx)-1], comment[len(comment)-1]
}
-func (c *MockProjectCommandBuilder_BuildVersionCommands_OngoingVerification) GetAllCapturedArguments() (_param0 []*events.CommandContext, _param1 []*events.CommentCommand) {
+func (c *MockProjectCommandBuilder_BuildVersionCommands_OngoingVerification) GetAllCapturedArguments() (_param0 []*command.Context, _param1 []*events.CommentCommand) {
params := pegomock.GetGenericMockFrom(c.mock).GetInvocationParams(c.methodInvocations)
if len(params) > 0 {
- _param0 = make([]*events.CommandContext, len(c.methodInvocations))
+ _param0 = make([]*command.Context, len(c.methodInvocations))
for u, param := range params[0] {
- _param0[u] = param.(*events.CommandContext)
+ _param0[u] = param.(*command.Context)
}
_param1 = make([]*events.CommentCommand, len(c.methodInvocations))
for u, param := range params[1] {
diff --git a/server/events/mocks/mock_project_command_runner.go b/server/events/mocks/mock_project_command_runner.go
index 052226a37..9f27f89a3 100644
--- a/server/events/mocks/mock_project_command_runner.go
+++ b/server/events/mocks/mock_project_command_runner.go
@@ -4,10 +4,11 @@
package mocks
import (
- pegomock "github.com/petergtz/pegomock"
- models "github.com/runatlantis/atlantis/server/events/models"
"reflect"
"time"
+
+ pegomock "github.com/petergtz/pegomock"
+ "github.com/runatlantis/atlantis/server/events/command"
)
type MockProjectCommandRunner struct {
@@ -25,76 +26,76 @@ func NewMockProjectCommandRunner(options ...pegomock.Option) *MockProjectCommand
func (mock *MockProjectCommandRunner) SetFailHandler(fh pegomock.FailHandler) { mock.fail = fh }
func (mock *MockProjectCommandRunner) FailHandler() pegomock.FailHandler { return mock.fail }
-func (mock *MockProjectCommandRunner) Plan(ctx models.ProjectCommandContext) models.ProjectResult {
+func (mock *MockProjectCommandRunner) Plan(ctx command.ProjectContext) command.ProjectResult {
if mock == nil {
panic("mock must not be nil. Use myMock := NewMockProjectCommandRunner().")
}
params := []pegomock.Param{ctx}
- result := pegomock.GetGenericMockFrom(mock).Invoke("Plan", params, []reflect.Type{reflect.TypeOf((*models.ProjectResult)(nil)).Elem()})
- var ret0 models.ProjectResult
+ result := pegomock.GetGenericMockFrom(mock).Invoke("Plan", params, []reflect.Type{reflect.TypeOf((*command.ProjectResult)(nil)).Elem()})
+ var ret0 command.ProjectResult
if len(result) != 0 {
if result[0] != nil {
- ret0 = result[0].(models.ProjectResult)
+ ret0 = result[0].(command.ProjectResult)
}
}
return ret0
}
-func (mock *MockProjectCommandRunner) Apply(ctx models.ProjectCommandContext) models.ProjectResult {
+func (mock *MockProjectCommandRunner) Apply(ctx command.ProjectContext) command.ProjectResult {
if mock == nil {
panic("mock must not be nil. Use myMock := NewMockProjectCommandRunner().")
}
params := []pegomock.Param{ctx}
- result := pegomock.GetGenericMockFrom(mock).Invoke("Apply", params, []reflect.Type{reflect.TypeOf((*models.ProjectResult)(nil)).Elem()})
- var ret0 models.ProjectResult
+ result := pegomock.GetGenericMockFrom(mock).Invoke("Apply", params, []reflect.Type{reflect.TypeOf((*command.ProjectResult)(nil)).Elem()})
+ var ret0 command.ProjectResult
if len(result) != 0 {
if result[0] != nil {
- ret0 = result[0].(models.ProjectResult)
+ ret0 = result[0].(command.ProjectResult)
}
}
return ret0
}
-func (mock *MockProjectCommandRunner) PolicyCheck(ctx models.ProjectCommandContext) models.ProjectResult {
+func (mock *MockProjectCommandRunner) PolicyCheck(ctx command.ProjectContext) command.ProjectResult {
if mock == nil {
panic("mock must not be nil. Use myMock := NewMockProjectCommandRunner().")
}
params := []pegomock.Param{ctx}
- result := pegomock.GetGenericMockFrom(mock).Invoke("PolicyCheck", params, []reflect.Type{reflect.TypeOf((*models.ProjectResult)(nil)).Elem()})
- var ret0 models.ProjectResult
+ result := pegomock.GetGenericMockFrom(mock).Invoke("PolicyCheck", params, []reflect.Type{reflect.TypeOf((*command.ProjectResult)(nil)).Elem()})
+ var ret0 command.ProjectResult
if len(result) != 0 {
if result[0] != nil {
- ret0 = result[0].(models.ProjectResult)
+ ret0 = result[0].(command.ProjectResult)
}
}
return ret0
}
-func (mock *MockProjectCommandRunner) ApprovePolicies(ctx models.ProjectCommandContext) models.ProjectResult {
+func (mock *MockProjectCommandRunner) ApprovePolicies(ctx command.ProjectContext) command.ProjectResult {
if mock == nil {
panic("mock must not be nil. Use myMock := NewMockProjectCommandRunner().")
}
params := []pegomock.Param{ctx}
- result := pegomock.GetGenericMockFrom(mock).Invoke("ApprovePolicies", params, []reflect.Type{reflect.TypeOf((*models.ProjectResult)(nil)).Elem()})
- var ret0 models.ProjectResult
+ result := pegomock.GetGenericMockFrom(mock).Invoke("ApprovePolicies", params, []reflect.Type{reflect.TypeOf((*command.ProjectResult)(nil)).Elem()})
+ var ret0 command.ProjectResult
if len(result) != 0 {
if result[0] != nil {
- ret0 = result[0].(models.ProjectResult)
+ ret0 = result[0].(command.ProjectResult)
}
}
return ret0
}
-func (mock *MockProjectCommandRunner) Version(ctx models.ProjectCommandContext) models.ProjectResult {
+func (mock *MockProjectCommandRunner) Version(ctx command.ProjectContext) command.ProjectResult {
if mock == nil {
panic("mock must not be nil. Use myMock := NewMockProjectCommandRunner().")
}
params := []pegomock.Param{ctx}
- result := pegomock.GetGenericMockFrom(mock).Invoke("Version", params, []reflect.Type{reflect.TypeOf((*models.ProjectResult)(nil)).Elem()})
- var ret0 models.ProjectResult
+ result := pegomock.GetGenericMockFrom(mock).Invoke("Version", params, []reflect.Type{reflect.TypeOf((*command.ProjectResult)(nil)).Elem()})
+ var ret0 command.ProjectResult
if len(result) != 0 {
if result[0] != nil {
- ret0 = result[0].(models.ProjectResult)
+ ret0 = result[0].(command.ProjectResult)
}
}
return ret0
@@ -137,7 +138,7 @@ type VerifierMockProjectCommandRunner struct {
timeout time.Duration
}
-func (verifier *VerifierMockProjectCommandRunner) Plan(ctx models.ProjectCommandContext) *MockProjectCommandRunner_Plan_OngoingVerification {
+func (verifier *VerifierMockProjectCommandRunner) Plan(ctx command.ProjectContext) *MockProjectCommandRunner_Plan_OngoingVerification {
params := []pegomock.Param{ctx}
methodInvocations := pegomock.GetGenericMockFrom(verifier.mock).Verify(verifier.inOrderContext, verifier.invocationCountMatcher, "Plan", params, verifier.timeout)
return &MockProjectCommandRunner_Plan_OngoingVerification{mock: verifier.mock, methodInvocations: methodInvocations}
@@ -148,23 +149,23 @@ type MockProjectCommandRunner_Plan_OngoingVerification struct {
methodInvocations []pegomock.MethodInvocation
}
-func (c *MockProjectCommandRunner_Plan_OngoingVerification) GetCapturedArguments() models.ProjectCommandContext {
+func (c *MockProjectCommandRunner_Plan_OngoingVerification) GetCapturedArguments() command.ProjectContext {
ctx := c.GetAllCapturedArguments()
return ctx[len(ctx)-1]
}
-func (c *MockProjectCommandRunner_Plan_OngoingVerification) GetAllCapturedArguments() (_param0 []models.ProjectCommandContext) {
+func (c *MockProjectCommandRunner_Plan_OngoingVerification) GetAllCapturedArguments() (_param0 []command.ProjectContext) {
params := pegomock.GetGenericMockFrom(c.mock).GetInvocationParams(c.methodInvocations)
if len(params) > 0 {
- _param0 = make([]models.ProjectCommandContext, len(c.methodInvocations))
+ _param0 = make([]command.ProjectContext, len(c.methodInvocations))
for u, param := range params[0] {
- _param0[u] = param.(models.ProjectCommandContext)
+ _param0[u] = param.(command.ProjectContext)
}
}
return
}
-func (verifier *VerifierMockProjectCommandRunner) Apply(ctx models.ProjectCommandContext) *MockProjectCommandRunner_Apply_OngoingVerification {
+func (verifier *VerifierMockProjectCommandRunner) Apply(ctx command.ProjectContext) *MockProjectCommandRunner_Apply_OngoingVerification {
params := []pegomock.Param{ctx}
methodInvocations := pegomock.GetGenericMockFrom(verifier.mock).Verify(verifier.inOrderContext, verifier.invocationCountMatcher, "Apply", params, verifier.timeout)
return &MockProjectCommandRunner_Apply_OngoingVerification{mock: verifier.mock, methodInvocations: methodInvocations}
@@ -175,23 +176,23 @@ type MockProjectCommandRunner_Apply_OngoingVerification struct {
methodInvocations []pegomock.MethodInvocation
}
-func (c *MockProjectCommandRunner_Apply_OngoingVerification) GetCapturedArguments() models.ProjectCommandContext {
+func (c *MockProjectCommandRunner_Apply_OngoingVerification) GetCapturedArguments() command.ProjectContext {
ctx := c.GetAllCapturedArguments()
return ctx[len(ctx)-1]
}
-func (c *MockProjectCommandRunner_Apply_OngoingVerification) GetAllCapturedArguments() (_param0 []models.ProjectCommandContext) {
+func (c *MockProjectCommandRunner_Apply_OngoingVerification) GetAllCapturedArguments() (_param0 []command.ProjectContext) {
params := pegomock.GetGenericMockFrom(c.mock).GetInvocationParams(c.methodInvocations)
if len(params) > 0 {
- _param0 = make([]models.ProjectCommandContext, len(c.methodInvocations))
+ _param0 = make([]command.ProjectContext, len(c.methodInvocations))
for u, param := range params[0] {
- _param0[u] = param.(models.ProjectCommandContext)
+ _param0[u] = param.(command.ProjectContext)
}
}
return
}
-func (verifier *VerifierMockProjectCommandRunner) PolicyCheck(ctx models.ProjectCommandContext) *MockProjectCommandRunner_PolicyCheck_OngoingVerification {
+func (verifier *VerifierMockProjectCommandRunner) PolicyCheck(ctx command.ProjectContext) *MockProjectCommandRunner_PolicyCheck_OngoingVerification {
params := []pegomock.Param{ctx}
methodInvocations := pegomock.GetGenericMockFrom(verifier.mock).Verify(verifier.inOrderContext, verifier.invocationCountMatcher, "PolicyCheck", params, verifier.timeout)
return &MockProjectCommandRunner_PolicyCheck_OngoingVerification{mock: verifier.mock, methodInvocations: methodInvocations}
@@ -202,23 +203,23 @@ type MockProjectCommandRunner_PolicyCheck_OngoingVerification struct {
methodInvocations []pegomock.MethodInvocation
}
-func (c *MockProjectCommandRunner_PolicyCheck_OngoingVerification) GetCapturedArguments() models.ProjectCommandContext {
+func (c *MockProjectCommandRunner_PolicyCheck_OngoingVerification) GetCapturedArguments() command.ProjectContext {
ctx := c.GetAllCapturedArguments()
return ctx[len(ctx)-1]
}
-func (c *MockProjectCommandRunner_PolicyCheck_OngoingVerification) GetAllCapturedArguments() (_param0 []models.ProjectCommandContext) {
+func (c *MockProjectCommandRunner_PolicyCheck_OngoingVerification) GetAllCapturedArguments() (_param0 []command.ProjectContext) {
params := pegomock.GetGenericMockFrom(c.mock).GetInvocationParams(c.methodInvocations)
if len(params) > 0 {
- _param0 = make([]models.ProjectCommandContext, len(c.methodInvocations))
+ _param0 = make([]command.ProjectContext, len(c.methodInvocations))
for u, param := range params[0] {
- _param0[u] = param.(models.ProjectCommandContext)
+ _param0[u] = param.(command.ProjectContext)
}
}
return
}
-func (verifier *VerifierMockProjectCommandRunner) ApprovePolicies(ctx models.ProjectCommandContext) *MockProjectCommandRunner_ApprovePolicies_OngoingVerification {
+func (verifier *VerifierMockProjectCommandRunner) ApprovePolicies(ctx command.ProjectContext) *MockProjectCommandRunner_ApprovePolicies_OngoingVerification {
params := []pegomock.Param{ctx}
methodInvocations := pegomock.GetGenericMockFrom(verifier.mock).Verify(verifier.inOrderContext, verifier.invocationCountMatcher, "ApprovePolicies", params, verifier.timeout)
return &MockProjectCommandRunner_ApprovePolicies_OngoingVerification{mock: verifier.mock, methodInvocations: methodInvocations}
@@ -229,23 +230,23 @@ type MockProjectCommandRunner_ApprovePolicies_OngoingVerification struct {
methodInvocations []pegomock.MethodInvocation
}
-func (c *MockProjectCommandRunner_ApprovePolicies_OngoingVerification) GetCapturedArguments() models.ProjectCommandContext {
+func (c *MockProjectCommandRunner_ApprovePolicies_OngoingVerification) GetCapturedArguments() command.ProjectContext {
ctx := c.GetAllCapturedArguments()
return ctx[len(ctx)-1]
}
-func (c *MockProjectCommandRunner_ApprovePolicies_OngoingVerification) GetAllCapturedArguments() (_param0 []models.ProjectCommandContext) {
+func (c *MockProjectCommandRunner_ApprovePolicies_OngoingVerification) GetAllCapturedArguments() (_param0 []command.ProjectContext) {
params := pegomock.GetGenericMockFrom(c.mock).GetInvocationParams(c.methodInvocations)
if len(params) > 0 {
- _param0 = make([]models.ProjectCommandContext, len(c.methodInvocations))
+ _param0 = make([]command.ProjectContext, len(c.methodInvocations))
for u, param := range params[0] {
- _param0[u] = param.(models.ProjectCommandContext)
+ _param0[u] = param.(command.ProjectContext)
}
}
return
}
-func (verifier *VerifierMockProjectCommandRunner) Version(ctx models.ProjectCommandContext) *MockProjectCommandRunner_Version_OngoingVerification {
+func (verifier *VerifierMockProjectCommandRunner) Version(ctx command.ProjectContext) *MockProjectCommandRunner_Version_OngoingVerification {
params := []pegomock.Param{ctx}
methodInvocations := pegomock.GetGenericMockFrom(verifier.mock).Verify(verifier.inOrderContext, verifier.invocationCountMatcher, "Version", params, verifier.timeout)
return &MockProjectCommandRunner_Version_OngoingVerification{mock: verifier.mock, methodInvocations: methodInvocations}
@@ -256,17 +257,17 @@ type MockProjectCommandRunner_Version_OngoingVerification struct {
methodInvocations []pegomock.MethodInvocation
}
-func (c *MockProjectCommandRunner_Version_OngoingVerification) GetCapturedArguments() models.ProjectCommandContext {
+func (c *MockProjectCommandRunner_Version_OngoingVerification) GetCapturedArguments() command.ProjectContext {
ctx := c.GetAllCapturedArguments()
return ctx[len(ctx)-1]
}
-func (c *MockProjectCommandRunner_Version_OngoingVerification) GetAllCapturedArguments() (_param0 []models.ProjectCommandContext) {
+func (c *MockProjectCommandRunner_Version_OngoingVerification) GetAllCapturedArguments() (_param0 []command.ProjectContext) {
params := pegomock.GetGenericMockFrom(c.mock).GetInvocationParams(c.methodInvocations)
if len(params) > 0 {
- _param0 = make([]models.ProjectCommandContext, len(c.methodInvocations))
+ _param0 = make([]command.ProjectContext, len(c.methodInvocations))
for u, param := range params[0] {
- _param0[u] = param.(models.ProjectCommandContext)
+ _param0[u] = param.(command.ProjectContext)
}
}
return
diff --git a/server/events/mocks/mock_project_lock.go b/server/events/mocks/mock_project_lock.go
index c280b4955..c1e6109c4 100644
--- a/server/events/mocks/mock_project_lock.go
+++ b/server/events/mocks/mock_project_lock.go
@@ -4,12 +4,13 @@
package mocks
import (
+ "reflect"
+ "time"
+
pegomock "github.com/petergtz/pegomock"
events "github.com/runatlantis/atlantis/server/events"
models "github.com/runatlantis/atlantis/server/events/models"
logging "github.com/runatlantis/atlantis/server/logging"
- "reflect"
- "time"
)
type MockProjectLocker struct {
diff --git a/server/events/mocks/mock_pull_cleaner.go b/server/events/mocks/mock_pull_cleaner.go
index 2288c67d7..b86bf8d89 100644
--- a/server/events/mocks/mock_pull_cleaner.go
+++ b/server/events/mocks/mock_pull_cleaner.go
@@ -4,10 +4,11 @@
package mocks
import (
- pegomock "github.com/petergtz/pegomock"
- models "github.com/runatlantis/atlantis/server/events/models"
"reflect"
"time"
+
+ pegomock "github.com/petergtz/pegomock"
+ models "github.com/runatlantis/atlantis/server/events/models"
)
type MockPullCleaner struct {
diff --git a/server/events/mocks/mock_resource_cleaner.go b/server/events/mocks/mock_resource_cleaner.go
index bd4d5d129..297a77433 100644
--- a/server/events/mocks/mock_resource_cleaner.go
+++ b/server/events/mocks/mock_resource_cleaner.go
@@ -4,10 +4,11 @@
package mocks
import (
- pegomock "github.com/petergtz/pegomock"
- jobs "github.com/runatlantis/atlantis/server/jobs"
"reflect"
"time"
+
+ pegomock "github.com/petergtz/pegomock"
+ jobs "github.com/runatlantis/atlantis/server/jobs"
)
type MockResourceCleaner struct {
diff --git a/server/events/mocks/mock_step_runner.go b/server/events/mocks/mock_step_runner.go
index 5fa0f7b0a..ff40642bb 100644
--- a/server/events/mocks/mock_step_runner.go
+++ b/server/events/mocks/mock_step_runner.go
@@ -4,10 +4,11 @@
package mocks
import (
- pegomock "github.com/petergtz/pegomock"
- models "github.com/runatlantis/atlantis/server/events/models"
"reflect"
"time"
+
+ pegomock "github.com/petergtz/pegomock"
+ "github.com/runatlantis/atlantis/server/events/command"
)
type MockStepRunner struct {
@@ -25,7 +26,7 @@ func NewMockStepRunner(options ...pegomock.Option) *MockStepRunner {
func (mock *MockStepRunner) SetFailHandler(fh pegomock.FailHandler) { mock.fail = fh }
func (mock *MockStepRunner) FailHandler() pegomock.FailHandler { return mock.fail }
-func (mock *MockStepRunner) Run(ctx models.ProjectCommandContext, extraArgs []string, path string, envs map[string]string) (string, error) {
+func (mock *MockStepRunner) Run(ctx command.ProjectContext, extraArgs []string, path string, envs map[string]string) (string, error) {
if mock == nil {
panic("mock must not be nil. Use myMock := NewMockStepRunner().")
}
@@ -81,7 +82,7 @@ type VerifierMockStepRunner struct {
timeout time.Duration
}
-func (verifier *VerifierMockStepRunner) Run(ctx models.ProjectCommandContext, extraArgs []string, path string, envs map[string]string) *MockStepRunner_Run_OngoingVerification {
+func (verifier *VerifierMockStepRunner) Run(ctx command.ProjectContext, extraArgs []string, path string, envs map[string]string) *MockStepRunner_Run_OngoingVerification {
params := []pegomock.Param{ctx, extraArgs, path, envs}
methodInvocations := pegomock.GetGenericMockFrom(verifier.mock).Verify(verifier.inOrderContext, verifier.invocationCountMatcher, "Run", params, verifier.timeout)
return &MockStepRunner_Run_OngoingVerification{mock: verifier.mock, methodInvocations: methodInvocations}
@@ -92,17 +93,17 @@ type MockStepRunner_Run_OngoingVerification struct {
methodInvocations []pegomock.MethodInvocation
}
-func (c *MockStepRunner_Run_OngoingVerification) GetCapturedArguments() (models.ProjectCommandContext, []string, string, map[string]string) {
+func (c *MockStepRunner_Run_OngoingVerification) GetCapturedArguments() (command.ProjectContext, []string, string, map[string]string) {
ctx, extraArgs, path, envs := c.GetAllCapturedArguments()
return ctx[len(ctx)-1], extraArgs[len(extraArgs)-1], path[len(path)-1], envs[len(envs)-1]
}
-func (c *MockStepRunner_Run_OngoingVerification) GetAllCapturedArguments() (_param0 []models.ProjectCommandContext, _param1 [][]string, _param2 []string, _param3 []map[string]string) {
+func (c *MockStepRunner_Run_OngoingVerification) GetAllCapturedArguments() (_param0 []command.ProjectContext, _param1 [][]string, _param2 []string, _param3 []map[string]string) {
params := pegomock.GetGenericMockFrom(c.mock).GetInvocationParams(c.methodInvocations)
if len(params) > 0 {
- _param0 = make([]models.ProjectCommandContext, len(c.methodInvocations))
+ _param0 = make([]command.ProjectContext, len(c.methodInvocations))
for u, param := range params[0] {
- _param0[u] = param.(models.ProjectCommandContext)
+ _param0[u] = param.(command.ProjectContext)
}
_param1 = make([][]string, len(c.methodInvocations))
for u, param := range params[1] {
diff --git a/server/events/mocks/mock_webhooks_sender.go b/server/events/mocks/mock_webhooks_sender.go
index fcbc85503..6a24b86ce 100644
--- a/server/events/mocks/mock_webhooks_sender.go
+++ b/server/events/mocks/mock_webhooks_sender.go
@@ -4,11 +4,12 @@
package mocks
import (
+ "reflect"
+ "time"
+
pegomock "github.com/petergtz/pegomock"
webhooks "github.com/runatlantis/atlantis/server/events/webhooks"
logging "github.com/runatlantis/atlantis/server/logging"
- "reflect"
- "time"
)
type MockWebhooksSender struct {
diff --git a/server/events/mocks/mock_working_dir.go b/server/events/mocks/mock_working_dir.go
index d9aca75a2..e5f976a01 100644
--- a/server/events/mocks/mock_working_dir.go
+++ b/server/events/mocks/mock_working_dir.go
@@ -4,11 +4,12 @@
package mocks
import (
+ "reflect"
+ "time"
+
pegomock "github.com/petergtz/pegomock"
models "github.com/runatlantis/atlantis/server/events/models"
logging "github.com/runatlantis/atlantis/server/logging"
- "reflect"
- "time"
)
type MockWorkingDir struct {
diff --git a/server/events/mocks/mock_working_dir_locker.go b/server/events/mocks/mock_working_dir_locker.go
index 57ffe9f5d..2b8f628ff 100644
--- a/server/events/mocks/mock_working_dir_locker.go
+++ b/server/events/mocks/mock_working_dir_locker.go
@@ -4,9 +4,10 @@
package mocks
import (
- pegomock "github.com/petergtz/pegomock"
"reflect"
"time"
+
+ pegomock "github.com/petergtz/pegomock"
)
type MockWorkingDirLocker struct {
diff --git a/server/events/models/fixtures/fixtures.go b/server/events/models/fixtures/fixtures.go
index 60713d6e6..2b89f293e 100644
--- a/server/events/models/fixtures/fixtures.go
+++ b/server/events/models/fixtures/fixtures.go
@@ -15,6 +15,7 @@ package fixtures
import (
"fmt"
+
"github.com/runatlantis/atlantis/server/core/config/valid"
"github.com/runatlantis/atlantis/server/events/models"
)
diff --git a/server/events/models/models.go b/server/events/models/models.go
index d43e203df..135a2dad9 100644
--- a/server/events/models/models.go
+++ b/server/events/models/models.go
@@ -24,16 +24,9 @@ import (
"strings"
"time"
- "github.com/hashicorp/go-version"
"github.com/runatlantis/atlantis/server/logging"
- "github.com/uber-go/tally"
"github.com/pkg/errors"
- "github.com/runatlantis/atlantis/server/core/config/valid"
-)
-
-const (
- planfileSlashReplace = "::"
)
type PullReqStatus struct {
@@ -226,27 +219,6 @@ type User struct {
Username string
}
-// LockMetadata contains additional data provided to the lock
-type LockMetadata struct {
- UnixTime int64
-}
-
-// CommandLock represents a global lock for an atlantis command (plan, apply, policy_check).
-// It is used to prevent commands from being executed
-type CommandLock struct {
- // Time is the time at which the lock was first created.
- LockMetadata LockMetadata
- CommandName CommandName
-}
-
-func (l *CommandLock) LockTime() time.Time {
- return time.Unix(l.LockMetadata.UnixTime, 0)
-}
-
-func (l *CommandLock) IsLocked() bool {
- return !l.LockTime().IsZero()
-}
-
// ProjectLock represents a lock on a project.
type ProjectLock struct {
// Project is the project that is being locked.
@@ -342,121 +314,6 @@ func (h VCSHostType) String() string {
return ""
}
-// ProjectCommandContext defines the context for a plan or apply stage that will
-// be executed for a project.
-type ProjectCommandContext struct {
- CommandName CommandName
- // ApplyCmd is the command that users should run to apply this plan. If
- // this is an apply then this will be empty.
- ApplyCmd string
- // ApplyRequirements is the list of requirements that must be satisfied
- // before we will run the apply stage.
- ApplyRequirements []string
- // AutomergeEnabled is true if automerge is enabled for the repo that this
- // project is in.
- AutomergeEnabled bool
- // ParallelApplyEnabled is true if parallel apply is enabled for this project.
- ParallelApplyEnabled bool
- // ParallelPlanEnabled is true if parallel plan is enabled for this project.
- ParallelPlanEnabled bool
- // ParallelPolicyCheckEnabled is true if parallel policy_check is enabled for this project.
- ParallelPolicyCheckEnabled bool
- // AutoplanEnabled is true if autoplanning is enabled for this project.
- AutoplanEnabled bool
- // BaseRepo is the repository that the pull request will be merged into.
- BaseRepo Repo
- // EscapedCommentArgs are the extra arguments that were added to the atlantis
- // command, ex. atlantis plan -- -target=resource. We then escape them
- // by adding a \ before each character so that they can be used within
- // sh -c safely, i.e. sh -c "terraform plan $(touch bad)".
- EscapedCommentArgs []string
- // HeadRepo is the repository that is getting merged into the BaseRepo.
- // If the pull request branch is from the same repository then HeadRepo will
- // be the same as BaseRepo.
- HeadRepo Repo
- // Log is a logger that's been set up for this context.
- Log logging.SimpleLogging
- // Scope is the scope for reporting stats setup for this context
- Scope tally.Scope
- // PullReqStatus holds state about the PR that requires additional computation outside models.PullRequest
- PullReqStatus PullReqStatus
- // CurrentProjectPlanStatus is the status of the current project prior to this command.
- ProjectPlanStatus ProjectPlanStatus
- // Pull is the pull request we're responding to.
- Pull PullRequest
- // ProjectName is the name of the project set in atlantis.yaml. If there was
- // no name this will be an empty string.
- ProjectName string
- // RepoConfigVersion is the version of the repo's atlantis.yaml file. If
- // there was no file, this will be 0.
- RepoConfigVersion int
- // RePlanCmd is the command that users should run to re-plan this project.
- // If this is an apply then this will be empty.
- RePlanCmd string
- // RepoRelDir is the directory of this project relative to the repo root.
- RepoRelDir string
- // Steps are the sequence of commands we need to run for this project and this
- // stage.
- Steps []valid.Step
- // TerraformVersion is the version of terraform we should use when executing
- // commands for this project. This can be set to nil in which case we will
- // use the default Atlantis terraform version.
- TerraformVersion *version.Version
- // User is the user that triggered this command.
- User User
- // Verbose is true when the user would like verbose output.
- Verbose bool
- // Workspace is the Terraform workspace this project is in. It will always
- // be set.
- Workspace string
- // PolicySets represent the policies that are run on the plan as part of the
- // policy check stage
- PolicySets valid.PolicySets
- // DeleteSourceBranchOnMerge will attempt to allow a branch to be deleted when merged (AzureDevOps & GitLab Support Only)
- DeleteSourceBranchOnMerge bool
- // UUID for atlantis logs
- JobID string
-}
-
-// SetScope sets the scope of the stats object field. Note: we deliberately set this on the value
-// instead of a pointer since we want scopes to mirror our function stack
-func (p ProjectCommandContext) SetScope(scope string) {
- p.Scope = p.Scope.SubScope(scope) //nolint
-}
-
-// GetShowResultFileName returns the filename (not the path) to store the tf show result
-func (p ProjectCommandContext) GetShowResultFileName() string {
- if p.ProjectName == "" {
- return fmt.Sprintf("%s.json", p.Workspace)
- }
- projName := strings.Replace(p.ProjectName, "/", planfileSlashReplace, -1)
- return fmt.Sprintf("%s-%s.json", projName, p.Workspace)
-}
-
-// Gets a unique identifier for the current pull request as a single string
-func (p ProjectCommandContext) PullInfo() string {
- normalizedOwner := strings.ReplaceAll(p.BaseRepo.Owner, "/", "-")
- normalizedName := strings.ReplaceAll(p.BaseRepo.Name, "/", "-")
- projectRepo := fmt.Sprintf("%s/%s", normalizedOwner, normalizedName)
-
- return BuildPullInfo(projectRepo, p.Pull.Num, p.ProjectName, p.RepoRelDir, p.Workspace)
-}
-
-func BuildPullInfo(repoName string, pullNum int, projectName string, relDir string, workspace string) string {
- projectIdentifier := GetProjectIdentifier(relDir, projectName)
- return fmt.Sprintf("%s/%d/%s/%s", repoName, pullNum, projectIdentifier, workspace)
-}
-
-func GetProjectIdentifier(relRepoDir string, projectName string) string {
- if projectName != "" {
- return projectName
- }
- // Replace directory separator / with -
- // Replace . with _ to ensure projects with no project name and root dir set to "." have a valid URL
- replacer := strings.NewReplacer("/", "-", ".", "_")
- return replacer.Replace(relRepoDir)
-}
-
// SplitRepoFullName splits a repo full name up into its owner and repo
// name segments. If the repoFullName is malformed, may return empty
// strings for owner or repo.
@@ -472,66 +329,6 @@ func SplitRepoFullName(repoFullName string) (owner string, repo string) {
return repoFullName[:lastSlashIdx], repoFullName[lastSlashIdx+1:]
}
-// ProjectResult is the result of executing a plan/policy_check/apply for a specific project.
-type ProjectResult struct {
- Command CommandName
- RepoRelDir string
- Workspace string
- Error error
- Failure string
- PlanSuccess *PlanSuccess
- PolicyCheckSuccess *PolicyCheckSuccess
- ApplySuccess string
- VersionSuccess string
- ProjectName string
-}
-
-// CommitStatus returns the vcs commit status of this project result.
-func (p ProjectResult) CommitStatus() CommitStatus {
- if p.Error != nil {
- return FailedCommitStatus
- }
- if p.Failure != "" {
- return FailedCommitStatus
- }
- return SuccessCommitStatus
-}
-
-// PlanStatus returns the plan status.
-func (p ProjectResult) PlanStatus() ProjectPlanStatus {
- switch p.Command {
-
- case PlanCommand:
- if p.Error != nil {
- return ErroredPlanStatus
- } else if p.Failure != "" {
- return ErroredPlanStatus
- }
- return PlannedPlanStatus
- case PolicyCheckCommand, ApprovePoliciesCommand:
- if p.Error != nil {
- return ErroredPolicyCheckStatus
- } else if p.Failure != "" {
- return ErroredPolicyCheckStatus
- }
- return PassedPolicyCheckStatus
- case ApplyCommand:
- if p.Error != nil {
- return ErroredApplyStatus
- } else if p.Failure != "" {
- return ErroredApplyStatus
- }
- return AppliedPlanStatus
- }
-
- panic("PlanStatus() missing a combination")
-}
-
-// IsSuccessful returns true if this project result had no errors.
-func (p ProjectResult) IsSuccessful() bool {
- return p.PlanSuccess != nil || p.PolicyCheckSuccess != nil || p.ApplySuccess != ""
-}
-
// PlanSuccess is the result of a successful plan.
type PlanSuccess struct {
// TerraformOutput is the output from Terraform of running plan.
@@ -673,52 +470,6 @@ func (p ProjectPlanStatus) String() string {
}
}
-// CommandName is which command to run.
-type CommandName int
-
-const (
- // ApplyCommand is a command to run terraform apply.
- ApplyCommand CommandName = iota
- // PlanCommand is a command to run terraform plan.
- PlanCommand
- // UnlockCommand is a command to discard previous plans as well as the atlantis locks.
- UnlockCommand
- // PolicyCheckCommand is a command to run conftest test.
- PolicyCheckCommand
- // ApprovePoliciesCommand is a command to approve policies with owner check
- ApprovePoliciesCommand
- // AutoplanCommand is a command to run terrafor plan on PR open/update if autoplan is enabled
- AutoplanCommand
- // VersionCommand is a command to run terraform version.
- VersionCommand
- // Adding more? Don't forget to update String() below
-)
-
-// TitleString returns the string representation in title form.
-// ie. policy_check becomes Policy Check
-func (c CommandName) TitleString() string {
- return strings.Title(strings.ReplaceAll(strings.ToLower(c.String()), "_", " "))
-}
-
-// String returns the string representation of c.
-func (c CommandName) String() string {
- switch c {
- case ApplyCommand:
- return "apply"
- case PlanCommand, AutoplanCommand:
- return "plan"
- case UnlockCommand:
- return "unlock"
- case PolicyCheckCommand:
- return "policy_check"
- case ApprovePoliciesCommand:
- return "approve_policies"
- case VersionCommand:
- return "version"
- }
- return ""
-}
-
// WorkflowHookCommandContext defines the context for a pre and post worklfow_hooks that will
// be executed before workflows.
type WorkflowHookCommandContext struct {
diff --git a/server/events/models/models_test.go b/server/events/models/models_test.go
index 7692205bd..7aea621b2 100644
--- a/server/events/models/models_test.go
+++ b/server/events/models/models_test.go
@@ -14,7 +14,6 @@
package models_test
import (
- "errors"
"fmt"
"testing"
@@ -355,224 +354,6 @@ func TestAzureDevopsSplitRepoFullName(t *testing.T) {
})
}
}
-
-func TestProjectResult_IsSuccessful(t *testing.T) {
- cases := map[string]struct {
- pr models.ProjectResult
- exp bool
- }{
- "plan success": {
- models.ProjectResult{
- PlanSuccess: &models.PlanSuccess{},
- },
- true,
- },
- "policy_check success": {
- models.ProjectResult{
- PolicyCheckSuccess: &models.PolicyCheckSuccess{},
- },
- true,
- },
- "apply success": {
- models.ProjectResult{
- ApplySuccess: "success",
- },
- true,
- },
- "failure": {
- models.ProjectResult{
- Failure: "failure",
- },
- false,
- },
- "error": {
- models.ProjectResult{
- Error: errors.New("error"),
- },
- false,
- },
- }
-
- for name, c := range cases {
- t.Run(name, func(t *testing.T) {
- Equals(t, c.exp, c.pr.IsSuccessful())
- })
- }
-}
-
-func TestProjectResult_PlanStatus(t *testing.T) {
- cases := []struct {
- p models.ProjectResult
- expStatus models.ProjectPlanStatus
- }{
- {
- p: models.ProjectResult{
- Command: models.PlanCommand,
- Error: errors.New("err"),
- },
- expStatus: models.ErroredPlanStatus,
- },
- {
- p: models.ProjectResult{
- Command: models.PlanCommand,
- Failure: "failure",
- },
- expStatus: models.ErroredPlanStatus,
- },
- {
- p: models.ProjectResult{
- Command: models.PlanCommand,
- PlanSuccess: &models.PlanSuccess{},
- },
- expStatus: models.PlannedPlanStatus,
- },
- {
- p: models.ProjectResult{
- Command: models.ApplyCommand,
- Error: errors.New("err"),
- },
- expStatus: models.ErroredApplyStatus,
- },
- {
- p: models.ProjectResult{
- Command: models.ApplyCommand,
- Failure: "failure",
- },
- expStatus: models.ErroredApplyStatus,
- },
- {
- p: models.ProjectResult{
- Command: models.ApplyCommand,
- ApplySuccess: "success",
- },
- expStatus: models.AppliedPlanStatus,
- },
- {
- p: models.ProjectResult{
- Command: models.PolicyCheckCommand,
- PolicyCheckSuccess: &models.PolicyCheckSuccess{},
- },
- expStatus: models.PassedPolicyCheckStatus,
- },
- {
- p: models.ProjectResult{
- Command: models.PolicyCheckCommand,
- Failure: "failure",
- },
- expStatus: models.ErroredPolicyCheckStatus,
- },
- {
- p: models.ProjectResult{
- Command: models.ApprovePoliciesCommand,
- PolicyCheckSuccess: &models.PolicyCheckSuccess{},
- },
- expStatus: models.PassedPolicyCheckStatus,
- },
- {
- p: models.ProjectResult{
- Command: models.ApprovePoliciesCommand,
- Failure: "failure",
- },
- expStatus: models.ErroredPolicyCheckStatus,
- },
- }
-
- for _, c := range cases {
- t.Run(c.expStatus.String(), func(t *testing.T) {
- Equals(t, c.expStatus, c.p.PlanStatus())
- })
- }
-}
-
-func TestPlanSuccess_Summary(t *testing.T) {
- cases := []struct {
- p models.ProjectResult
- expResult string
- }{
- {
- p: models.ProjectResult{
- PlanSuccess: &models.PlanSuccess{
- TerraformOutput: `
- An execution plan has been generated and is shown below.
- Resource actions are indicated with the following symbols:
- - destroy
-
- Terraform will perform the following actions:
-
- - null_resource.hi[1]
-
-
- Plan: 0 to add, 0 to change, 1 to destroy.`,
- },
- },
- expResult: "Plan: 0 to add, 0 to change, 1 to destroy.",
- },
- {
- p: models.ProjectResult{
- PlanSuccess: &models.PlanSuccess{
- TerraformOutput: `
- An execution plan has been generated and is shown below.
- Resource actions are indicated with the following symbols:
-
- No changes. Infrastructure is up-to-date.`,
- },
- },
- expResult: "No changes. Infrastructure is up-to-date.",
- },
- {
- p: models.ProjectResult{
- PlanSuccess: &models.PlanSuccess{
- TerraformOutput: `
- Note: Objects have changed outside of Terraform
-
- Terraform detected the following changes made outside of Terraform since the
- last "terraform apply":
-
- No changes. Your infrastructure matches the configuration.`,
- },
- },
- expResult: "\n**Note: Objects have changed outside of Terraform**\nNo changes. Your infrastructure matches the configuration.",
- },
- {
- p: models.ProjectResult{
- PlanSuccess: &models.PlanSuccess{
- TerraformOutput: `
- Note: Objects have changed outside of Terraform
-
- Terraform detected the following changes made outside of Terraform since the
- last "terraform apply":
-
- An execution plan has been generated and is shown below.
- Resource actions are indicated with the following symbols:
- - destroy
-
- Terraform will perform the following actions:
-
- - null_resource.hi[1]
-
-
- Plan: 0 to add, 0 to change, 1 to destroy.`,
- },
- },
- expResult: "\n**Note: Objects have changed outside of Terraform**\nPlan: 0 to add, 0 to change, 1 to destroy.",
- },
- {
- p: models.ProjectResult{
- PlanSuccess: &models.PlanSuccess{
- TerraformOutput: `No match, expect empty`,
- },
- },
- expResult: "",
- },
- }
-
- for _, c := range cases {
- t.Run(c.expResult, func(t *testing.T) {
- Equals(t, c.expResult, c.p.PlanSuccess.Summary())
- })
- }
-}
-
func TestPullStatus_StatusCount(t *testing.T) {
ps := models.PullStatus{
Projects: []models.ProjectStatus{
@@ -608,27 +389,3 @@ func TestPullStatus_StatusCount(t *testing.T) {
Equals(t, 1, ps.StatusCount(models.ErroredPolicyCheckStatus))
Equals(t, 1, ps.StatusCount(models.PassedPolicyCheckStatus))
}
-
-func TestApplyCommand_String(t *testing.T) {
- uc := models.ApplyCommand
-
- Equals(t, "apply", uc.String())
-}
-
-func TestPlanCommand_String(t *testing.T) {
- uc := models.PlanCommand
-
- Equals(t, "plan", uc.String())
-}
-
-func TestPolicyCheckCommand_String(t *testing.T) {
- uc := models.PolicyCheckCommand
-
- Equals(t, "policy_check", uc.String())
-}
-
-func TestUnlockCommand_String(t *testing.T) {
- uc := models.UnlockCommand
-
- Equals(t, "unlock", uc.String())
-}
diff --git a/server/events/plan_command_runner.go b/server/events/plan_command_runner.go
index 9f4d34104..526d0994d 100644
--- a/server/events/plan_command_runner.go
+++ b/server/events/plan_command_runner.go
@@ -1,6 +1,7 @@
package events
import (
+ "github.com/runatlantis/atlantis/server/events/command"
"github.com/runatlantis/atlantis/server/events/models"
"github.com/runatlantis/atlantis/server/events/vcs"
)
@@ -65,16 +66,16 @@ type PlanCommandRunner struct {
pullStatusFetcher PullStatusFetcher
}
-func (p *PlanCommandRunner) runAutoplan(ctx *CommandContext) {
+func (p *PlanCommandRunner) runAutoplan(ctx *command.Context) {
baseRepo := ctx.Pull.BaseRepo
pull := ctx.Pull
projectCmds, err := p.prjCmdBuilder.BuildAutoplanCommands(ctx)
if err != nil {
- if statusErr := p.commitStatusUpdater.UpdateCombined(baseRepo, pull, models.FailedCommitStatus, models.PlanCommand); statusErr != nil {
+ if statusErr := p.commitStatusUpdater.UpdateCombined(baseRepo, pull, models.FailedCommitStatus, command.Plan); statusErr != nil {
ctx.Log.Warn("unable to update commit status: %s", statusErr)
}
- p.pullUpdater.updatePull(ctx, AutoplanCommand{}, CommandResult{Error: err})
+ p.pullUpdater.updatePull(ctx, AutoplanCommand{}, command.Result{Error: err})
return
}
@@ -87,13 +88,13 @@ func (p *PlanCommandRunner) runAutoplan(ctx *CommandContext) {
// with 0/0 projects planned/policy_checked/applied successfully because some users require
// the Atlantis status to be passing for all pull requests.
ctx.Log.Debug("setting VCS status to success with no projects found")
- if err := p.commitStatusUpdater.UpdateCombinedCount(baseRepo, pull, models.SuccessCommitStatus, models.PlanCommand, 0, 0); err != nil {
+ if err := p.commitStatusUpdater.UpdateCombinedCount(baseRepo, pull, models.SuccessCommitStatus, command.Plan, 0, 0); err != nil {
ctx.Log.Warn("unable to update commit status: %s", err)
}
- if err := p.commitStatusUpdater.UpdateCombinedCount(baseRepo, pull, models.SuccessCommitStatus, models.PolicyCheckCommand, 0, 0); err != nil {
+ if err := p.commitStatusUpdater.UpdateCombinedCount(baseRepo, pull, models.SuccessCommitStatus, command.PolicyCheck, 0, 0); err != nil {
ctx.Log.Warn("unable to update commit status: %s", err)
}
- if err := p.commitStatusUpdater.UpdateCombinedCount(baseRepo, pull, models.SuccessCommitStatus, models.ApplyCommand, 0, 0); err != nil {
+ if err := p.commitStatusUpdater.UpdateCombinedCount(baseRepo, pull, models.SuccessCommitStatus, command.Apply, 0, 0); err != nil {
ctx.Log.Warn("unable to update commit status: %s", err)
}
}
@@ -101,15 +102,15 @@ func (p *PlanCommandRunner) runAutoplan(ctx *CommandContext) {
}
// At this point we are sure Atlantis has work to do, so set commit status to pending
- if err := p.commitStatusUpdater.UpdateCombined(ctx.Pull.BaseRepo, ctx.Pull, models.PendingCommitStatus, models.PlanCommand); err != nil {
+ if err := p.commitStatusUpdater.UpdateCombined(ctx.Pull.BaseRepo, ctx.Pull, models.PendingCommitStatus, command.Plan); err != nil {
ctx.Log.Warn("unable to update plan commit status: %s", err)
}
- if err := p.commitStatusUpdater.UpdateCombinedCount(ctx.Pull.BaseRepo, ctx.Pull, models.PendingCommitStatus, models.ApplyCommand, 0, len(projectCmds)); err != nil {
+ if err := p.commitStatusUpdater.UpdateCombinedCount(ctx.Pull.BaseRepo, ctx.Pull, models.PendingCommitStatus, command.Apply, 0, len(projectCmds)); err != nil {
ctx.Log.Warn("unable to update apply commit status: %s", err)
}
// Only run commands in parallel if enabled
- var result CommandResult
+ var result command.Result
if p.isParallelEnabled(projectCmds) {
ctx.Log.Info("Running plans in parallel")
result = runProjectCmdsParallel(projectCmds, p.prjCmdRunner.Plan, p.parallelPoolSize)
@@ -148,21 +149,21 @@ func (p *PlanCommandRunner) runAutoplan(ctx *CommandContext) {
}
}
-func (p *PlanCommandRunner) run(ctx *CommandContext, cmd *CommentCommand) {
+func (p *PlanCommandRunner) run(ctx *command.Context, cmd *CommentCommand) {
var err error
baseRepo := ctx.Pull.BaseRepo
pull := ctx.Pull
- if err = p.commitStatusUpdater.UpdateCombined(baseRepo, pull, models.PendingCommitStatus, models.PlanCommand); err != nil {
+ if err = p.commitStatusUpdater.UpdateCombined(baseRepo, pull, models.PendingCommitStatus, command.Plan); err != nil {
ctx.Log.Warn("unable to update commit status: %s", err)
}
projectCmds, err := p.prjCmdBuilder.BuildPlanCommands(ctx, cmd)
if err != nil {
- if statusErr := p.commitStatusUpdater.UpdateCombined(ctx.Pull.BaseRepo, ctx.Pull, models.FailedCommitStatus, models.PlanCommand); statusErr != nil {
+ if statusErr := p.commitStatusUpdater.UpdateCombined(ctx.Pull.BaseRepo, ctx.Pull, models.FailedCommitStatus, command.Plan); statusErr != nil {
ctx.Log.Warn("unable to update commit status: %s", statusErr)
}
- p.pullUpdater.updatePull(ctx, cmd, CommandResult{Error: err})
+ p.pullUpdater.updatePull(ctx, cmd, command.Result{Error: err})
return
}
@@ -173,7 +174,7 @@ func (p *PlanCommandRunner) run(ctx *CommandContext, cmd *CommentCommand) {
// with 0/0 projects planned successfully because some users require
// the Atlantis status to be passing for all pull requests.
ctx.Log.Debug("setting VCS status to success with no projects found")
- if err := p.commitStatusUpdater.UpdateCombinedCount(baseRepo, pull, models.SuccessCommitStatus, models.PlanCommand, 0, 0); err != nil {
+ if err := p.commitStatusUpdater.UpdateCombinedCount(baseRepo, pull, models.SuccessCommitStatus, command.Plan, 0, 0); err != nil {
ctx.Log.Warn("unable to update commit status: %s", err)
}
}
@@ -183,15 +184,15 @@ func (p *PlanCommandRunner) run(ctx *CommandContext, cmd *CommentCommand) {
projectCmds, policyCheckCmds := p.partitionProjectCmds(ctx, projectCmds)
// At this point we are sure Atlantis has work to do, so set commit status to pending
- if err := p.commitStatusUpdater.UpdateCombined(ctx.Pull.BaseRepo, ctx.Pull, models.PendingCommitStatus, models.PlanCommand); err != nil {
+ if err := p.commitStatusUpdater.UpdateCombined(ctx.Pull.BaseRepo, ctx.Pull, models.PendingCommitStatus, command.Plan); err != nil {
ctx.Log.Warn("unable to update plan commit status: %s", err)
}
- if err := p.commitStatusUpdater.UpdateCombinedCount(ctx.Pull.BaseRepo, ctx.Pull, models.PendingCommitStatus, models.ApplyCommand, 0, len(projectCmds)); err != nil {
+ if err := p.commitStatusUpdater.UpdateCombinedCount(ctx.Pull.BaseRepo, ctx.Pull, models.PendingCommitStatus, command.Apply, 0, len(projectCmds)); err != nil {
ctx.Log.Warn("unable to update apply commit status: %s", err)
}
// Only run commands in parallel if enabled
- var result CommandResult
+ var result command.Result
if p.isParallelEnabled(projectCmds) {
ctx.Log.Info("Running applies in parallel")
result = runProjectCmdsParallel(projectCmds, p.prjCmdRunner.Plan, p.parallelPoolSize)
@@ -227,15 +228,15 @@ func (p *PlanCommandRunner) run(ctx *CommandContext, cmd *CommentCommand) {
}
}
-func (p *PlanCommandRunner) Run(ctx *CommandContext, cmd *CommentCommand) {
- if ctx.Trigger == Auto {
+func (p *PlanCommandRunner) Run(ctx *command.Context, cmd *CommentCommand) {
+ if ctx.Trigger == command.AutoTrigger {
p.runAutoplan(ctx)
} else {
p.run(ctx, cmd)
}
}
-func (p *PlanCommandRunner) updateCommitStatus(ctx *CommandContext, pullStatus models.PullStatus) {
+func (p *PlanCommandRunner) updateCommitStatus(ctx *command.Context, pullStatus models.PullStatus) {
var numSuccess int
var numErrored int
status := models.SuccessCommitStatus
@@ -254,7 +255,7 @@ func (p *PlanCommandRunner) updateCommitStatus(ctx *CommandContext, pullStatus m
ctx.Pull.BaseRepo,
ctx.Pull,
status,
- models.PlanCommand,
+ command.Plan,
numSuccess,
len(pullStatus.Projects),
); err != nil {
@@ -263,7 +264,7 @@ func (p *PlanCommandRunner) updateCommitStatus(ctx *CommandContext, pullStatus m
}
// deletePlans deletes all plans generated in this ctx.
-func (p *PlanCommandRunner) deletePlans(ctx *CommandContext) {
+func (p *PlanCommandRunner) deletePlans(ctx *command.Context) {
pullDir, err := p.workingDir.GetPullDir(ctx.Pull.BaseRepo, ctx.Pull)
if err != nil {
ctx.Log.Err("getting pull dir: %s", err)
@@ -274,17 +275,17 @@ func (p *PlanCommandRunner) deletePlans(ctx *CommandContext) {
}
func (p *PlanCommandRunner) partitionProjectCmds(
- ctx *CommandContext,
- cmds []models.ProjectCommandContext,
+ ctx *command.Context,
+ cmds []command.ProjectContext,
) (
- projectCmds []models.ProjectCommandContext,
- policyCheckCmds []models.ProjectCommandContext,
+ projectCmds []command.ProjectContext,
+ policyCheckCmds []command.ProjectContext,
) {
for _, cmd := range cmds {
switch cmd.CommandName {
- case models.PlanCommand:
+ case command.Plan:
projectCmds = append(projectCmds, cmd)
- case models.PolicyCheckCommand:
+ case command.PolicyCheck:
policyCheckCmds = append(policyCheckCmds, cmd)
default:
ctx.Log.Err("%s is not supported", cmd.CommandName)
@@ -293,6 +294,6 @@ func (p *PlanCommandRunner) partitionProjectCmds(
return
}
-func (p *PlanCommandRunner) isParallelEnabled(projectCmds []models.ProjectCommandContext) bool {
+func (p *PlanCommandRunner) isParallelEnabled(projectCmds []command.ProjectContext) bool {
return len(projectCmds) > 0 && projectCmds[0].ParallelPlanEnabled
}
diff --git a/server/events/policy_check_command_runner.go b/server/events/policy_check_command_runner.go
index 246830fa9..f82470b92 100644
--- a/server/events/policy_check_command_runner.go
+++ b/server/events/policy_check_command_runner.go
@@ -1,6 +1,9 @@
package events
-import "github.com/runatlantis/atlantis/server/events/models"
+import (
+ "github.com/runatlantis/atlantis/server/events/command"
+ "github.com/runatlantis/atlantis/server/events/models"
+)
func NewPolicyCheckCommandRunner(
dbUpdater *DBUpdater,
@@ -31,7 +34,7 @@ type PolicyCheckCommandRunner struct {
silenceVCSStatusNoProjects bool
}
-func (p *PolicyCheckCommandRunner) Run(ctx *CommandContext, cmds []models.ProjectCommandContext) {
+func (p *PolicyCheckCommandRunner) Run(ctx *command.Context, cmds []command.ProjectContext) {
if len(cmds) == 0 {
ctx.Log.Info("no projects to run policy_check in")
if !p.silenceVCSStatusNoProjects {
@@ -39,7 +42,7 @@ func (p *PolicyCheckCommandRunner) Run(ctx *CommandContext, cmds []models.Projec
// with 0/0 projects policy_checked successfully because some users require
// the Atlantis status to be passing for all pull requests.
ctx.Log.Debug("setting VCS status to success with no projects found")
- if err := p.commitStatusUpdater.UpdateCombinedCount(ctx.Pull.BaseRepo, ctx.Pull, models.SuccessCommitStatus, models.PolicyCheckCommand, 0, 0); err != nil {
+ if err := p.commitStatusUpdater.UpdateCombinedCount(ctx.Pull.BaseRepo, ctx.Pull, models.SuccessCommitStatus, command.PolicyCheck, 0, 0); err != nil {
ctx.Log.Warn("unable to update commit status: %s", err)
}
}
@@ -47,11 +50,11 @@ func (p *PolicyCheckCommandRunner) Run(ctx *CommandContext, cmds []models.Projec
}
// So set policy_check commit status to pending
- if err := p.commitStatusUpdater.UpdateCombined(ctx.Pull.BaseRepo, ctx.Pull, models.PendingCommitStatus, models.PolicyCheckCommand); err != nil {
+ if err := p.commitStatusUpdater.UpdateCombined(ctx.Pull.BaseRepo, ctx.Pull, models.PendingCommitStatus, command.PolicyCheck); err != nil {
ctx.Log.Warn("unable to update commit status: %s", err)
}
- var result CommandResult
+ var result command.Result
if p.isParallelEnabled(cmds) {
ctx.Log.Info("Running policy_checks in parallel")
result = runProjectCmdsParallel(cmds, p.prjCmdRunner.PolicyCheck, p.parallelPoolSize)
@@ -69,7 +72,7 @@ func (p *PolicyCheckCommandRunner) Run(ctx *CommandContext, cmds []models.Projec
p.updateCommitStatus(ctx, pullStatus)
}
-func (p *PolicyCheckCommandRunner) updateCommitStatus(ctx *CommandContext, pullStatus models.PullStatus) {
+func (p *PolicyCheckCommandRunner) updateCommitStatus(ctx *command.Context, pullStatus models.PullStatus) {
var numSuccess int
var numErrored int
status := models.SuccessCommitStatus
@@ -81,11 +84,11 @@ func (p *PolicyCheckCommandRunner) updateCommitStatus(ctx *CommandContext, pullS
status = models.FailedCommitStatus
}
- if err := p.commitStatusUpdater.UpdateCombinedCount(ctx.Pull.BaseRepo, ctx.Pull, status, models.PolicyCheckCommand, numSuccess, len(pullStatus.Projects)); err != nil {
+ if err := p.commitStatusUpdater.UpdateCombinedCount(ctx.Pull.BaseRepo, ctx.Pull, status, command.PolicyCheck, numSuccess, len(pullStatus.Projects)); err != nil {
ctx.Log.Warn("unable to update commit status: %s", err)
}
}
-func (p *PolicyCheckCommandRunner) isParallelEnabled(cmds []models.ProjectCommandContext) bool {
+func (p *PolicyCheckCommandRunner) isParallelEnabled(cmds []command.ProjectContext) bool {
return len(cmds) > 0 && cmds[0].ParallelPolicyCheckEnabled
}
diff --git a/server/events/post_workflow_hooks_command_runner.go b/server/events/post_workflow_hooks_command_runner.go
index 00e0348f9..6e534e712 100644
--- a/server/events/post_workflow_hooks_command_runner.go
+++ b/server/events/post_workflow_hooks_command_runner.go
@@ -3,6 +3,7 @@ package events
import (
"github.com/runatlantis/atlantis/server/core/config/valid"
"github.com/runatlantis/atlantis/server/core/runtime"
+ "github.com/runatlantis/atlantis/server/events/command"
"github.com/runatlantis/atlantis/server/events/models"
"github.com/runatlantis/atlantis/server/events/vcs"
)
@@ -10,7 +11,7 @@ import (
//go:generate pegomock generate -m --use-experimental-model-gen --package mocks -o mocks/mock_post_workflows_hooks_command_runner.go PostWorkflowHooksCommandRunner
type PostWorkflowHooksCommandRunner interface {
- RunPostHooks(ctx *CommandContext) error
+ RunPostHooks(ctx *command.Context) error
}
// DefaultPostWorkflowHooksCommandRunner is the first step when processing a workflow hook commands.
@@ -24,7 +25,7 @@ type DefaultPostWorkflowHooksCommandRunner struct {
// RunPostHooks runs post_workflow_hooks after a plan/apply has completed
func (w *DefaultPostWorkflowHooksCommandRunner) RunPostHooks(
- ctx *CommandContext,
+ ctx *command.Context,
) error {
pull := ctx.Pull
baseRepo := pull.BaseRepo
diff --git a/server/events/post_workflow_hooks_command_runner_test.go b/server/events/post_workflow_hooks_command_runner_test.go
index 68e0875da..b595178a3 100644
--- a/server/events/post_workflow_hooks_command_runner_test.go
+++ b/server/events/post_workflow_hooks_command_runner_test.go
@@ -9,6 +9,7 @@ import (
. "github.com/petergtz/pegomock"
"github.com/runatlantis/atlantis/server/core/config/valid"
"github.com/runatlantis/atlantis/server/events"
+ "github.com/runatlantis/atlantis/server/events/command"
"github.com/runatlantis/atlantis/server/events/mocks"
"github.com/runatlantis/atlantis/server/events/models"
"github.com/runatlantis/atlantis/server/events/models/fixtures"
@@ -44,7 +45,7 @@ func TestRunPostHooks_Clone(t *testing.T) {
var newPull = fixtures.Pull
newPull.BaseRepo = fixtures.GithubRepo
- ctx := &events.CommandContext{
+ ctx := &command.Context{
Pull: newPull,
HeadRepo: fixtures.GithubRepo,
User: fixtures.User,
diff --git a/server/events/pre_workflow_hooks_command_runner.go b/server/events/pre_workflow_hooks_command_runner.go
index 7ee2a4f06..f197d8fa3 100644
--- a/server/events/pre_workflow_hooks_command_runner.go
+++ b/server/events/pre_workflow_hooks_command_runner.go
@@ -3,6 +3,7 @@ package events
import (
"github.com/runatlantis/atlantis/server/core/config/valid"
"github.com/runatlantis/atlantis/server/core/runtime"
+ "github.com/runatlantis/atlantis/server/events/command"
"github.com/runatlantis/atlantis/server/events/models"
"github.com/runatlantis/atlantis/server/events/vcs"
)
@@ -10,7 +11,7 @@ import (
//go:generate pegomock generate -m --use-experimental-model-gen --package mocks -o mocks/mock_pre_workflows_hooks_command_runner.go PreWorkflowHooksCommandRunner
type PreWorkflowHooksCommandRunner interface {
- RunPreHooks(ctx *CommandContext) error
+ RunPreHooks(ctx *command.Context) error
}
// DefaultPreWorkflowHooksCommandRunner is the first step when processing a workflow hook commands.
@@ -24,7 +25,7 @@ type DefaultPreWorkflowHooksCommandRunner struct {
// RunPreHooks runs pre_workflow_hooks when PR is opened or updated.
func (w *DefaultPreWorkflowHooksCommandRunner) RunPreHooks(
- ctx *CommandContext,
+ ctx *command.Context,
) error {
pull := ctx.Pull
baseRepo := pull.BaseRepo
diff --git a/server/events/pre_workflow_hooks_command_runner_test.go b/server/events/pre_workflow_hooks_command_runner_test.go
index d94b010ab..dc31c494c 100644
--- a/server/events/pre_workflow_hooks_command_runner_test.go
+++ b/server/events/pre_workflow_hooks_command_runner_test.go
@@ -8,6 +8,7 @@ import (
"github.com/runatlantis/atlantis/server/core/config/valid"
runtime_mocks "github.com/runatlantis/atlantis/server/core/runtime/mocks"
"github.com/runatlantis/atlantis/server/events"
+ "github.com/runatlantis/atlantis/server/events/command"
"github.com/runatlantis/atlantis/server/events/mocks"
"github.com/runatlantis/atlantis/server/events/models"
"github.com/runatlantis/atlantis/server/events/models/fixtures"
@@ -47,7 +48,7 @@ func TestRunPreHooks_Clone(t *testing.T) {
var newPull = fixtures.Pull
newPull.BaseRepo = fixtures.GithubRepo
- ctx := &events.CommandContext{
+ ctx := &command.Context{
Pull: newPull,
HeadRepo: fixtures.GithubRepo,
User: fixtures.User,
diff --git a/server/events/project_command_builder.go b/server/events/project_command_builder.go
index d9f8657b6..04feca8a6 100644
--- a/server/events/project_command_builder.go
+++ b/server/events/project_command_builder.go
@@ -10,7 +10,7 @@ import (
"github.com/pkg/errors"
"github.com/runatlantis/atlantis/server/core/config"
- "github.com/runatlantis/atlantis/server/events/models"
+ "github.com/runatlantis/atlantis/server/events/command"
"github.com/runatlantis/atlantis/server/events/vcs"
)
@@ -106,30 +106,30 @@ func NewProjectCommandBuilder(
type ProjectPlanCommandBuilder interface {
// BuildAutoplanCommands builds project commands that will run plan on
// the projects determined to be modified.
- BuildAutoplanCommands(ctx *CommandContext) ([]models.ProjectCommandContext, error)
+ BuildAutoplanCommands(ctx *command.Context) ([]command.ProjectContext, error)
// BuildPlanCommands builds project plan commands for this ctx and comment. If
// comment doesn't specify one project then there may be multiple commands
// to be run.
- BuildPlanCommands(ctx *CommandContext, comment *CommentCommand) ([]models.ProjectCommandContext, error)
+ BuildPlanCommands(ctx *command.Context, comment *CommentCommand) ([]command.ProjectContext, error)
}
type ProjectApplyCommandBuilder interface {
// BuildApplyCommands builds project Apply commands for this ctx and comment. If
// comment doesn't specify one project then there may be multiple commands
// to be run.
- BuildApplyCommands(ctx *CommandContext, comment *CommentCommand) ([]models.ProjectCommandContext, error)
+ BuildApplyCommands(ctx *command.Context, comment *CommentCommand) ([]command.ProjectContext, error)
}
type ProjectApprovePoliciesCommandBuilder interface {
// BuildApprovePoliciesCommands builds project PolicyCheck commands for this ctx and comment.
- BuildApprovePoliciesCommands(ctx *CommandContext, comment *CommentCommand) ([]models.ProjectCommandContext, error)
+ BuildApprovePoliciesCommands(ctx *command.Context, comment *CommentCommand) ([]command.ProjectContext, error)
}
type ProjectVersionCommandBuilder interface {
// BuildVersionCommands builds project Version commands for this ctx and comment. If
// comment doesn't specify one project then there may be multiple commands
// to be run.
- BuildVersionCommands(ctx *CommandContext, comment *CommentCommand) ([]models.ProjectCommandContext, error)
+ BuildVersionCommands(ctx *command.Context, comment *CommentCommand) ([]command.ProjectContext, error)
}
//go:generate pegomock generate -m --use-experimental-model-gen --package mocks -o mocks/mock_project_command_builder.go ProjectCommandBuilder
@@ -161,12 +161,12 @@ type DefaultProjectCommandBuilder struct {
}
// See ProjectCommandBuilder.BuildAutoplanCommands.
-func (p *DefaultProjectCommandBuilder) BuildAutoplanCommands(ctx *CommandContext) ([]models.ProjectCommandContext, error) {
+func (p *DefaultProjectCommandBuilder) BuildAutoplanCommands(ctx *command.Context) ([]command.ProjectContext, error) {
projCtxs, err := p.buildPlanAllCommands(ctx, nil, false)
if err != nil {
return nil, err
}
- var autoplanEnabled []models.ProjectCommandContext
+ var autoplanEnabled []command.ProjectContext
for _, projCtx := range projCtxs {
if !projCtx.AutoplanEnabled {
ctx.Log.Debug("ignoring project at dir %q, workspace: %q because autoplan is disabled", projCtx.RepoRelDir, projCtx.Workspace)
@@ -178,7 +178,7 @@ func (p *DefaultProjectCommandBuilder) BuildAutoplanCommands(ctx *CommandContext
}
// See ProjectCommandBuilder.BuildPlanCommands.
-func (p *DefaultProjectCommandBuilder) BuildPlanCommands(ctx *CommandContext, cmd *CommentCommand) ([]models.ProjectCommandContext, error) {
+func (p *DefaultProjectCommandBuilder) BuildPlanCommands(ctx *command.Context, cmd *CommentCommand) ([]command.ProjectContext, error) {
if !cmd.IsForSpecificProject() {
return p.buildPlanAllCommands(ctx, cmd.Flags, cmd.Verbose)
}
@@ -187,7 +187,7 @@ func (p *DefaultProjectCommandBuilder) BuildPlanCommands(ctx *CommandContext, cm
}
// See ProjectCommandBuilder.BuildApplyCommands.
-func (p *DefaultProjectCommandBuilder) BuildApplyCommands(ctx *CommandContext, cmd *CommentCommand) ([]models.ProjectCommandContext, error) {
+func (p *DefaultProjectCommandBuilder) BuildApplyCommands(ctx *command.Context, cmd *CommentCommand) ([]command.ProjectContext, error) {
if !cmd.IsForSpecificProject() {
return p.buildAllProjectCommands(ctx, cmd)
}
@@ -195,11 +195,11 @@ func (p *DefaultProjectCommandBuilder) BuildApplyCommands(ctx *CommandContext, c
return pac, err
}
-func (p *DefaultProjectCommandBuilder) BuildApprovePoliciesCommands(ctx *CommandContext, cmd *CommentCommand) ([]models.ProjectCommandContext, error) {
+func (p *DefaultProjectCommandBuilder) BuildApprovePoliciesCommands(ctx *command.Context, cmd *CommentCommand) ([]command.ProjectContext, error) {
return p.buildAllProjectCommands(ctx, cmd)
}
-func (p *DefaultProjectCommandBuilder) BuildVersionCommands(ctx *CommandContext, cmd *CommentCommand) ([]models.ProjectCommandContext, error) {
+func (p *DefaultProjectCommandBuilder) BuildVersionCommands(ctx *command.Context, cmd *CommentCommand) ([]command.ProjectContext, error) {
if !cmd.IsForSpecificProject() {
return p.buildAllProjectCommands(ctx, cmd)
}
@@ -209,7 +209,7 @@ func (p *DefaultProjectCommandBuilder) BuildVersionCommands(ctx *CommandContext,
// buildPlanAllCommands builds plan contexts for all projects we determine were
// modified in this ctx.
-func (p *DefaultProjectCommandBuilder) buildPlanAllCommands(ctx *CommandContext, commentFlags []string, verbose bool) ([]models.ProjectCommandContext, error) {
+func (p *DefaultProjectCommandBuilder) buildPlanAllCommands(ctx *command.Context, commentFlags []string, verbose bool) ([]command.ProjectContext, error) {
// We'll need the list of modified files.
modifiedFiles, err := p.VCSClient.GetModifiedFiles(ctx.Pull.BaseRepo, ctx.Pull)
if err != nil {
@@ -236,7 +236,7 @@ func (p *DefaultProjectCommandBuilder) buildPlanAllCommands(ctx *CommandContext,
ctx.Log.Info("%d projects are changed on MR %q based on their when_modified config", len(matchingProjects), ctx.Pull.Num)
if len(matchingProjects) == 0 {
ctx.Log.Info("skipping repo clone since no project was modified")
- return []models.ProjectCommandContext{}, nil
+ return []command.ProjectContext{}, nil
}
// NOTE: We discard this work here and end up doing it again after
// cloning to ensure all the return values are set properly with
@@ -266,7 +266,7 @@ func (p *DefaultProjectCommandBuilder) buildPlanAllCommands(ctx *CommandContext,
return nil, errors.Wrapf(err, "looking for %s file in %q", config.AtlantisYAMLFilename, repoDir)
}
- var projCtxs []models.ProjectCommandContext
+ var projCtxs []command.ProjectContext
if hasRepoCfg {
// If there's a repo cfg then we'll use it to figure out which projects
@@ -289,7 +289,7 @@ func (p *DefaultProjectCommandBuilder) buildPlanAllCommands(ctx *CommandContext,
projCtxs = append(projCtxs,
p.ProjectCommandContextBuilder.BuildProjectContext(
ctx,
- models.PlanCommand,
+ command.Plan,
mergedCfg,
commentFlags,
repoDir,
@@ -316,7 +316,7 @@ func (p *DefaultProjectCommandBuilder) buildPlanAllCommands(ctx *CommandContext,
projCtxs = append(projCtxs,
p.ProjectCommandContextBuilder.BuildProjectContext(
ctx,
- models.PlanCommand,
+ command.Plan,
pCfg,
commentFlags,
repoDir,
@@ -334,13 +334,13 @@ func (p *DefaultProjectCommandBuilder) buildPlanAllCommands(ctx *CommandContext,
// buildProjectPlanCommand builds a plan context for a single project.
// cmd must be for only one project.
-func (p *DefaultProjectCommandBuilder) buildProjectPlanCommand(ctx *CommandContext, cmd *CommentCommand) ([]models.ProjectCommandContext, error) {
+func (p *DefaultProjectCommandBuilder) buildProjectPlanCommand(ctx *command.Context, cmd *CommentCommand) ([]command.ProjectContext, error) {
workspace := DefaultWorkspace
if cmd.Workspace != "" {
workspace = cmd.Workspace
}
- var pcc []models.ProjectCommandContext
+ var pcc []command.ProjectContext
ctx.Log.Debug("building plan command")
unlockFn, err := p.WorkingDirLocker.TryLock(ctx.Pull.BaseRepo.FullName, ctx.Pull.Num, workspace)
if err != nil {
@@ -368,7 +368,7 @@ func (p *DefaultProjectCommandBuilder) buildProjectPlanCommand(ctx *CommandConte
return p.buildProjectCommandCtx(
ctx,
- models.PlanCommand,
+ command.Plan,
cmd.ProjectName,
cmd.Flags,
defaultRepoDir,
@@ -380,7 +380,7 @@ func (p *DefaultProjectCommandBuilder) buildProjectPlanCommand(ctx *CommandConte
// getCfg returns the atlantis.yaml config (if it exists) for this project. If
// there is no config, then projectCfg and repoCfg will be nil.
-func (p *DefaultProjectCommandBuilder) getCfg(ctx *CommandContext, projectName string, dir string, workspace string, repoDir string) (projectsCfg []valid.Project, repoCfg *valid.RepoCfg, err error) {
+func (p *DefaultProjectCommandBuilder) getCfg(ctx *command.Context, projectName string, dir string, workspace string, repoDir string) (projectsCfg []valid.Project, repoCfg *valid.RepoCfg, err error) {
hasConfigFile, err := p.ParserValidator.HasRepoCfg(repoDir)
if err != nil {
err = errors.Wrapf(err, "looking for %s file in %q", config.AtlantisYAMLFilename, repoDir)
@@ -432,7 +432,7 @@ func (p *DefaultProjectCommandBuilder) getCfg(ctx *CommandContext, projectName s
// buildAllProjectCommands builds contexts for a command for every project that has
// pending plans in this ctx.
-func (p *DefaultProjectCommandBuilder) buildAllProjectCommands(ctx *CommandContext, commentCmd *CommentCommand) ([]models.ProjectCommandContext, error) {
+func (p *DefaultProjectCommandBuilder) buildAllProjectCommands(ctx *command.Context, commentCmd *CommentCommand) ([]command.ProjectContext, error) {
// Lock all dirs in this pull request (instead of a single dir) because we
// don't know how many dirs we'll need to run the command in.
unlockFn, err := p.WorkingDirLocker.TryLockPull(ctx.Pull.BaseRepo.FullName, ctx.Pull.Num)
@@ -458,7 +458,7 @@ func (p *DefaultProjectCommandBuilder) buildAllProjectCommands(ctx *CommandConte
return nil, err
}
- var cmds []models.ProjectCommandContext
+ var cmds []command.ProjectContext
for _, plan := range plans {
commentCmds, err := p.buildProjectCommandCtx(ctx, commentCmd.CommandName(), plan.ProjectName, commentCmd.Flags, defaultRepoDir, plan.RepoRelDir, plan.Workspace, commentCmd.Verbose)
if err != nil {
@@ -471,13 +471,13 @@ func (p *DefaultProjectCommandBuilder) buildAllProjectCommands(ctx *CommandConte
// buildProjectApplyCommand builds an apply command for the single project
// identified by cmd.
-func (p *DefaultProjectCommandBuilder) buildProjectApplyCommand(ctx *CommandContext, cmd *CommentCommand) ([]models.ProjectCommandContext, error) {
+func (p *DefaultProjectCommandBuilder) buildProjectApplyCommand(ctx *command.Context, cmd *CommentCommand) ([]command.ProjectContext, error) {
workspace := DefaultWorkspace
if cmd.Workspace != "" {
workspace = cmd.Workspace
}
- var projCtx []models.ProjectCommandContext
+ var projCtx []command.ProjectContext
unlockFn, err := p.WorkingDirLocker.TryLock(ctx.Pull.BaseRepo.FullName, ctx.Pull.Num, workspace)
if err != nil {
return projCtx, err
@@ -500,7 +500,7 @@ func (p *DefaultProjectCommandBuilder) buildProjectApplyCommand(ctx *CommandCont
return p.buildProjectCommandCtx(
ctx,
- models.ApplyCommand,
+ command.Apply,
cmd.ProjectName,
cmd.Flags,
repoDir,
@@ -512,13 +512,13 @@ func (p *DefaultProjectCommandBuilder) buildProjectApplyCommand(ctx *CommandCont
// buildProjectVersionCommand builds a version command for the single project
// identified by cmd.
-func (p *DefaultProjectCommandBuilder) buildProjectVersionCommand(ctx *CommandContext, cmd *CommentCommand) ([]models.ProjectCommandContext, error) {
+func (p *DefaultProjectCommandBuilder) buildProjectVersionCommand(ctx *command.Context, cmd *CommentCommand) ([]command.ProjectContext, error) {
workspace := DefaultWorkspace
if cmd.Workspace != "" {
workspace = cmd.Workspace
}
- var projCtx []models.ProjectCommandContext
+ var projCtx []command.ProjectContext
unlockFn, err := p.WorkingDirLocker.TryLock(ctx.Pull.BaseRepo.FullName, ctx.Pull.Num, workspace)
if err != nil {
return projCtx, err
@@ -541,7 +541,7 @@ func (p *DefaultProjectCommandBuilder) buildProjectVersionCommand(ctx *CommandCo
return p.buildProjectCommandCtx(
ctx,
- models.VersionCommand,
+ command.Version,
cmd.ProjectName,
cmd.Flags,
repoDir,
@@ -553,20 +553,20 @@ func (p *DefaultProjectCommandBuilder) buildProjectVersionCommand(ctx *CommandCo
// buildProjectCommandCtx builds a context for a single or several projects identified
// by the parameters.
-func (p *DefaultProjectCommandBuilder) buildProjectCommandCtx(ctx *CommandContext,
- cmd models.CommandName,
+func (p *DefaultProjectCommandBuilder) buildProjectCommandCtx(ctx *command.Context,
+ cmd command.Name,
projectName string,
commentFlags []string,
repoDir string,
repoRelDir string,
workspace string,
- verbose bool) ([]models.ProjectCommandContext, error) {
+ verbose bool) ([]command.ProjectContext, error) {
matchingProjects, repoCfgPtr, err := p.getCfg(ctx, projectName, repoRelDir, workspace, repoDir)
if err != nil {
- return []models.ProjectCommandContext{}, err
+ return []command.ProjectContext{}, err
}
- var projCtxs []models.ProjectCommandContext
+ var projCtxs []command.ProjectContext
var projCfg valid.MergedProjectCfg
automerge := DefaultAutomergeEnabled
parallelApply := DefaultParallelApplyEnabled
@@ -619,7 +619,7 @@ func (p *DefaultProjectCommandBuilder) buildProjectCommandCtx(ctx *CommandContex
}
if err := p.validateWorkspaceAllowed(repoCfgPtr, repoRelDir, workspace); err != nil {
- return []models.ProjectCommandContext{}, err
+ return []command.ProjectContext{}, err
}
return projCtxs, nil
diff --git a/server/events/project_command_builder_internal_test.go b/server/events/project_command_builder_internal_test.go
index 9b1ca4289..a8a0dc847 100644
--- a/server/events/project_command_builder_internal_test.go
+++ b/server/events/project_command_builder_internal_test.go
@@ -9,6 +9,7 @@ import (
. "github.com/petergtz/pegomock"
"github.com/runatlantis/atlantis/server/core/config"
"github.com/runatlantis/atlantis/server/core/config/valid"
+ "github.com/runatlantis/atlantis/server/events/command"
"github.com/runatlantis/atlantis/server/events/matchers"
"github.com/runatlantis/atlantis/server/events/models"
vcsmocks "github.com/runatlantis/atlantis/server/events/vcs/mocks"
@@ -39,7 +40,7 @@ func TestBuildProjectCmdCtx(t *testing.T) {
globalCfg string
repoCfg string
expErr string
- expCtx models.ProjectCommandContext
+ expCtx command.ProjectContext
expPlanSteps []string
expApplySteps []string
}{
@@ -60,7 +61,7 @@ workflows:
steps:
- apply`,
repoCfg: "",
- expCtx: models.ProjectCommandContext{
+ expCtx: command.ProjectContext{
ApplyCmd: "atlantis apply -d project1 -w myworkspace",
BaseRepo: baseRepo,
EscapedCommentArgs: []string{`\f\l\a\g`},
@@ -113,7 +114,7 @@ projects:
when_modified: [../modules/**/*.tf]
terraform_version: v10.0
`,
- expCtx: models.ProjectCommandContext{
+ expCtx: command.ProjectContext{
ApplyCmd: "atlantis apply -d project1 -w myworkspace",
BaseRepo: baseRepo,
EscapedCommentArgs: []string{`\f\l\a\g`},
@@ -168,7 +169,7 @@ projects:
when_modified: [../modules/**/*.tf]
terraform_version: v10.0
`,
- expCtx: models.ProjectCommandContext{
+ expCtx: command.ProjectContext{
ApplyCmd: "atlantis apply -d project1 -w myworkspace",
BaseRepo: baseRepo,
EscapedCommentArgs: []string{`\f\l\a\g`},
@@ -231,7 +232,7 @@ projects:
when_modified: [../modules/**/*.tf]
terraform_version: v10.0
`,
- expCtx: models.ProjectCommandContext{
+ expCtx: command.ProjectContext{
ApplyCmd: "atlantis apply -d project1 -w myworkspace",
BaseRepo: baseRepo,
EscapedCommentArgs: []string{`\f\l\a\g`},
@@ -381,7 +382,7 @@ workflows:
steps:
- apply
`,
- expCtx: models.ProjectCommandContext{
+ expCtx: command.ProjectContext{
ApplyCmd: "atlantis apply -d project1 -w myworkspace",
BaseRepo: baseRepo,
EscapedCommentArgs: []string{`\f\l\a\g`},
@@ -440,7 +441,7 @@ projects:
terraform_version: v10.0
workflow: custom
`,
- expCtx: models.ProjectCommandContext{
+ expCtx: command.ProjectContext{
ApplyCmd: "atlantis apply -d project1 -w myworkspace",
BaseRepo: baseRepo,
EscapedCommentArgs: []string{`\f\l\a\g`},
@@ -502,7 +503,7 @@ workflows:
apply:
steps: []
`,
- expCtx: models.ProjectCommandContext{
+ expCtx: command.ProjectContext{
ApplyCmd: "atlantis apply -d project1 -w myworkspace",
BaseRepo: baseRepo,
EscapedCommentArgs: []string{`\f\l\a\g`},
@@ -548,7 +549,7 @@ projects:
- dir: project1
workspace: myworkspace
`,
- expCtx: models.ProjectCommandContext{
+ expCtx: command.ProjectContext{
ApplyCmd: "atlantis apply -d project1 -w myworkspace",
BaseRepo: baseRepo,
EscapedCommentArgs: []string{`\f\l\a\g`},
@@ -630,9 +631,9 @@ projects:
)
// We run a test for each type of command.
- for _, cmd := range []models.CommandName{models.PlanCommand, models.ApplyCommand} {
+ for _, cmd := range []command.Name{command.Plan, command.Apply} {
t.Run(cmd.String(), func(t *testing.T) {
- ctxs, err := builder.buildProjectCommandCtx(&CommandContext{
+ ctxs, err := builder.buildProjectCommandCtx(&command.Context{
Log: logger,
Scope: statsScope,
Pull: models.PullRequest{
@@ -654,9 +655,9 @@ projects:
// Construct expected steps.
var stepNames []string
switch cmd {
- case models.PlanCommand:
+ case command.Plan:
stepNames = c.expPlanSteps
- case models.ApplyCommand:
+ case command.Apply:
stepNames = c.expApplySteps
}
var expSteps []valid.Step
@@ -705,7 +706,7 @@ func TestBuildProjectCmdCtx_WithRegExpCmdEnabled(t *testing.T) {
globalCfg string
repoCfg string
expErr string
- expCtx models.ProjectCommandContext
+ expCtx command.ProjectContext
expPlanSteps []string
expApplySteps []string
}{
@@ -752,7 +753,7 @@ projects:
when_modified: [../modules/**/*.tf]
terraform_version: v10.0
`,
- expCtx: models.ProjectCommandContext{
+ expCtx: command.ProjectContext{
ApplyCmd: "atlantis apply -p myproject_1",
BaseRepo: baseRepo,
EscapedCommentArgs: []string{`\f\l\a\g`},
@@ -832,9 +833,9 @@ projects:
)
// We run a test for each type of command, again specific projects
- for _, cmd := range []models.CommandName{models.PlanCommand, models.ApplyCommand} {
+ for _, cmd := range []command.Name{command.Plan, command.Apply} {
t.Run(cmd.String(), func(t *testing.T) {
- ctxs, err := builder.buildProjectCommandCtx(&CommandContext{
+ ctxs, err := builder.buildProjectCommandCtx(&command.Context{
Pull: models.PullRequest{
BaseRepo: baseRepo,
},
@@ -857,9 +858,9 @@ projects:
// Construct expected steps.
var stepNames []string
switch cmd {
- case models.PlanCommand:
+ case command.Plan:
stepNames = c.expPlanSteps
- case models.ApplyCommand:
+ case command.Apply:
stepNames = c.expApplySteps
}
var expSteps []valid.Step
@@ -909,7 +910,7 @@ func TestBuildProjectCmdCtx_WithPolicCheckEnabled(t *testing.T) {
globalCfg string
repoCfg string
expErr string
- expCtx models.ProjectCommandContext
+ expCtx command.ProjectContext
expPolicyCheckSteps []string
}{
// Test that if we've set global defaults and no project config
@@ -920,7 +921,7 @@ repos:
- id: /.*/
`,
repoCfg: "",
- expCtx: models.ProjectCommandContext{
+ expCtx: command.ProjectContext{
ApplyCmd: "atlantis apply -d project1 -w myworkspace",
BaseRepo: baseRepo,
EscapedCommentArgs: []string{`\f\l\a\g`},
@@ -978,7 +979,7 @@ workflows:
steps:
- policy_check
`,
- expCtx: models.ProjectCommandContext{
+ expCtx: command.ProjectContext{
ApplyCmd: "atlantis apply -d project1 -w myworkspace",
BaseRepo: baseRepo,
EscapedCommentArgs: []string{`\f\l\a\g`},
@@ -1061,9 +1062,9 @@ workflows:
logger,
)
- cmd := models.PolicyCheckCommand
+ cmd := command.PolicyCheck
t.Run(cmd.String(), func(t *testing.T) {
- ctxs, err := builder.buildProjectCommandCtx(&CommandContext{
+ ctxs, err := builder.buildProjectCommandCtx(&command.Context{
Log: logger,
Scope: statsScope,
Pull: models.PullRequest{
@@ -1072,7 +1073,7 @@ workflows:
PullRequestStatus: models.PullReqStatus{
Mergeable: true,
},
- }, models.PlanCommand, "", []string{"flag"}, tmp, "project1", "myworkspace", true)
+ }, command.Plan, "", []string{"flag"}, tmp, "project1", "myworkspace", true)
if c.expErr != "" {
ErrEquals(t, c.expErr, err)
diff --git a/server/events/project_command_builder_test.go b/server/events/project_command_builder_test.go
index fe7b4d6c6..a28aa97b9 100644
--- a/server/events/project_command_builder_test.go
+++ b/server/events/project_command_builder_test.go
@@ -11,6 +11,7 @@ import (
"github.com/runatlantis/atlantis/server/core/config"
"github.com/runatlantis/atlantis/server/core/config/valid"
"github.com/runatlantis/atlantis/server/events"
+ "github.com/runatlantis/atlantis/server/events/command"
"github.com/runatlantis/atlantis/server/events/matchers"
"github.com/runatlantis/atlantis/server/events/mocks"
"github.com/runatlantis/atlantis/server/events/models"
@@ -162,7 +163,7 @@ projects:
logger,
)
- ctxs, err := builder.BuildAutoplanCommands(&events.CommandContext{
+ ctxs, err := builder.BuildAutoplanCommands(&command.Context{
PullRequestStatus: models.PullReqStatus{
Mergeable: true,
},
@@ -201,7 +202,7 @@ func TestDefaultProjectCommandBuilder_BuildSinglePlanApplyCommand(t *testing.T)
Cmd: events.CommentCommand{
RepoRelDir: ".",
Flags: []string{"commentarg"},
- Name: models.PlanCommand,
+ Name: command.Plan,
Workspace: "myworkspace",
},
AtlantisYAML: "",
@@ -214,7 +215,7 @@ func TestDefaultProjectCommandBuilder_BuildSinglePlanApplyCommand(t *testing.T)
Description: "no atlantis.yaml with project flag",
Cmd: events.CommentCommand{
RepoRelDir: ".",
- Name: models.PlanCommand,
+ Name: command.Plan,
ProjectName: "myproject",
},
AtlantisYAML: "",
@@ -224,7 +225,7 @@ func TestDefaultProjectCommandBuilder_BuildSinglePlanApplyCommand(t *testing.T)
Description: "simple atlantis.yaml",
Cmd: events.CommentCommand{
RepoRelDir: ".",
- Name: models.PlanCommand,
+ Name: command.Plan,
Workspace: "myworkspace",
},
AtlantisYAML: `
@@ -241,7 +242,7 @@ projects:
Description: "atlantis.yaml wrong dir",
Cmd: events.CommentCommand{
RepoRelDir: ".",
- Name: models.PlanCommand,
+ Name: command.Plan,
Workspace: "myworkspace",
},
AtlantisYAML: `
@@ -258,7 +259,7 @@ projects:
Description: "atlantis.yaml wrong workspace",
Cmd: events.CommentCommand{
RepoRelDir: ".",
- Name: models.PlanCommand,
+ Name: command.Plan,
Workspace: "myworkspace",
},
AtlantisYAML: `
@@ -272,7 +273,7 @@ projects:
{
Description: "atlantis.yaml with projectname",
Cmd: events.CommentCommand{
- Name: models.PlanCommand,
+ Name: command.Plan,
ProjectName: "myproject",
},
AtlantisYAML: `
@@ -290,7 +291,7 @@ projects:
{
Description: "atlantis.yaml with mergeable apply requirement",
Cmd: events.CommentCommand{
- Name: models.PlanCommand,
+ Name: command.Plan,
ProjectName: "myproject",
},
AtlantisYAML: `
@@ -308,7 +309,7 @@ projects:
{
Description: "atlantis.yaml with mergeable and approved apply requirements",
Cmd: events.CommentCommand{
- Name: models.PlanCommand,
+ Name: command.Plan,
ProjectName: "myproject",
},
AtlantisYAML: `
@@ -326,7 +327,7 @@ projects:
{
Description: "atlantis.yaml with multiple dir/workspaces matching",
Cmd: events.CommentCommand{
- Name: models.PlanCommand,
+ Name: command.Plan,
RepoRelDir: ".",
Workspace: "myworkspace",
},
@@ -346,7 +347,7 @@ projects:
{
Description: "atlantis.yaml with project flag not matching",
Cmd: events.CommentCommand{
- Name: models.PlanCommand,
+ Name: command.Plan,
RepoRelDir: ".",
Workspace: "default",
ProjectName: "notconfigured",
@@ -361,7 +362,7 @@ projects:
{
Description: "atlantis.yaml with ParallelPlan Set to true",
Cmd: events.CommentCommand{
- Name: models.PlanCommand,
+ Name: command.Plan,
RepoRelDir: ".",
Workspace: "default",
ProjectName: "myproject",
@@ -388,7 +389,7 @@ projects:
for _, c := range cases {
// NOTE: we're testing both plan and apply here.
- for _, cmdName := range []models.CommandName{models.PlanCommand, models.ApplyCommand} {
+ for _, cmdName := range []command.Name{command.Plan, command.Apply} {
t.Run(c.Description+"_"+cmdName.String(), func(t *testing.T) {
RegisterMockTestingT(t)
tmpDir, cleanup := DirStructure(t, map[string]interface{}{
@@ -430,15 +431,15 @@ projects:
logger,
)
- var actCtxs []models.ProjectCommandContext
+ var actCtxs []command.ProjectContext
var err error
- if cmdName == models.PlanCommand {
- actCtxs, err = builder.BuildPlanCommands(&events.CommandContext{
+ if cmdName == command.Plan {
+ actCtxs, err = builder.BuildPlanCommands(&command.Context{
Log: logger,
Scope: scope,
}, &c.Cmd)
} else {
- actCtxs, err = builder.BuildApplyCommands(&events.CommandContext{Log: logger, Scope: scope}, &c.Cmd)
+ actCtxs, err = builder.BuildApplyCommands(&command.Context{Log: logger, Scope: scope}, &c.Cmd)
}
if c.ExpErr != "" {
@@ -586,14 +587,14 @@ projects:
)
ctxs, err := builder.BuildPlanCommands(
- &events.CommandContext{
+ &command.Context{
Log: logger,
Scope: scope,
},
&events.CommentCommand{
RepoRelDir: "",
Flags: nil,
- Name: models.PlanCommand,
+ Name: command.Plan,
Verbose: false,
Workspace: "",
ProjectName: "",
@@ -677,14 +678,14 @@ func TestDefaultProjectCommandBuilder_BuildMultiApply(t *testing.T) {
)
ctxs, err := builder.BuildApplyCommands(
- &events.CommandContext{
+ &command.Context{
Log: logger,
Scope: scope,
},
&events.CommentCommand{
RepoRelDir: "",
Flags: nil,
- Name: models.ApplyCommand,
+ Name: command.Apply,
Verbose: false,
Workspace: "",
ProjectName: "",
@@ -761,7 +762,7 @@ projects:
logger,
)
- ctx := &events.CommandContext{
+ ctx := &command.Context{
HeadRepo: models.Repo{},
Pull: models.PullRequest{},
User: models.User{},
@@ -771,7 +772,7 @@ projects:
_, err = builder.BuildPlanCommands(ctx, &events.CommentCommand{
RepoRelDir: ".",
Flags: nil,
- Name: models.PlanCommand,
+ Name: command.Plan,
Verbose: false,
Workspace: "notconfigured",
ProjectName: "",
@@ -840,15 +841,15 @@ func TestDefaultProjectCommandBuilder_EscapeArgs(t *testing.T) {
logger,
)
- var actCtxs []models.ProjectCommandContext
+ var actCtxs []command.ProjectContext
var err error
- actCtxs, err = builder.BuildPlanCommands(&events.CommandContext{
+ actCtxs, err = builder.BuildPlanCommands(&command.Context{
Log: logger,
Scope: scope,
}, &events.CommentCommand{
RepoRelDir: ".",
Flags: c.ExtraArgs,
- Name: models.PlanCommand,
+ Name: command.Plan,
Verbose: false,
Workspace: "default",
})
@@ -1024,14 +1025,14 @@ projects:
)
actCtxs, err := builder.BuildPlanCommands(
- &events.CommandContext{
+ &command.Context{
Log: logger,
Scope: scope,
},
&events.CommentCommand{
RepoRelDir: "",
Flags: nil,
- Name: models.PlanCommand,
+ Name: command.Plan,
Verbose: false,
})
@@ -1090,9 +1091,9 @@ projects:
logger,
)
- var actCtxs []models.ProjectCommandContext
+ var actCtxs []command.ProjectContext
var err error
- actCtxs, err = builder.BuildAutoplanCommands(&events.CommandContext{
+ actCtxs, err = builder.BuildAutoplanCommands(&command.Context{
HeadRepo: models.Repo{},
Pull: models.PullRequest{},
User: models.User{},
@@ -1148,7 +1149,7 @@ func TestDefaultProjectCommandBuilder_WithPolicyCheckEnabled_BuildAutoplanComman
logger,
)
- ctxs, err := builder.BuildAutoplanCommands(&events.CommandContext{
+ ctxs, err := builder.BuildAutoplanCommands(&command.Context{
PullRequestStatus: models.PullReqStatus{
Mergeable: true,
},
@@ -1160,9 +1161,9 @@ func TestDefaultProjectCommandBuilder_WithPolicyCheckEnabled_BuildAutoplanComman
Equals(t, 2, len(ctxs))
planCtx := ctxs[0]
policyCheckCtx := ctxs[1]
- Equals(t, models.PlanCommand, planCtx.CommandName)
+ Equals(t, command.Plan, planCtx.CommandName)
Equals(t, globalCfg.Workflows["default"].Plan.Steps, planCtx.Steps)
- Equals(t, models.PolicyCheckCommand, policyCheckCtx.CommandName)
+ Equals(t, command.PolicyCheck, policyCheckCtx.CommandName)
Equals(t, globalCfg.Workflows["default"].PolicyCheck.Steps, policyCheckCtx.Steps)
}
@@ -1231,14 +1232,14 @@ func TestDefaultProjectCommandBuilder_BuildVersionCommand(t *testing.T) {
)
ctxs, err := builder.BuildVersionCommands(
- &events.CommandContext{
+ &command.Context{
Log: logger,
Scope: scope,
},
&events.CommentCommand{
RepoRelDir: "",
Flags: nil,
- Name: models.VersionCommand,
+ Name: command.Version,
Verbose: false,
Workspace: "",
ProjectName: "",
diff --git a/server/events/project_command_context_builder.go b/server/events/project_command_context_builder.go
index 08299f353..ac6323dd2 100644
--- a/server/events/project_command_context_builder.go
+++ b/server/events/project_command_context_builder.go
@@ -8,6 +8,7 @@ import (
"github.com/hashicorp/go-version"
"github.com/hashicorp/terraform-config-inspect/tfconfig"
"github.com/runatlantis/atlantis/server/core/config/valid"
+ "github.com/runatlantis/atlantis/server/events/command"
"github.com/runatlantis/atlantis/server/events/models"
"github.com/uber-go/tally"
)
@@ -33,13 +34,13 @@ func NewProjectCommandContextBuilder(policyCheckEnabled bool, commentBuilder Com
type ProjectCommandContextBuilder interface {
// BuildProjectContext builds project command contexts for atlantis commands
BuildProjectContext(
- ctx *CommandContext,
- cmdName models.CommandName,
+ ctx *command.Context,
+ cmdName command.Name,
prjCfg valid.MergedProjectCfg,
commentFlags []string,
repoDir string,
automerge, deleteSourceBranchOnMerge, parallelApply, parallelPlan, verbose bool,
- ) []models.ProjectCommandContext
+ ) []command.ProjectContext
}
// CommandScopedStatsProjectCommandContextBuilder ensures that project command context contains a scoped stats
@@ -52,20 +53,20 @@ type CommandScopedStatsProjectCommandContextBuilder struct {
// BuildProjectContext builds the context and injects the appropriate command level scope after the fact.
func (cb *CommandScopedStatsProjectCommandContextBuilder) BuildProjectContext(
- ctx *CommandContext,
- cmdName models.CommandName,
+ ctx *command.Context,
+ cmdName command.Name,
prjCfg valid.MergedProjectCfg,
commentFlags []string,
repoDir string,
automerge, deleteSourceBranchOnMerge, parallelApply, parallelPlan, verbose bool,
-) (projectCmds []models.ProjectCommandContext) {
+) (projectCmds []command.ProjectContext) {
cb.ProjectCounter.Inc(1)
cmds := cb.ProjectCommandContextBuilder.BuildProjectContext(
ctx, cmdName, prjCfg, commentFlags, repoDir, automerge, deleteSourceBranchOnMerge, parallelApply, parallelPlan, verbose,
)
- projectCmds = []models.ProjectCommandContext{}
+ projectCmds = []command.ProjectContext{}
for _, cmd := range cmds {
@@ -84,22 +85,22 @@ type DefaultProjectCommandContextBuilder struct {
}
func (cb *DefaultProjectCommandContextBuilder) BuildProjectContext(
- ctx *CommandContext,
- cmdName models.CommandName,
+ ctx *command.Context,
+ cmdName command.Name,
prjCfg valid.MergedProjectCfg,
commentFlags []string,
repoDir string,
automerge, deleteSourceBranchOnMerge, parallelApply, parallelPlan, verbose bool,
-) (projectCmds []models.ProjectCommandContext) {
+) (projectCmds []command.ProjectContext) {
ctx.Log.Debug("Building project command context for %s", cmdName)
var steps []valid.Step
switch cmdName {
- case models.PlanCommand:
+ case command.Plan:
steps = prjCfg.Workflow.Plan.Steps
- case models.ApplyCommand:
+ case command.Apply:
steps = prjCfg.Workflow.Apply.Steps
- case models.VersionCommand:
+ case command.Version:
// Setting statically since there will only be one step
steps = []valid.Step{{
StepName: "version",
@@ -142,13 +143,13 @@ type PolicyCheckProjectCommandContextBuilder struct {
}
func (cb *PolicyCheckProjectCommandContextBuilder) BuildProjectContext(
- ctx *CommandContext,
- cmdName models.CommandName,
+ ctx *command.Context,
+ cmdName command.Name,
prjCfg valid.MergedProjectCfg,
commentFlags []string,
repoDir string,
automerge, deleteSourceBranchOnMerge, parallelApply, parallelPlan, verbose bool,
-) (projectCmds []models.ProjectCommandContext) {
+) (projectCmds []command.ProjectContext) {
ctx.Log.Debug("PolicyChecks are enabled")
// If TerraformVersion not defined in config file look for a
@@ -170,13 +171,13 @@ func (cb *PolicyCheckProjectCommandContextBuilder) BuildProjectContext(
verbose,
)
- if cmdName == models.PlanCommand {
- ctx.Log.Debug("Building project command context for %s", models.PolicyCheckCommand)
+ if cmdName == command.Plan {
+ ctx.Log.Debug("Building project command context for %s", command.PolicyCheck)
steps := prjCfg.Workflow.PolicyCheck.Steps
projectCmds = append(projectCmds, newProjectCommandContext(
ctx,
- models.PolicyCheckCommand,
+ command.PolicyCheck,
cb.CommentBuilder.BuildApplyComment(prjCfg.RepoRelDir, prjCfg.Workspace, prjCfg.Name, prjCfg.AutoMergeDisabled),
cb.CommentBuilder.BuildPlanComment(prjCfg.RepoRelDir, prjCfg.Workspace, prjCfg.Name, commentFlags),
cb.CommentBuilder.BuildVersionComment(prjCfg.RepoRelDir, prjCfg.Workspace, prjCfg.Name),
@@ -199,8 +200,8 @@ func (cb *PolicyCheckProjectCommandContextBuilder) BuildProjectContext(
// newProjectCommandContext is a initializer method that handles constructing the
// ProjectCommandContext.
-func newProjectCommandContext(ctx *CommandContext,
- cmd models.CommandName,
+func newProjectCommandContext(ctx *command.Context,
+ cmd command.Name,
applyCmd string,
planCmd string,
versionCmd string,
@@ -215,7 +216,7 @@ func newProjectCommandContext(ctx *CommandContext,
verbose bool,
scope tally.Scope,
pullStatus models.PullReqStatus,
-) models.ProjectCommandContext {
+) command.ProjectContext {
var projectPlanStatus models.ProjectPlanStatus
@@ -235,7 +236,7 @@ func newProjectCommandContext(ctx *CommandContext,
}
}
- return models.ProjectCommandContext{
+ return command.ProjectContext{
CommandName: cmd,
ApplyCmd: applyCmd,
BaseRepo: ctx.Pull.BaseRepo,
@@ -281,7 +282,7 @@ func escapeArgs(args []string) []string {
// Extracts required_version from Terraform configuration.
// Returns nil if unable to determine version from configuration.
-func getTfVersion(ctx *CommandContext, absProjDir string) *version.Version {
+func getTfVersion(ctx *command.Context, absProjDir string) *version.Version {
module, diags := tfconfig.LoadModule(absProjDir)
if diags.HasErrors() {
ctx.Log.Err("trying to detect required version: %s", diags.Error())
diff --git a/server/events/project_command_context_builder_test.go b/server/events/project_command_context_builder_test.go
index 50c5dced5..8f3c78727 100644
--- a/server/events/project_command_context_builder_test.go
+++ b/server/events/project_command_context_builder_test.go
@@ -6,6 +6,7 @@ import (
. "github.com/petergtz/pegomock"
"github.com/runatlantis/atlantis/server/core/config/valid"
"github.com/runatlantis/atlantis/server/events"
+ "github.com/runatlantis/atlantis/server/events/command"
"github.com/runatlantis/atlantis/server/events/mocks"
"github.com/runatlantis/atlantis/server/events/models"
"github.com/runatlantis/atlantis/server/logging"
@@ -37,7 +38,7 @@ func TestProjectCommandContextBuilder_PullStatus(t *testing.T) {
Projects: []models.ProjectStatus{},
}
- commandCtx := &events.CommandContext{
+ commandCtx := &command.Context{
Log: logging.NewNoopLogger(t),
PullStatus: pullStatus,
}
@@ -57,8 +58,7 @@ func TestProjectCommandContextBuilder_PullStatus(t *testing.T) {
},
}
- result := subject.BuildProjectContext(commandCtx, models.PlanCommand, projCfg, []string{}, "some/dir", false, false, false, false, false)
-
+ result := subject.BuildProjectContext(commandCtx, command.Plan, projCfg, []string{}, "some/dir", false, false, false, false, false)
assert.Equal(t, models.ErroredPolicyCheckStatus, result[0].ProjectPlanStatus)
})
@@ -77,7 +77,7 @@ func TestProjectCommandContextBuilder_PullStatus(t *testing.T) {
},
}
- result := subject.BuildProjectContext(commandCtx, models.PlanCommand, projCfg, []string{}, "some/dir", false, false, false, false, false)
+ result := subject.BuildProjectContext(commandCtx, command.Plan, projCfg, []string{}, "some/dir", false, false, false, false, false)
assert.Equal(t, models.ErroredPolicyCheckStatus, result[0].ProjectPlanStatus)
})
@@ -97,7 +97,7 @@ func TestProjectCommandContextBuilder_PullStatus(t *testing.T) {
},
}
- result := subject.BuildProjectContext(commandCtx, models.PlanCommand, projCfg, []string{}, "some/dir", false, false, true, false, false)
+ result := subject.BuildProjectContext(commandCtx, command.Plan, projCfg, []string{}, "some/dir", false, false, true, false, false)
assert.True(t, result[0].ParallelApplyEnabled)
assert.False(t, result[0].ParallelPlanEnabled)
diff --git a/server/events/project_command_pool_executor.go b/server/events/project_command_pool_executor.go
index 1c1eb2484..75fa38214 100644
--- a/server/events/project_command_pool_executor.go
+++ b/server/events/project_command_pool_executor.go
@@ -4,17 +4,17 @@ import (
"sync"
"github.com/remeh/sizedwaitgroup"
- "github.com/runatlantis/atlantis/server/events/models"
+ "github.com/runatlantis/atlantis/server/events/command"
)
-type prjCmdRunnerFunc func(ctx models.ProjectCommandContext) models.ProjectResult
+type prjCmdRunnerFunc func(ctx command.ProjectContext) command.ProjectResult
func runProjectCmdsParallel(
- cmds []models.ProjectCommandContext,
+ cmds []command.ProjectContext,
runnerFunc prjCmdRunnerFunc,
poolSize int,
-) CommandResult {
- var results []models.ProjectResult
+) command.Result {
+ var results []command.ProjectResult
mux := &sync.Mutex{}
wg := sizedwaitgroup.New(poolSize)
@@ -35,18 +35,18 @@ func runProjectCmdsParallel(
}
wg.Wait()
- return CommandResult{ProjectResults: results}
+ return command.Result{ProjectResults: results}
}
func runProjectCmds(
- cmds []models.ProjectCommandContext,
+ cmds []command.ProjectContext,
runnerFunc prjCmdRunnerFunc,
-) CommandResult {
- var results []models.ProjectResult
+) command.Result {
+ var results []command.ProjectResult
for _, pCmd := range cmds {
res := runnerFunc(pCmd)
results = append(results, res)
}
- return CommandResult{ProjectResults: results}
+ return command.Result{ProjectResults: results}
}
diff --git a/server/events/project_command_runner.go b/server/events/project_command_runner.go
index 84e0f7929..82debf548 100644
--- a/server/events/project_command_runner.go
+++ b/server/events/project_command_runner.go
@@ -22,6 +22,7 @@ import (
"github.com/pkg/errors"
"github.com/runatlantis/atlantis/server/core/config/valid"
"github.com/runatlantis/atlantis/server/core/runtime"
+ "github.com/runatlantis/atlantis/server/events/command"
"github.com/runatlantis/atlantis/server/events/models"
"github.com/runatlantis/atlantis/server/events/webhooks"
"github.com/runatlantis/atlantis/server/logging"
@@ -53,7 +54,7 @@ type LockURLGenerator interface {
// `terraform plan`.
type StepRunner interface {
// Run runs the step.
- Run(ctx models.ProjectCommandContext, extraArgs []string, path string, envs map[string]string) (string, error)
+ Run(ctx command.ProjectContext, extraArgs []string, path string, envs map[string]string) (string, error)
}
//go:generate pegomock generate -m --use-experimental-model-gen --package mocks -o mocks/mock_custom_step_runner.go CustomStepRunner
@@ -61,14 +62,14 @@ type StepRunner interface {
// CustomStepRunner runs custom run steps.
type CustomStepRunner interface {
// Run cmd in path.
- Run(ctx models.ProjectCommandContext, cmd string, path string, envs map[string]string) (string, error)
+ Run(ctx command.ProjectContext, cmd string, path string, envs map[string]string) (string, error)
}
//go:generate pegomock generate -m --use-experimental-model-gen --package mocks -o mocks/mock_env_step_runner.go EnvStepRunner
// EnvStepRunner runs env steps.
type EnvStepRunner interface {
- Run(ctx models.ProjectCommandContext, cmd string, value string, path string, envs map[string]string) (string, error)
+ Run(ctx command.ProjectContext, cmd string, value string, path string, envs map[string]string) (string, error)
}
//go:generate pegomock generate -m --use-experimental-model-gen --package mocks -o mocks/mock_webhooks_sender.go WebhooksSender
@@ -83,27 +84,27 @@ type WebhooksSender interface {
type ProjectPlanCommandRunner interface {
// Plan runs terraform plan for the project described by ctx.
- Plan(ctx models.ProjectCommandContext) models.ProjectResult
+ Plan(ctx command.ProjectContext) command.ProjectResult
}
type ProjectApplyCommandRunner interface {
// Apply runs terraform apply for the project described by ctx.
- Apply(ctx models.ProjectCommandContext) models.ProjectResult
+ Apply(ctx command.ProjectContext) command.ProjectResult
}
type ProjectPolicyCheckCommandRunner interface {
// PolicyCheck runs OPA defined policies for the project desribed by ctx.
- PolicyCheck(ctx models.ProjectCommandContext) models.ProjectResult
+ PolicyCheck(ctx command.ProjectContext) command.ProjectResult
}
type ProjectApprovePoliciesCommandRunner interface {
// Approves any failing OPA policies.
- ApprovePolicies(ctx models.ProjectCommandContext) models.ProjectResult
+ ApprovePolicies(ctx command.ProjectContext) command.ProjectResult
}
type ProjectVersionCommandRunner interface {
// Version runs terraform version for the project described by ctx.
- Version(ctx models.ProjectCommandContext) models.ProjectResult
+ Version(ctx command.ProjectContext) command.ProjectResult
}
// ProjectCommandRunner runs project commands. A project command is a command
@@ -121,13 +122,13 @@ type ProjectCommandRunner interface {
type JobURLSetter interface {
// SetJobURLWithStatus sets the commit status for the project represented by
// ctx and updates the status with and url to a job.
- SetJobURLWithStatus(ctx models.ProjectCommandContext, cmdName models.CommandName, status models.CommitStatus) error
+ SetJobURLWithStatus(ctx command.ProjectContext, cmdName command.Name, status models.CommitStatus) error
}
//go:generate pegomock generate -m --use-experimental-model-gen --package mocks -o mocks/mock_job_message_sender.go JobMessageSender
type JobMessageSender interface {
- Send(ctx models.ProjectCommandContext, msg string, operationComplete bool)
+ Send(ctx command.ProjectContext, msg string, operationComplete bool)
}
// ProjectOutputWrapper is a decorator that creates a new PR status check per project.
@@ -138,19 +139,19 @@ type ProjectOutputWrapper struct {
JobURLSetter JobURLSetter
}
-func (p *ProjectOutputWrapper) Plan(ctx models.ProjectCommandContext) models.ProjectResult {
- result := p.updateProjectPRStatus(models.PlanCommand, ctx, p.ProjectCommandRunner.Plan)
+func (p *ProjectOutputWrapper) Plan(ctx command.ProjectContext) command.ProjectResult {
+ result := p.updateProjectPRStatus(command.Plan, ctx, p.ProjectCommandRunner.Plan)
p.JobMessageSender.Send(ctx, "", OperationComplete)
return result
}
-func (p *ProjectOutputWrapper) Apply(ctx models.ProjectCommandContext) models.ProjectResult {
- result := p.updateProjectPRStatus(models.ApplyCommand, ctx, p.ProjectCommandRunner.Apply)
+func (p *ProjectOutputWrapper) Apply(ctx command.ProjectContext) command.ProjectResult {
+ result := p.updateProjectPRStatus(command.Apply, ctx, p.ProjectCommandRunner.Apply)
p.JobMessageSender.Send(ctx, "", OperationComplete)
return result
}
-func (p *ProjectOutputWrapper) updateProjectPRStatus(commandName models.CommandName, ctx models.ProjectCommandContext, execute func(ctx models.ProjectCommandContext) models.ProjectResult) models.ProjectResult {
+func (p *ProjectOutputWrapper) updateProjectPRStatus(commandName command.Name, ctx command.ProjectContext, execute func(ctx command.ProjectContext) command.ProjectResult) command.ProjectResult {
// Create a PR status to track project's plan status. The status will
// include a link to view the progress of atlantis plan command in real
// time
@@ -196,10 +197,10 @@ type DefaultProjectCommandRunner struct {
}
// Plan runs terraform plan for the project described by ctx.
-func (p *DefaultProjectCommandRunner) Plan(ctx models.ProjectCommandContext) models.ProjectResult {
+func (p *DefaultProjectCommandRunner) Plan(ctx command.ProjectContext) command.ProjectResult {
planSuccess, failure, err := p.doPlan(ctx)
- return models.ProjectResult{
- Command: models.PlanCommand,
+ return command.ProjectResult{
+ Command: command.Plan,
PlanSuccess: planSuccess,
Error: err,
Failure: failure,
@@ -210,10 +211,10 @@ func (p *DefaultProjectCommandRunner) Plan(ctx models.ProjectCommandContext) mod
}
// PolicyCheck evaluates policies defined with Rego for the project described by ctx.
-func (p *DefaultProjectCommandRunner) PolicyCheck(ctx models.ProjectCommandContext) models.ProjectResult {
+func (p *DefaultProjectCommandRunner) PolicyCheck(ctx command.ProjectContext) command.ProjectResult {
policySuccess, failure, err := p.doPolicyCheck(ctx)
- return models.ProjectResult{
- Command: models.PolicyCheckCommand,
+ return command.ProjectResult{
+ Command: command.PolicyCheck,
PolicyCheckSuccess: policySuccess,
Error: err,
Failure: failure,
@@ -224,10 +225,10 @@ func (p *DefaultProjectCommandRunner) PolicyCheck(ctx models.ProjectCommandConte
}
// Apply runs terraform apply for the project described by ctx.
-func (p *DefaultProjectCommandRunner) Apply(ctx models.ProjectCommandContext) models.ProjectResult {
+func (p *DefaultProjectCommandRunner) Apply(ctx command.ProjectContext) command.ProjectResult {
applyOut, failure, err := p.doApply(ctx)
- return models.ProjectResult{
- Command: models.ApplyCommand,
+ return command.ProjectResult{
+ Command: command.Apply,
Failure: failure,
Error: err,
ApplySuccess: applyOut,
@@ -237,10 +238,10 @@ func (p *DefaultProjectCommandRunner) Apply(ctx models.ProjectCommandContext) mo
}
}
-func (p *DefaultProjectCommandRunner) ApprovePolicies(ctx models.ProjectCommandContext) models.ProjectResult {
+func (p *DefaultProjectCommandRunner) ApprovePolicies(ctx command.ProjectContext) command.ProjectResult {
approvedOut, failure, err := p.doApprovePolicies(ctx)
- return models.ProjectResult{
- Command: models.PolicyCheckCommand,
+ return command.ProjectResult{
+ Command: command.PolicyCheck,
Failure: failure,
Error: err,
PolicyCheckSuccess: approvedOut,
@@ -250,10 +251,10 @@ func (p *DefaultProjectCommandRunner) ApprovePolicies(ctx models.ProjectCommandC
}
}
-func (p *DefaultProjectCommandRunner) Version(ctx models.ProjectCommandContext) models.ProjectResult {
+func (p *DefaultProjectCommandRunner) Version(ctx command.ProjectContext) command.ProjectResult {
versionOut, failure, err := p.doVersion(ctx)
- return models.ProjectResult{
- Command: models.VersionCommand,
+ return command.ProjectResult{
+ Command: command.Version,
Failure: failure,
Error: err,
VersionSuccess: versionOut,
@@ -263,7 +264,7 @@ func (p *DefaultProjectCommandRunner) Version(ctx models.ProjectCommandContext)
}
}
-func (p *DefaultProjectCommandRunner) doApprovePolicies(ctx models.ProjectCommandContext) (*models.PolicyCheckSuccess, string, error) {
+func (p *DefaultProjectCommandRunner) doApprovePolicies(ctx command.ProjectContext) (*models.PolicyCheckSuccess, string, error) {
// TODO: Make this a bit smarter
// without checking some sort of state that the policy check has indeed passed this is likely to cause issues
@@ -273,7 +274,7 @@ func (p *DefaultProjectCommandRunner) doApprovePolicies(ctx models.ProjectComman
}, "", nil
}
-func (p *DefaultProjectCommandRunner) doPolicyCheck(ctx models.ProjectCommandContext) (*models.PolicyCheckSuccess, string, error) {
+func (p *DefaultProjectCommandRunner) doPolicyCheck(ctx command.ProjectContext) (*models.PolicyCheckSuccess, string, error) {
// Acquire Atlantis lock for this repo/dir/workspace.
// This should already be acquired from the prior plan operation.
// if for some reason an unlock happens between the plan and policy check step
@@ -344,7 +345,7 @@ func (p *DefaultProjectCommandRunner) doPolicyCheck(ctx models.ProjectCommandCon
}, "", nil
}
-func (p *DefaultProjectCommandRunner) doPlan(ctx models.ProjectCommandContext) (*models.PlanSuccess, string, error) {
+func (p *DefaultProjectCommandRunner) doPlan(ctx command.ProjectContext) (*models.PlanSuccess, string, error) {
// Acquire Atlantis lock for this repo/dir/workspace.
lockAttempt, err := p.Locker.TryLock(ctx.Log, ctx.Pull, ctx.User, ctx.Workspace, models.NewProject(ctx.Pull.BaseRepo.FullName, ctx.RepoRelDir))
if err != nil {
@@ -393,7 +394,7 @@ func (p *DefaultProjectCommandRunner) doPlan(ctx models.ProjectCommandContext) (
}, "", nil
}
-func (p *DefaultProjectCommandRunner) doApply(ctx models.ProjectCommandContext) (applyOut string, failure string, err error) {
+func (p *DefaultProjectCommandRunner) doApply(ctx command.ProjectContext) (applyOut string, failure string, err error) {
repoDir, err := p.WorkingDir.GetWorkingDir(ctx.Pull.BaseRepo, ctx.Pull, ctx.Workspace)
if err != nil {
if os.IsNotExist(err) {
@@ -436,7 +437,7 @@ func (p *DefaultProjectCommandRunner) doApply(ctx models.ProjectCommandContext)
return strings.Join(outputs, "\n"), "", nil
}
-func (p *DefaultProjectCommandRunner) doVersion(ctx models.ProjectCommandContext) (versionOut string, failure string, err error) {
+func (p *DefaultProjectCommandRunner) doVersion(ctx command.ProjectContext) (versionOut string, failure string, err error) {
repoDir, err := p.WorkingDir.GetWorkingDir(ctx.Pull.BaseRepo, ctx.Pull, ctx.Workspace)
if err != nil {
if os.IsNotExist(err) {
@@ -464,7 +465,7 @@ func (p *DefaultProjectCommandRunner) doVersion(ctx models.ProjectCommandContext
return strings.Join(outputs, "\n"), "", nil
}
-func (p *DefaultProjectCommandRunner) runSteps(steps []valid.Step, ctx models.ProjectCommandContext, absPath string) ([]string, error) {
+func (p *DefaultProjectCommandRunner) runSteps(steps []valid.Step, ctx command.ProjectContext, absPath string) ([]string, error) {
var outputs []string
envs := make(map[string]string)
diff --git a/server/events/project_command_runner_test.go b/server/events/project_command_runner_test.go
index 5b964c2ea..d05758184 100644
--- a/server/events/project_command_runner_test.go
+++ b/server/events/project_command_runner_test.go
@@ -25,6 +25,7 @@ import (
"github.com/runatlantis/atlantis/server/core/runtime"
tmocks "github.com/runatlantis/atlantis/server/core/terraform/mocks"
"github.com/runatlantis/atlantis/server/events"
+ "github.com/runatlantis/atlantis/server/events/command"
"github.com/runatlantis/atlantis/server/events/mocks"
eventmocks "github.com/runatlantis/atlantis/server/events/mocks"
"github.com/runatlantis/atlantis/server/events/mocks/matchers"
@@ -82,7 +83,7 @@ func TestDefaultProjectCommandRunner_Plan(t *testing.T) {
expEnvs := map[string]string{
"name": "value",
}
- ctx := models.ProjectCommandContext{
+ ctx := command.ProjectContext{
Log: logging.NewNoopLogger(t),
Steps: []valid.Step{
{
@@ -133,7 +134,7 @@ func TestDefaultProjectCommandRunner_Plan(t *testing.T) {
func TestProjectOutputWrapper(t *testing.T) {
RegisterMockTestingT(t)
- ctx := models.ProjectCommandContext{
+ ctx := command.ProjectContext{
Log: logging.NewNoopLogger(t),
Steps: []valid.Step{
{
@@ -149,43 +150,43 @@ func TestProjectOutputWrapper(t *testing.T) {
Failure bool
Error bool
Success bool
- CommandName models.CommandName
+ CommandName command.Name
}{
{
Description: "plan success",
Success: true,
- CommandName: models.PlanCommand,
+ CommandName: command.Plan,
},
{
Description: "plan failure",
Failure: true,
- CommandName: models.PlanCommand,
+ CommandName: command.Plan,
},
{
Description: "plan error",
Error: true,
- CommandName: models.PlanCommand,
+ CommandName: command.Plan,
},
{
Description: "apply success",
Success: true,
- CommandName: models.ApplyCommand,
+ CommandName: command.Apply,
},
{
Description: "apply failure",
Failure: true,
- CommandName: models.ApplyCommand,
+ CommandName: command.Apply,
},
{
Description: "apply error",
Error: true,
- CommandName: models.ApplyCommand,
+ CommandName: command.Apply,
},
}
for _, c := range cases {
t.Run(c.Description, func(t *testing.T) {
- var prjResult models.ProjectResult
+ var prjResult command.ProjectResult
var expCommitStatus models.CommitStatus
mockJobURLSetter := eventmocks.NewMockJobURLSetter()
@@ -199,18 +200,18 @@ func TestProjectOutputWrapper(t *testing.T) {
}
if c.Success {
- prjResult = models.ProjectResult{
+ prjResult = command.ProjectResult{
PlanSuccess: &models.PlanSuccess{},
ApplySuccess: "exists",
}
expCommitStatus = models.SuccessCommitStatus
} else if c.Failure {
- prjResult = models.ProjectResult{
+ prjResult = command.ProjectResult{
Failure: "failure",
}
expCommitStatus = models.FailedCommitStatus
} else if c.Error {
- prjResult = models.ProjectResult{
+ prjResult = command.ProjectResult{
Error: errors.New("error"),
}
expCommitStatus = models.FailedCommitStatus
@@ -220,9 +221,9 @@ func TestProjectOutputWrapper(t *testing.T) {
When(mockProjectCommandRunner.Apply(matchers.AnyModelsProjectCommandContext())).ThenReturn(prjResult)
switch c.CommandName {
- case models.PlanCommand:
+ case command.Plan:
runner.Plan(ctx)
- case models.ApplyCommand:
+ case command.Apply:
runner.Apply(ctx)
}
@@ -230,9 +231,9 @@ func TestProjectOutputWrapper(t *testing.T) {
mockJobURLSetter.VerifyWasCalled(Once()).SetJobURLWithStatus(ctx, c.CommandName, expCommitStatus)
switch c.CommandName {
- case models.PlanCommand:
+ case command.Plan:
mockProjectCommandRunner.VerifyWasCalledOnce().Plan(ctx)
- case models.ApplyCommand:
+ case command.Apply:
mockProjectCommandRunner.VerifyWasCalledOnce().Apply(ctx)
}
})
@@ -246,7 +247,7 @@ func TestDefaultProjectCommandRunner_ApplyNotCloned(t *testing.T) {
runner := &events.DefaultProjectCommandRunner{
WorkingDir: mockWorkingDir,
}
- ctx := models.ProjectCommandContext{}
+ ctx := command.ProjectContext{}
When(mockWorkingDir.GetWorkingDir(ctx.BaseRepo, ctx.Pull, ctx.Workspace)).ThenReturn("", os.ErrNotExist)
res := runner.Apply(ctx)
@@ -264,7 +265,7 @@ func TestDefaultProjectCommandRunner_ApplyNotApproved(t *testing.T) {
WorkingDir: mockWorkingDir,
},
}
- ctx := models.ProjectCommandContext{
+ ctx := command.ProjectContext{
ApplyRequirements: []string{"approved"},
}
tmp, cleanup := TempDir(t)
@@ -286,7 +287,7 @@ func TestDefaultProjectCommandRunner_ApplyNotMergeable(t *testing.T) {
WorkingDir: mockWorkingDir,
},
}
- ctx := models.ProjectCommandContext{
+ ctx := command.ProjectContext{
PullReqStatus: models.PullReqStatus{
Mergeable: false,
},
@@ -311,7 +312,7 @@ func TestDefaultProjectCommandRunner_ApplyDiverged(t *testing.T) {
WorkingDir: mockWorkingDir,
},
}
- ctx := models.ProjectCommandContext{
+ ctx := command.ProjectContext{
ApplyRequirements: []string{"undiverged"},
}
tmp, cleanup := TempDir(t)
@@ -437,7 +438,7 @@ func TestDefaultProjectCommandRunner_Apply(t *testing.T) {
AnyString(),
)).ThenReturn(repoDir, nil)
- ctx := models.ProjectCommandContext{
+ ctx := command.ProjectContext{
Log: logging.NewNoopLogger(t),
Steps: c.steps,
Workspace: "default",
@@ -509,7 +510,7 @@ func TestDefaultProjectCommandRunner_ApplyRunStepFailure(t *testing.T) {
AnyString(),
)).ThenReturn(repoDir, nil)
- ctx := models.ProjectCommandContext{
+ ctx := command.ProjectContext{
Log: logging.NewNoopLogger(t),
Steps: []valid.Step{
{
@@ -575,7 +576,7 @@ func TestDefaultProjectCommandRunner_RunEnvSteps(t *testing.T) {
LockKey: "lock-key",
}, nil)
- ctx := models.ProjectCommandContext{
+ ctx := command.ProjectContext{
Log: logging.NewNoopLogger(t),
Steps: []valid.Step{
{
diff --git a/server/events/pull_closed_executor_test.go b/server/events/pull_closed_executor_test.go
index 0941c1f1b..2c0f43ac7 100644
--- a/server/events/pull_closed_executor_test.go
+++ b/server/events/pull_closed_executor_test.go
@@ -26,6 +26,7 @@ import (
. "github.com/petergtz/pegomock"
lockmocks "github.com/runatlantis/atlantis/server/core/locking/mocks"
"github.com/runatlantis/atlantis/server/events"
+ "github.com/runatlantis/atlantis/server/events/command"
"github.com/runatlantis/atlantis/server/events/mocks"
"github.com/runatlantis/atlantis/server/events/mocks/matchers"
"github.com/runatlantis/atlantis/server/events/models"
@@ -197,7 +198,7 @@ func TestCleanUpLogStreaming(t *testing.T) {
// Create Log streaming resources
prjCmdOutput := make(chan *jobs.ProjectCmdOutputLine)
prjCmdOutHandler := jobs.NewAsyncProjectCommandOutputHandler(prjCmdOutput, logger)
- ctx := models.ProjectCommandContext{
+ ctx := command.ProjectContext{
BaseRepo: fixtures.GithubRepo,
Pull: fixtures.Pull,
ProjectName: *fixtures.Project.Name,
@@ -233,7 +234,7 @@ func TestCleanUpLogStreaming(t *testing.T) {
panic(errors.Wrap(err, "could not create bucket"))
}
db, _ := db.NewWithDB(boltDB, lockBucket, configBucket)
- result := []models.ProjectResult{
+ result := []command.ProjectResult{
{
RepoRelDir: fixtures.GithubRepo.FullName,
Workspace: "default",
diff --git a/server/events/pull_updater.go b/server/events/pull_updater.go
index 3cc69f310..3c8355097 100644
--- a/server/events/pull_updater.go
+++ b/server/events/pull_updater.go
@@ -1,6 +1,9 @@
package events
-import "github.com/runatlantis/atlantis/server/events/vcs"
+import (
+ "github.com/runatlantis/atlantis/server/events/command"
+ "github.com/runatlantis/atlantis/server/events/vcs"
+)
type PullUpdater struct {
HidePrevPlanComments bool
@@ -8,7 +11,7 @@ type PullUpdater struct {
MarkdownRenderer *MarkdownRenderer
}
-func (c *PullUpdater) updatePull(ctx *CommandContext, command PullCommand, res CommandResult) {
+func (c *PullUpdater) updatePull(ctx *command.Context, cmd PullCommand, res command.Result) {
// Log if we got any errors or failures.
if res.Error != nil {
ctx.Log.Err(res.Error.Error())
@@ -20,13 +23,13 @@ func (c *PullUpdater) updatePull(ctx *CommandContext, command PullCommand, res C
// clutter in a pull/merge request. This will not delete the comment, since the
// comment trail may be useful in auditing or backtracing problems.
if c.HidePrevPlanComments {
- if err := c.VCSClient.HidePrevCommandComments(ctx.Pull.BaseRepo, ctx.Pull.Num, command.CommandName().TitleString()); err != nil {
+ if err := c.VCSClient.HidePrevCommandComments(ctx.Pull.BaseRepo, ctx.Pull.Num, cmd.CommandName().TitleString()); err != nil {
ctx.Log.Err("unable to hide old comments: %s", err)
}
}
- comment := c.MarkdownRenderer.Render(res, command.CommandName(), ctx.Log.GetHistory(), command.IsVerbose(), ctx.Pull.BaseRepo.VCSHost.Type)
- if err := c.VCSClient.CreateComment(ctx.Pull.BaseRepo, ctx.Pull.Num, comment, command.CommandName().String()); err != nil {
+ comment := c.MarkdownRenderer.Render(res, cmd.CommandName(), ctx.Log.GetHistory(), cmd.IsVerbose(), ctx.Pull.BaseRepo.VCSHost.Type)
+ if err := c.VCSClient.CreateComment(ctx.Pull.BaseRepo, ctx.Pull.Num, comment, cmd.CommandName().String()); err != nil {
ctx.Log.Err("unable to comment: %s", err)
}
}
diff --git a/server/events/unlock_command_runner.go b/server/events/unlock_command_runner.go
index f95397ef5..1a7407397 100644
--- a/server/events/unlock_command_runner.go
+++ b/server/events/unlock_command_runner.go
@@ -1,7 +1,7 @@
package events
import (
- "github.com/runatlantis/atlantis/server/events/models"
+ "github.com/runatlantis/atlantis/server/events/command"
"github.com/runatlantis/atlantis/server/events/vcs"
)
@@ -26,7 +26,7 @@ type UnlockCommandRunner struct {
}
func (u *UnlockCommandRunner) Run(
- ctx *CommandContext,
+ ctx *command.Context,
cmd *CommentCommand,
) {
baseRepo := ctx.Pull.BaseRepo
@@ -44,7 +44,7 @@ func (u *UnlockCommandRunner) Run(
return
}
- if commentErr := u.vcsClient.CreateComment(baseRepo, pullNum, vcsMessage, models.UnlockCommand.String()); commentErr != nil {
+ if commentErr := u.vcsClient.CreateComment(baseRepo, pullNum, vcsMessage, command.Unlock.String()); commentErr != nil {
ctx.Log.Err("unable to comment: %s", commentErr)
}
}
diff --git a/server/events/vcs/github_client_test.go b/server/events/vcs/github_client_test.go
index b388cec91..ccabb41ad 100644
--- a/server/events/vcs/github_client_test.go
+++ b/server/events/vcs/github_client_test.go
@@ -12,6 +12,7 @@ import (
"strings"
"testing"
+ "github.com/runatlantis/atlantis/server/events/command"
"github.com/runatlantis/atlantis/server/events/models"
"github.com/runatlantis/atlantis/server/events/vcs"
"github.com/runatlantis/atlantis/server/logging"
@@ -228,7 +229,7 @@ func TestGithubClient_PaginatesComments(t *testing.T) {
},
},
123,
- models.PlanCommand.TitleString(),
+ command.Plan.TitleString(),
)
Ok(t, err)
Equals(t, 2, len(gotMinimizeCalls))
@@ -317,7 +318,7 @@ func TestGithubClient_HideOldComments(t *testing.T) {
},
},
123,
- models.PlanCommand.TitleString(),
+ command.Plan.TitleString(),
)
Ok(t, err)
Equals(t, 3, len(gotMinimizeCalls))
@@ -876,7 +877,7 @@ func TestGithubClient_SplitComments(t *testing.T) {
}
// create an extra long string
comment := strings.Repeat("a", 65537)
- err = client.CreateComment(repo, pull.Num, comment, models.PlanCommand.String())
+ err = client.CreateComment(repo, pull.Num, comment, command.Plan.String())
Ok(t, err)
err = client.CreateComment(repo, pull.Num, comment, "")
Ok(t, err)
@@ -887,7 +888,7 @@ func TestGithubClient_SplitComments(t *testing.T) {
secondSplit := strings.ToLower(body[0])
Equals(t, 4, len(githubComments))
- Assert(t, strings.Contains(firstSplit, models.PlanCommand.String()), fmt.Sprintf("comment should contain the command name but was %q", firstSplit))
+ Assert(t, strings.Contains(firstSplit, command.Plan.String()), fmt.Sprintf("comment should contain the command name but was %q", firstSplit))
Assert(t, strings.Contains(secondSplit, "continued from previous comment"), fmt.Sprintf("comment should contain no reference to the command name but was %q", secondSplit))
}
diff --git a/server/events/vcs/gitlab_client.go b/server/events/vcs/gitlab_client.go
index d202141fd..7bf7a10b3 100644
--- a/server/events/vcs/gitlab_client.go
+++ b/server/events/vcs/gitlab_client.go
@@ -24,6 +24,7 @@ import (
"github.com/runatlantis/atlantis/server/core/config"
+ "github.com/runatlantis/atlantis/server/events/command"
"github.com/runatlantis/atlantis/server/events/vcs/common"
version "github.com/hashicorp/go-version"
@@ -211,7 +212,7 @@ func (g *GitlabClient) PullIsMergeable(repo models.Repo, pull models.PullRequest
}
for _, status := range statuses {
- if !strings.HasSuffix(status.Name, fmt.Sprintf("/%s", models.ApplyCommand.String())) {
+ if !strings.HasSuffix(status.Name, fmt.Sprintf("/%s", command.Apply.String())) {
if !status.AllowFailure && project.OnlyAllowMergeIfPipelineSucceeds && status.Status != "success" {
return false, nil
}
diff --git a/server/events/vcs/mocks/matchers/models_approvalstatus.go b/server/events/vcs/mocks/matchers/models_approvalstatus.go
index 01b76dd96..e4ce9d9d7 100644
--- a/server/events/vcs/mocks/matchers/models_approvalstatus.go
+++ b/server/events/vcs/mocks/matchers/models_approvalstatus.go
@@ -2,9 +2,10 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+ "github.com/petergtz/pegomock"
+
models "github.com/runatlantis/atlantis/server/events/models"
)
diff --git a/server/events/vcs/mocks/matchers/models_commitstatus.go b/server/events/vcs/mocks/matchers/models_commitstatus.go
index 1e10ed782..5ebf733ee 100644
--- a/server/events/vcs/mocks/matchers/models_commitstatus.go
+++ b/server/events/vcs/mocks/matchers/models_commitstatus.go
@@ -2,9 +2,10 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+ "github.com/petergtz/pegomock"
+
models "github.com/runatlantis/atlantis/server/events/models"
)
diff --git a/server/events/vcs/mocks/matchers/models_pullrequest.go b/server/events/vcs/mocks/matchers/models_pullrequest.go
index 9ae2a7e92..db2666f02 100644
--- a/server/events/vcs/mocks/matchers/models_pullrequest.go
+++ b/server/events/vcs/mocks/matchers/models_pullrequest.go
@@ -2,9 +2,10 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+ "github.com/petergtz/pegomock"
+
models "github.com/runatlantis/atlantis/server/events/models"
)
diff --git a/server/events/vcs/mocks/matchers/models_pullrequestoptions.go b/server/events/vcs/mocks/matchers/models_pullrequestoptions.go
index c2c240c7a..b20914719 100644
--- a/server/events/vcs/mocks/matchers/models_pullrequestoptions.go
+++ b/server/events/vcs/mocks/matchers/models_pullrequestoptions.go
@@ -2,9 +2,10 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+ "github.com/petergtz/pegomock"
+
models "github.com/runatlantis/atlantis/server/events/models"
)
diff --git a/server/events/vcs/mocks/matchers/models_repo.go b/server/events/vcs/mocks/matchers/models_repo.go
index fd44665f8..2ca60819c 100644
--- a/server/events/vcs/mocks/matchers/models_repo.go
+++ b/server/events/vcs/mocks/matchers/models_repo.go
@@ -2,9 +2,10 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+ "github.com/petergtz/pegomock"
+
models "github.com/runatlantis/atlantis/server/events/models"
)
diff --git a/server/events/vcs/mocks/matchers/ptr_to_http_client.go b/server/events/vcs/mocks/matchers/ptr_to_http_client.go
index 74766e888..4a4742755 100644
--- a/server/events/vcs/mocks/matchers/ptr_to_http_client.go
+++ b/server/events/vcs/mocks/matchers/ptr_to_http_client.go
@@ -2,9 +2,10 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+ "github.com/petergtz/pegomock"
+
http "net/http"
)
diff --git a/server/events/vcs/mocks/matchers/slice_of_byte.go b/server/events/vcs/mocks/matchers/slice_of_byte.go
index 951531345..7ff2e45ca 100644
--- a/server/events/vcs/mocks/matchers/slice_of_byte.go
+++ b/server/events/vcs/mocks/matchers/slice_of_byte.go
@@ -2,8 +2,9 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+
+ "github.com/petergtz/pegomock"
)
func AnySliceOfByte() []byte {
diff --git a/server/events/vcs/mocks/matchers/slice_of_string.go b/server/events/vcs/mocks/matchers/slice_of_string.go
index f9281819d..8bfc2792f 100644
--- a/server/events/vcs/mocks/matchers/slice_of_string.go
+++ b/server/events/vcs/mocks/matchers/slice_of_string.go
@@ -2,8 +2,9 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+
+ "github.com/petergtz/pegomock"
)
func AnySliceOfString() []string {
diff --git a/server/events/vcs/mocks/mock_client.go b/server/events/vcs/mocks/mock_client.go
index a2bfd40d1..319949ded 100644
--- a/server/events/vcs/mocks/mock_client.go
+++ b/server/events/vcs/mocks/mock_client.go
@@ -4,10 +4,11 @@
package mocks
import (
- pegomock "github.com/petergtz/pegomock"
- models "github.com/runatlantis/atlantis/server/events/models"
"reflect"
"time"
+
+ pegomock "github.com/petergtz/pegomock"
+ models "github.com/runatlantis/atlantis/server/events/models"
)
type MockClient struct {
diff --git a/server/events/vcs/mocks/mock_github_credentials.go b/server/events/vcs/mocks/mock_github_credentials.go
index d491009dc..ad7765d21 100644
--- a/server/events/vcs/mocks/mock_github_credentials.go
+++ b/server/events/vcs/mocks/mock_github_credentials.go
@@ -4,10 +4,11 @@
package mocks
import (
- pegomock "github.com/petergtz/pegomock"
http "net/http"
"reflect"
"time"
+
+ pegomock "github.com/petergtz/pegomock"
)
type MockGithubCredentials struct {
diff --git a/server/events/version_command_runner.go b/server/events/version_command_runner.go
index b1b7e029b..101ba2857 100644
--- a/server/events/version_command_runner.go
+++ b/server/events/version_command_runner.go
@@ -1,6 +1,8 @@
package events
-import "github.com/runatlantis/atlantis/server/events/models"
+import (
+ "github.com/runatlantis/atlantis/server/events/command"
+)
func NewVersionCommandRunner(
pullUpdater *PullUpdater,
@@ -28,9 +30,9 @@ type VersionCommandRunner struct {
silenceVCSStatusNoProjects bool
}
-func (v *VersionCommandRunner) Run(ctx *CommandContext, cmd *CommentCommand) {
+func (v *VersionCommandRunner) Run(ctx *command.Context, cmd *CommentCommand) {
var err error
- var projectCmds []models.ProjectCommandContext
+ var projectCmds []command.ProjectContext
projectCmds, err = v.prjCmdBuilder.BuildVersionCommands(ctx, cmd)
if err != nil {
ctx.Log.Warn("Error %s", err)
@@ -42,7 +44,7 @@ func (v *VersionCommandRunner) Run(ctx *CommandContext, cmd *CommentCommand) {
}
// Only run commands in parallel if enabled
- var result CommandResult
+ var result command.Result
if v.isParallelEnabled(projectCmds) {
ctx.Log.Info("Running version in parallel")
result = runProjectCmdsParallel(projectCmds, v.prjCmdRunner.Version, v.parallelPoolSize)
@@ -53,6 +55,6 @@ func (v *VersionCommandRunner) Run(ctx *CommandContext, cmd *CommentCommand) {
v.pullUpdater.updatePull(ctx, cmd, result)
}
-func (v *VersionCommandRunner) isParallelEnabled(cmds []models.ProjectCommandContext) bool {
+func (v *VersionCommandRunner) isParallelEnabled(cmds []command.ProjectContext) bool {
return len(cmds) > 0 && cmds[0].ParallelPolicyCheckEnabled
}
diff --git a/server/events/webhooks/mocks/matchers/logging_simplelogging.go b/server/events/webhooks/mocks/matchers/logging_simplelogging.go
index 502456e7c..c3b96f61f 100644
--- a/server/events/webhooks/mocks/matchers/logging_simplelogging.go
+++ b/server/events/webhooks/mocks/matchers/logging_simplelogging.go
@@ -2,9 +2,10 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+ "github.com/petergtz/pegomock"
+
logging "github.com/runatlantis/atlantis/server/logging"
)
diff --git a/server/events/webhooks/mocks/matchers/ptr_to_logging_simplelogger.go b/server/events/webhooks/mocks/matchers/ptr_to_logging_simplelogger.go
index ddb778473..49af91b55 100644
--- a/server/events/webhooks/mocks/matchers/ptr_to_logging_simplelogger.go
+++ b/server/events/webhooks/mocks/matchers/ptr_to_logging_simplelogger.go
@@ -2,9 +2,10 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+ "github.com/petergtz/pegomock"
+
logging "github.com/runatlantis/atlantis/server/logging"
)
diff --git a/server/events/webhooks/mocks/matchers/ptr_to_slack_authtestresponse.go b/server/events/webhooks/mocks/matchers/ptr_to_slack_authtestresponse.go
index 179abf628..958bfd2eb 100644
--- a/server/events/webhooks/mocks/matchers/ptr_to_slack_authtestresponse.go
+++ b/server/events/webhooks/mocks/matchers/ptr_to_slack_authtestresponse.go
@@ -2,9 +2,10 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+ "github.com/petergtz/pegomock"
+
slack "github.com/nlopes/slack"
)
diff --git a/server/events/webhooks/mocks/matchers/ptr_to_slack_getconversationsparameters.go b/server/events/webhooks/mocks/matchers/ptr_to_slack_getconversationsparameters.go
index ca4220019..54831bd3d 100644
--- a/server/events/webhooks/mocks/matchers/ptr_to_slack_getconversationsparameters.go
+++ b/server/events/webhooks/mocks/matchers/ptr_to_slack_getconversationsparameters.go
@@ -2,9 +2,10 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+ "github.com/petergtz/pegomock"
+
slack "github.com/nlopes/slack"
)
diff --git a/server/events/webhooks/mocks/matchers/slack_postmessageparameters.go b/server/events/webhooks/mocks/matchers/slack_postmessageparameters.go
index 1960cca69..e5ae68a61 100644
--- a/server/events/webhooks/mocks/matchers/slack_postmessageparameters.go
+++ b/server/events/webhooks/mocks/matchers/slack_postmessageparameters.go
@@ -2,9 +2,10 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+ "github.com/petergtz/pegomock"
+
slack "github.com/nlopes/slack"
)
diff --git a/server/events/webhooks/mocks/matchers/slice_of_slack_channel.go b/server/events/webhooks/mocks/matchers/slice_of_slack_channel.go
index 0c26ce66e..37ab8bf1e 100644
--- a/server/events/webhooks/mocks/matchers/slice_of_slack_channel.go
+++ b/server/events/webhooks/mocks/matchers/slice_of_slack_channel.go
@@ -2,9 +2,10 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+ "github.com/petergtz/pegomock"
+
slack "github.com/nlopes/slack"
)
diff --git a/server/events/webhooks/mocks/matchers/webhooks_applyresult.go b/server/events/webhooks/mocks/matchers/webhooks_applyresult.go
index adbcf9817..6b1878e32 100644
--- a/server/events/webhooks/mocks/matchers/webhooks_applyresult.go
+++ b/server/events/webhooks/mocks/matchers/webhooks_applyresult.go
@@ -2,9 +2,10 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+ "github.com/petergtz/pegomock"
+
webhooks "github.com/runatlantis/atlantis/server/events/webhooks"
)
diff --git a/server/events/webhooks/mocks/mock_sender.go b/server/events/webhooks/mocks/mock_sender.go
index 680ab6dce..42ba6f59c 100644
--- a/server/events/webhooks/mocks/mock_sender.go
+++ b/server/events/webhooks/mocks/mock_sender.go
@@ -4,11 +4,12 @@
package mocks
import (
+ "reflect"
+ "time"
+
pegomock "github.com/petergtz/pegomock"
webhooks "github.com/runatlantis/atlantis/server/events/webhooks"
logging "github.com/runatlantis/atlantis/server/logging"
- "reflect"
- "time"
)
type MockSender struct {
diff --git a/server/events/webhooks/mocks/mock_slack_client.go b/server/events/webhooks/mocks/mock_slack_client.go
index ef842b8cd..a1fe65a26 100644
--- a/server/events/webhooks/mocks/mock_slack_client.go
+++ b/server/events/webhooks/mocks/mock_slack_client.go
@@ -4,10 +4,11 @@
package mocks
import (
- pegomock "github.com/petergtz/pegomock"
- webhooks "github.com/runatlantis/atlantis/server/events/webhooks"
"reflect"
"time"
+
+ pegomock "github.com/petergtz/pegomock"
+ webhooks "github.com/runatlantis/atlantis/server/events/webhooks"
)
type MockSlackClient struct {
diff --git a/server/events/webhooks/mocks/mock_underlying_slack_client.go b/server/events/webhooks/mocks/mock_underlying_slack_client.go
index b13b0bdb7..db558eae8 100644
--- a/server/events/webhooks/mocks/mock_underlying_slack_client.go
+++ b/server/events/webhooks/mocks/mock_underlying_slack_client.go
@@ -4,10 +4,11 @@
package mocks
import (
- slack "github.com/nlopes/slack"
- pegomock "github.com/petergtz/pegomock"
"reflect"
"time"
+
+ slack "github.com/nlopes/slack"
+ pegomock "github.com/petergtz/pegomock"
)
type MockUnderlyingSlackClient struct {
diff --git a/server/jobs/job_url_setter.go b/server/jobs/job_url_setter.go
index d681935c5..02af4c661 100644
--- a/server/jobs/job_url_setter.go
+++ b/server/jobs/job_url_setter.go
@@ -1,12 +1,15 @@
package jobs
-import "github.com/runatlantis/atlantis/server/events/models"
+import (
+ "github.com/runatlantis/atlantis/server/events/command"
+ "github.com/runatlantis/atlantis/server/events/models"
+)
//go:generate pegomock generate -m --use-experimental-model-gen --package mocks -o mocks/mock_project_job_url_generator.go ProjectJobURLGenerator
// ProjectJobURLGenerator generates urls to view project's progress.
type ProjectJobURLGenerator interface {
- GenerateProjectJobURL(p models.ProjectCommandContext) (string, error)
+ GenerateProjectJobURL(p command.ProjectContext) (string, error)
}
//go:generate pegomock generate -m --use-experimental-model-gen --package mocks -o mocks/mock_project_status_updater.go ProjectStatusUpdater
@@ -14,7 +17,7 @@ type ProjectJobURLGenerator interface {
type ProjectStatusUpdater interface {
// UpdateProject sets the commit status for the project represented by
// ctx.
- UpdateProject(ctx models.ProjectCommandContext, cmdName models.CommandName, status models.CommitStatus, url string) error
+ UpdateProject(ctx command.ProjectContext, cmdName command.Name, status models.CommitStatus, url string) error
}
type JobURLSetter struct {
@@ -29,7 +32,7 @@ func NewJobURLSetter(projectJobURLGenerator ProjectJobURLGenerator, projectStatu
}
}
-func (j *JobURLSetter) SetJobURLWithStatus(ctx models.ProjectCommandContext, cmdName models.CommandName, status models.CommitStatus) error {
+func (j *JobURLSetter) SetJobURLWithStatus(ctx command.ProjectContext, cmdName command.Name, status models.CommitStatus) error {
url, err := j.projectJobURLGenerator.GenerateProjectJobURL(ctx)
if err != nil {
diff --git a/server/jobs/job_url_setter_test.go b/server/jobs/job_url_setter_test.go
index 5ae8073c6..4b19edcbc 100644
--- a/server/jobs/job_url_setter_test.go
+++ b/server/jobs/job_url_setter_test.go
@@ -5,6 +5,7 @@ import (
"testing"
. "github.com/petergtz/pegomock"
+ "github.com/runatlantis/atlantis/server/events/command"
"github.com/runatlantis/atlantis/server/events/models"
"github.com/runatlantis/atlantis/server/jobs"
"github.com/runatlantis/atlantis/server/jobs/mocks"
@@ -24,11 +25,11 @@ func TestJobURLSetter(t *testing.T) {
jobURLSetter := jobs.NewJobURLSetter(projectJobURLGenerator, projectStatusUpdater)
When(projectJobURLGenerator.GenerateProjectJobURL(matchers.EqModelsProjectCommandContext(ctx))).ThenReturn(url, nil)
- When(projectStatusUpdater.UpdateProject(ctx, models.PlanCommand, models.PendingCommitStatus, url)).ThenReturn(nil)
- err := jobURLSetter.SetJobURLWithStatus(ctx, models.PlanCommand, models.PendingCommitStatus)
+ When(projectStatusUpdater.UpdateProject(ctx, command.Plan, models.PendingCommitStatus, url)).ThenReturn(nil)
+ err := jobURLSetter.SetJobURLWithStatus(ctx, command.Plan, models.PendingCommitStatus)
Ok(t, err)
- projectStatusUpdater.VerifyWasCalledOnce().UpdateProject(ctx, models.PlanCommand, models.PendingCommitStatus, "url-to-project-jobs")
+ projectStatusUpdater.VerifyWasCalledOnce().UpdateProject(ctx, command.Plan, models.PendingCommitStatus, "url-to-project-jobs")
})
t.Run("update project status with project jobs url error", func(t *testing.T) {
@@ -38,7 +39,7 @@ func TestJobURLSetter(t *testing.T) {
jobURLSetter := jobs.NewJobURLSetter(projectJobURLGenerator, projectStatusUpdater)
When(projectJobURLGenerator.GenerateProjectJobURL(matchers.EqModelsProjectCommandContext(ctx))).ThenReturn("url-to-project-jobs", errors.New("some error"))
- err := jobURLSetter.SetJobURLWithStatus(ctx, models.PlanCommand, models.PendingCommitStatus)
+ err := jobURLSetter.SetJobURLWithStatus(ctx, command.Plan, models.PendingCommitStatus)
assert.Error(t, err)
})
}
diff --git a/server/jobs/mocks/matchers/chan_of_string.go b/server/jobs/mocks/matchers/chan_of_string.go
index e1bfee572..44526eb9b 100644
--- a/server/jobs/mocks/matchers/chan_of_string.go
+++ b/server/jobs/mocks/matchers/chan_of_string.go
@@ -2,8 +2,9 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+
+ "github.com/petergtz/pegomock"
)
func AnyChanOfString() chan string {
diff --git a/server/jobs/mocks/matchers/jobs_pullinfo.go b/server/jobs/mocks/matchers/jobs_pullinfo.go
index 95e16a16f..64141c6b3 100644
--- a/server/jobs/mocks/matchers/jobs_pullinfo.go
+++ b/server/jobs/mocks/matchers/jobs_pullinfo.go
@@ -2,9 +2,10 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+ "github.com/petergtz/pegomock"
+
jobs "github.com/runatlantis/atlantis/server/jobs"
)
diff --git a/server/jobs/mocks/matchers/models_commandname.go b/server/jobs/mocks/matchers/models_commandname.go
index f586b4d21..aec79b126 100644
--- a/server/jobs/mocks/matchers/models_commandname.go
+++ b/server/jobs/mocks/matchers/models_commandname.go
@@ -2,32 +2,32 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
- models "github.com/runatlantis/atlantis/server/events/models"
+ "github.com/petergtz/pegomock"
+ "github.com/runatlantis/atlantis/server/events/command"
)
-func AnyModelsCommandName() models.CommandName {
- pegomock.RegisterMatcher(pegomock.NewAnyMatcher(reflect.TypeOf((*(models.CommandName))(nil)).Elem()))
- var nullValue models.CommandName
+func AnyModelsCommandName() command.Name {
+ pegomock.RegisterMatcher(pegomock.NewAnyMatcher(reflect.TypeOf((*(command.Name))(nil)).Elem()))
+ var nullValue command.Name
return nullValue
}
-func EqModelsCommandName(value models.CommandName) models.CommandName {
+func EqModelsCommandName(value command.Name) command.Name {
pegomock.RegisterMatcher(&pegomock.EqMatcher{Value: value})
- var nullValue models.CommandName
+ var nullValue command.Name
return nullValue
}
-func NotEqModelsCommandName(value models.CommandName) models.CommandName {
+func NotEqModelsCommandName(value command.Name) command.Name {
pegomock.RegisterMatcher(&pegomock.NotEqMatcher{Value: value})
- var nullValue models.CommandName
+ var nullValue command.Name
return nullValue
}
-func ModelsCommandNameThat(matcher pegomock.ArgumentMatcher) models.CommandName {
+func ModelsCommandNameThat(matcher pegomock.ArgumentMatcher) command.Name {
pegomock.RegisterMatcher(matcher)
- var nullValue models.CommandName
+ var nullValue command.Name
return nullValue
}
diff --git a/server/jobs/mocks/matchers/models_commitstatus.go b/server/jobs/mocks/matchers/models_commitstatus.go
index 1e10ed782..5ebf733ee 100644
--- a/server/jobs/mocks/matchers/models_commitstatus.go
+++ b/server/jobs/mocks/matchers/models_commitstatus.go
@@ -2,9 +2,10 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+ "github.com/petergtz/pegomock"
+
models "github.com/runatlantis/atlantis/server/events/models"
)
diff --git a/server/jobs/mocks/matchers/models_projectcommandcontext.go b/server/jobs/mocks/matchers/models_projectcommandcontext.go
index 535f8b967..90db05bac 100644
--- a/server/jobs/mocks/matchers/models_projectcommandcontext.go
+++ b/server/jobs/mocks/matchers/models_projectcommandcontext.go
@@ -2,32 +2,32 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
- models "github.com/runatlantis/atlantis/server/events/models"
+ "github.com/petergtz/pegomock"
+ "github.com/runatlantis/atlantis/server/events/command"
)
-func AnyModelsProjectCommandContext() models.ProjectCommandContext {
- pegomock.RegisterMatcher(pegomock.NewAnyMatcher(reflect.TypeOf((*(models.ProjectCommandContext))(nil)).Elem()))
- var nullValue models.ProjectCommandContext
+func AnyModelsProjectCommandContext() command.ProjectContext {
+ pegomock.RegisterMatcher(pegomock.NewAnyMatcher(reflect.TypeOf((*(command.ProjectContext))(nil)).Elem()))
+ var nullValue command.ProjectContext
return nullValue
}
-func EqModelsProjectCommandContext(value models.ProjectCommandContext) models.ProjectCommandContext {
+func EqModelsProjectCommandContext(value command.ProjectContext) command.ProjectContext {
pegomock.RegisterMatcher(&pegomock.EqMatcher{Value: value})
- var nullValue models.ProjectCommandContext
+ var nullValue command.ProjectContext
return nullValue
}
-func NotEqModelsProjectCommandContext(value models.ProjectCommandContext) models.ProjectCommandContext {
+func NotEqModelsProjectCommandContext(value command.ProjectContext) command.ProjectContext {
pegomock.RegisterMatcher(&pegomock.NotEqMatcher{Value: value})
- var nullValue models.ProjectCommandContext
+ var nullValue command.ProjectContext
return nullValue
}
-func ModelsProjectCommandContextThat(matcher pegomock.ArgumentMatcher) models.ProjectCommandContext {
+func ModelsProjectCommandContextThat(matcher pegomock.ArgumentMatcher) command.ProjectContext {
pegomock.RegisterMatcher(matcher)
- var nullValue models.ProjectCommandContext
+ var nullValue command.ProjectContext
return nullValue
}
diff --git a/server/jobs/mocks/mock_project_command_output_handler.go b/server/jobs/mocks/mock_project_command_output_handler.go
index 32b6ed76a..8bc39e45e 100644
--- a/server/jobs/mocks/mock_project_command_output_handler.go
+++ b/server/jobs/mocks/mock_project_command_output_handler.go
@@ -4,11 +4,12 @@
package mocks
import (
- pegomock "github.com/petergtz/pegomock"
- models "github.com/runatlantis/atlantis/server/events/models"
- jobs "github.com/runatlantis/atlantis/server/jobs"
"reflect"
"time"
+
+ pegomock "github.com/petergtz/pegomock"
+ "github.com/runatlantis/atlantis/server/events/command"
+ jobs "github.com/runatlantis/atlantis/server/jobs"
)
type MockProjectCommandOutputHandler struct {
@@ -73,7 +74,7 @@ func (mock *MockProjectCommandOutputHandler) Register(_param0 string, _param1 ch
pegomock.GetGenericMockFrom(mock).Invoke("Register", params, []reflect.Type{})
}
-func (mock *MockProjectCommandOutputHandler) Send(_param0 models.ProjectCommandContext, _param1 string, _param2 bool) {
+func (mock *MockProjectCommandOutputHandler) Send(_param0 command.ProjectContext, _param1 string, _param2 bool) {
if mock == nil {
panic("mock must not be nil. Use myMock := NewMockProjectCommandOutputHandler().")
}
@@ -251,7 +252,7 @@ func (c *MockProjectCommandOutputHandler_Register_OngoingVerification) GetAllCap
return
}
-func (verifier *VerifierMockProjectCommandOutputHandler) Send(_param0 models.ProjectCommandContext, _param1 string, _param2 bool) *MockProjectCommandOutputHandler_Send_OngoingVerification {
+func (verifier *VerifierMockProjectCommandOutputHandler) Send(_param0 command.ProjectContext, _param1 string, _param2 bool) *MockProjectCommandOutputHandler_Send_OngoingVerification {
params := []pegomock.Param{_param0, _param1, _param2}
methodInvocations := pegomock.GetGenericMockFrom(verifier.mock).Verify(verifier.inOrderContext, verifier.invocationCountMatcher, "Send", params, verifier.timeout)
return &MockProjectCommandOutputHandler_Send_OngoingVerification{mock: verifier.mock, methodInvocations: methodInvocations}
@@ -262,17 +263,17 @@ type MockProjectCommandOutputHandler_Send_OngoingVerification struct {
methodInvocations []pegomock.MethodInvocation
}
-func (c *MockProjectCommandOutputHandler_Send_OngoingVerification) GetCapturedArguments() (models.ProjectCommandContext, string, bool) {
+func (c *MockProjectCommandOutputHandler_Send_OngoingVerification) GetCapturedArguments() (command.ProjectContext, string, bool) {
_param0, _param1, _param2 := c.GetAllCapturedArguments()
return _param0[len(_param0)-1], _param1[len(_param1)-1], _param2[len(_param2)-1]
}
-func (c *MockProjectCommandOutputHandler_Send_OngoingVerification) GetAllCapturedArguments() (_param0 []models.ProjectCommandContext, _param1 []string, _param2 []bool) {
+func (c *MockProjectCommandOutputHandler_Send_OngoingVerification) GetAllCapturedArguments() (_param0 []command.ProjectContext, _param1 []string, _param2 []bool) {
params := pegomock.GetGenericMockFrom(c.mock).GetInvocationParams(c.methodInvocations)
if len(params) > 0 {
- _param0 = make([]models.ProjectCommandContext, len(c.methodInvocations))
+ _param0 = make([]command.ProjectContext, len(c.methodInvocations))
for u, param := range params[0] {
- _param0[u] = param.(models.ProjectCommandContext)
+ _param0[u] = param.(command.ProjectContext)
}
_param1 = make([]string, len(c.methodInvocations))
for u, param := range params[1] {
diff --git a/server/jobs/mocks/mock_project_job_url_generator.go b/server/jobs/mocks/mock_project_job_url_generator.go
index 385cc6410..88d7e530f 100644
--- a/server/jobs/mocks/mock_project_job_url_generator.go
+++ b/server/jobs/mocks/mock_project_job_url_generator.go
@@ -4,10 +4,11 @@
package mocks
import (
- pegomock "github.com/petergtz/pegomock"
- models "github.com/runatlantis/atlantis/server/events/models"
"reflect"
"time"
+
+ pegomock "github.com/petergtz/pegomock"
+ "github.com/runatlantis/atlantis/server/events/command"
)
type MockProjectJobURLGenerator struct {
@@ -25,7 +26,7 @@ func NewMockProjectJobURLGenerator(options ...pegomock.Option) *MockProjectJobUR
func (mock *MockProjectJobURLGenerator) SetFailHandler(fh pegomock.FailHandler) { mock.fail = fh }
func (mock *MockProjectJobURLGenerator) FailHandler() pegomock.FailHandler { return mock.fail }
-func (mock *MockProjectJobURLGenerator) GenerateProjectJobURL(_param0 models.ProjectCommandContext) (string, error) {
+func (mock *MockProjectJobURLGenerator) GenerateProjectJobURL(_param0 command.ProjectContext) (string, error) {
if mock == nil {
panic("mock must not be nil. Use myMock := NewMockProjectJobURLGenerator().")
}
@@ -81,7 +82,7 @@ type VerifierMockProjectJobURLGenerator struct {
timeout time.Duration
}
-func (verifier *VerifierMockProjectJobURLGenerator) GenerateProjectJobURL(_param0 models.ProjectCommandContext) *MockProjectJobURLGenerator_GenerateProjectJobURL_OngoingVerification {
+func (verifier *VerifierMockProjectJobURLGenerator) GenerateProjectJobURL(_param0 command.ProjectContext) *MockProjectJobURLGenerator_GenerateProjectJobURL_OngoingVerification {
params := []pegomock.Param{_param0}
methodInvocations := pegomock.GetGenericMockFrom(verifier.mock).Verify(verifier.inOrderContext, verifier.invocationCountMatcher, "GenerateProjectJobURL", params, verifier.timeout)
return &MockProjectJobURLGenerator_GenerateProjectJobURL_OngoingVerification{mock: verifier.mock, methodInvocations: methodInvocations}
@@ -92,17 +93,17 @@ type MockProjectJobURLGenerator_GenerateProjectJobURL_OngoingVerification struct
methodInvocations []pegomock.MethodInvocation
}
-func (c *MockProjectJobURLGenerator_GenerateProjectJobURL_OngoingVerification) GetCapturedArguments() models.ProjectCommandContext {
+func (c *MockProjectJobURLGenerator_GenerateProjectJobURL_OngoingVerification) GetCapturedArguments() command.ProjectContext {
_param0 := c.GetAllCapturedArguments()
return _param0[len(_param0)-1]
}
-func (c *MockProjectJobURLGenerator_GenerateProjectJobURL_OngoingVerification) GetAllCapturedArguments() (_param0 []models.ProjectCommandContext) {
+func (c *MockProjectJobURLGenerator_GenerateProjectJobURL_OngoingVerification) GetAllCapturedArguments() (_param0 []command.ProjectContext) {
params := pegomock.GetGenericMockFrom(c.mock).GetInvocationParams(c.methodInvocations)
if len(params) > 0 {
- _param0 = make([]models.ProjectCommandContext, len(c.methodInvocations))
+ _param0 = make([]command.ProjectContext, len(c.methodInvocations))
for u, param := range params[0] {
- _param0[u] = param.(models.ProjectCommandContext)
+ _param0[u] = param.(command.ProjectContext)
}
}
return
diff --git a/server/jobs/mocks/mock_project_status_updater.go b/server/jobs/mocks/mock_project_status_updater.go
index 4ea237d0f..2284b26a3 100644
--- a/server/jobs/mocks/mock_project_status_updater.go
+++ b/server/jobs/mocks/mock_project_status_updater.go
@@ -4,10 +4,12 @@
package mocks
import (
- pegomock "github.com/petergtz/pegomock"
- models "github.com/runatlantis/atlantis/server/events/models"
"reflect"
"time"
+
+ pegomock "github.com/petergtz/pegomock"
+ "github.com/runatlantis/atlantis/server/events/command"
+ models "github.com/runatlantis/atlantis/server/events/models"
)
type MockProjectStatusUpdater struct {
@@ -25,7 +27,7 @@ func NewMockProjectStatusUpdater(options ...pegomock.Option) *MockProjectStatusU
func (mock *MockProjectStatusUpdater) SetFailHandler(fh pegomock.FailHandler) { mock.fail = fh }
func (mock *MockProjectStatusUpdater) FailHandler() pegomock.FailHandler { return mock.fail }
-func (mock *MockProjectStatusUpdater) UpdateProject(_param0 models.ProjectCommandContext, _param1 models.CommandName, _param2 models.CommitStatus, _param3 string) error {
+func (mock *MockProjectStatusUpdater) UpdateProject(_param0 command.ProjectContext, _param1 command.Name, _param2 models.CommitStatus, _param3 string) error {
if mock == nil {
panic("mock must not be nil. Use myMock := NewMockProjectStatusUpdater().")
}
@@ -77,7 +79,7 @@ type VerifierMockProjectStatusUpdater struct {
timeout time.Duration
}
-func (verifier *VerifierMockProjectStatusUpdater) UpdateProject(_param0 models.ProjectCommandContext, _param1 models.CommandName, _param2 models.CommitStatus, _param3 string) *MockProjectStatusUpdater_UpdateProject_OngoingVerification {
+func (verifier *VerifierMockProjectStatusUpdater) UpdateProject(_param0 command.ProjectContext, _param1 command.Name, _param2 models.CommitStatus, _param3 string) *MockProjectStatusUpdater_UpdateProject_OngoingVerification {
params := []pegomock.Param{_param0, _param1, _param2, _param3}
methodInvocations := pegomock.GetGenericMockFrom(verifier.mock).Verify(verifier.inOrderContext, verifier.invocationCountMatcher, "UpdateProject", params, verifier.timeout)
return &MockProjectStatusUpdater_UpdateProject_OngoingVerification{mock: verifier.mock, methodInvocations: methodInvocations}
@@ -88,21 +90,21 @@ type MockProjectStatusUpdater_UpdateProject_OngoingVerification struct {
methodInvocations []pegomock.MethodInvocation
}
-func (c *MockProjectStatusUpdater_UpdateProject_OngoingVerification) GetCapturedArguments() (models.ProjectCommandContext, models.CommandName, models.CommitStatus, string) {
+func (c *MockProjectStatusUpdater_UpdateProject_OngoingVerification) GetCapturedArguments() (command.ProjectContext, command.Name, models.CommitStatus, string) {
_param0, _param1, _param2, _param3 := c.GetAllCapturedArguments()
return _param0[len(_param0)-1], _param1[len(_param1)-1], _param2[len(_param2)-1], _param3[len(_param3)-1]
}
-func (c *MockProjectStatusUpdater_UpdateProject_OngoingVerification) GetAllCapturedArguments() (_param0 []models.ProjectCommandContext, _param1 []models.CommandName, _param2 []models.CommitStatus, _param3 []string) {
+func (c *MockProjectStatusUpdater_UpdateProject_OngoingVerification) GetAllCapturedArguments() (_param0 []command.ProjectContext, _param1 []command.Name, _param2 []models.CommitStatus, _param3 []string) {
params := pegomock.GetGenericMockFrom(c.mock).GetInvocationParams(c.methodInvocations)
if len(params) > 0 {
- _param0 = make([]models.ProjectCommandContext, len(c.methodInvocations))
+ _param0 = make([]command.ProjectContext, len(c.methodInvocations))
for u, param := range params[0] {
- _param0[u] = param.(models.ProjectCommandContext)
+ _param0[u] = param.(command.ProjectContext)
}
- _param1 = make([]models.CommandName, len(c.methodInvocations))
+ _param1 = make([]command.Name, len(c.methodInvocations))
for u, param := range params[1] {
- _param1[u] = param.(models.CommandName)
+ _param1[u] = param.(command.Name)
}
_param2 = make([]models.CommitStatus, len(c.methodInvocations))
for u, param := range params[2] {
diff --git a/server/jobs/project_command_output_handler.go b/server/jobs/project_command_output_handler.go
index 438bd799c..afd1837c6 100644
--- a/server/jobs/project_command_output_handler.go
+++ b/server/jobs/project_command_output_handler.go
@@ -3,7 +3,7 @@ package jobs
import (
"sync"
- "github.com/runatlantis/atlantis/server/events/models"
+ "github.com/runatlantis/atlantis/server/events/command"
"github.com/runatlantis/atlantis/server/logging"
)
@@ -52,7 +52,7 @@ type AsyncProjectCommandOutputHandler struct {
type ProjectCommandOutputHandler interface {
// Send will enqueue the msg and wait for Handle() to receive the message.
- Send(ctx models.ProjectCommandContext, msg string, operationComplete bool)
+ Send(ctx command.ProjectContext, msg string, operationComplete bool)
// Register registers a channel and blocks until it is caught up. Callers should call this asynchronously when attempting
// to read the channel in the same goroutine
@@ -90,7 +90,7 @@ func (p *AsyncProjectCommandOutputHandler) IsKeyExists(key string) bool {
return ok
}
-func (p *AsyncProjectCommandOutputHandler) Send(ctx models.ProjectCommandContext, msg string, operationComplete bool) {
+func (p *AsyncProjectCommandOutputHandler) Send(ctx command.ProjectContext, msg string, operationComplete bool) {
p.projectCmdOutput <- &ProjectCmdOutputLine{
JobID: ctx.JobID,
JobInfo: JobInfo{
@@ -249,7 +249,7 @@ func (p *AsyncProjectCommandOutputHandler) CleanUp(pullInfo PullInfo) {
// NoopProjectOutputHandler is a mock that doesn't do anything
type NoopProjectOutputHandler struct{}
-func (p *NoopProjectOutputHandler) Send(ctx models.ProjectCommandContext, msg string, isOperationComplete bool) {
+func (p *NoopProjectOutputHandler) Send(ctx command.ProjectContext, msg string, isOperationComplete bool) {
}
func (p *NoopProjectOutputHandler) Register(jobID string, receiver chan string) {}
diff --git a/server/jobs/project_command_output_handler_test.go b/server/jobs/project_command_output_handler_test.go
index 20a67b3a0..96187a65b 100644
--- a/server/jobs/project_command_output_handler_test.go
+++ b/server/jobs/project_command_output_handler_test.go
@@ -5,6 +5,7 @@ import (
"testing"
"time"
+ "github.com/runatlantis/atlantis/server/events/command"
"github.com/runatlantis/atlantis/server/events/models"
"github.com/runatlantis/atlantis/server/jobs"
"github.com/runatlantis/atlantis/server/logging"
@@ -12,9 +13,9 @@ import (
"github.com/stretchr/testify/assert"
)
-func createTestProjectCmdContext(t *testing.T) models.ProjectCommandContext {
+func createTestProjectCmdContext(t *testing.T) command.ProjectContext {
logger := logging.NewNoopLogger(t)
- return models.ProjectCommandContext{
+ return command.ProjectContext{
BaseRepo: models.Repo{
Name: "test-repo",
Owner: "test-org",
diff --git a/server/logging/mocks/matchers/logging_loglevel.go b/server/logging/mocks/matchers/logging_loglevel.go
index bba8254e7..c1f742113 100644
--- a/server/logging/mocks/matchers/logging_loglevel.go
+++ b/server/logging/mocks/matchers/logging_loglevel.go
@@ -2,9 +2,10 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+ "github.com/petergtz/pegomock"
+
logging "github.com/runatlantis/atlantis/server/logging"
)
diff --git a/server/logging/mocks/matchers/logging_simplelogging.go b/server/logging/mocks/matchers/logging_simplelogging.go
index 502456e7c..c3b96f61f 100644
--- a/server/logging/mocks/matchers/logging_simplelogging.go
+++ b/server/logging/mocks/matchers/logging_simplelogging.go
@@ -2,9 +2,10 @@
package matchers
import (
- "github.com/petergtz/pegomock"
"reflect"
+ "github.com/petergtz/pegomock"
+
logging "github.com/runatlantis/atlantis/server/logging"
)
diff --git a/server/logging/mocks/matchers/ptr_to_log_logger.go b/server/logging/mocks/matchers/ptr_to_log_logger.go
index a15f6620a..73a8e575a 100644
--- a/server/logging/mocks/matchers/ptr_to_log_logger.go
+++ b/server/logging/mocks/matchers/ptr_to_log_logger.go
@@ -2,9 +2,10 @@
package matchers
import (
+ log "log"
"reflect"
+
"github.com/petergtz/pegomock"
- log "log"
)
func AnyPtrToLogLogger() *log.Logger {
diff --git a/server/logging/mocks/matchers/ptr_to_logging_simplelogger.go b/server/logging/mocks/matchers/ptr_to_logging_simplelogger.go
index cf9bb5453..e7c8b942f 100644
--- a/server/logging/mocks/matchers/ptr_to_logging_simplelogger.go
+++ b/server/logging/mocks/matchers/ptr_to_logging_simplelogger.go
@@ -2,9 +2,10 @@
package matchers
import (
+ "reflect"
+
"github.com/petergtz/pegomock"
logging "github.com/runatlantis/atlantis/server/logging"
- "reflect"
)
func AnyPtrToLoggingSimpleLogger() logging.SimpleLogging {
diff --git a/server/logging/mocks/mock_simple_logging.go b/server/logging/mocks/mock_simple_logging.go
index 3efaa7b0c..36e97c84b 100644
--- a/server/logging/mocks/mock_simple_logging.go
+++ b/server/logging/mocks/mock_simple_logging.go
@@ -4,10 +4,11 @@
package mocks
import (
- pegomock "github.com/petergtz/pegomock"
- logging "github.com/runatlantis/atlantis/server/logging"
"reflect"
"time"
+
+ pegomock "github.com/petergtz/pegomock"
+ logging "github.com/runatlantis/atlantis/server/logging"
)
type MockSimpleLogging struct {
diff --git a/server/router.go b/server/router.go
index 58e2d800a..ce480e256 100644
--- a/server/router.go
+++ b/server/router.go
@@ -6,7 +6,7 @@ import (
"github.com/gorilla/mux"
"github.com/pkg/errors"
- "github.com/runatlantis/atlantis/server/events/models"
+ "github.com/runatlantis/atlantis/server/events/command"
)
// Router can be used to retrieve Atlantis URLs. It acts as an intermediary
@@ -39,7 +39,7 @@ func (r *Router) GenerateLockURL(lockID string) string {
return r.AtlantisURL.String() + lockURL.String()
}
-func (r *Router) GenerateProjectJobURL(ctx models.ProjectCommandContext) (string, error) {
+func (r *Router) GenerateProjectJobURL(ctx command.ProjectContext) (string, error) {
if ctx.JobID == "" {
return "", fmt.Errorf("no job id in ctx")
}
diff --git a/server/router_test.go b/server/router_test.go
index f5af05084..4b683e07c 100644
--- a/server/router_test.go
+++ b/server/router_test.go
@@ -8,6 +8,7 @@ import (
"github.com/google/uuid"
"github.com/gorilla/mux"
"github.com/runatlantis/atlantis/server"
+ "github.com/runatlantis/atlantis/server/events/command"
"github.com/runatlantis/atlantis/server/events/models"
. "github.com/runatlantis/atlantis/testing"
"github.com/stretchr/testify/assert"
@@ -82,7 +83,7 @@ func setupJobsRouter(t *testing.T) *server.Router {
func TestGenerateProjectJobURL_ShouldGenerateURLWhenJobIDSpecified(t *testing.T) {
router := setupJobsRouter(t)
jobID := uuid.New().String()
- ctx := models.ProjectCommandContext{
+ ctx := command.ProjectContext{
JobID: jobID,
}
expectedURL := fmt.Sprintf("http://localhost:4141/jobs/%s", jobID)
@@ -94,7 +95,7 @@ func TestGenerateProjectJobURL_ShouldGenerateURLWhenJobIDSpecified(t *testing.T)
func TestGenerateProjectJobURL_ShouldReturnErrorWhenJobIDNotSpecified(t *testing.T) {
router := setupJobsRouter(t)
- ctx := models.ProjectCommandContext{
+ ctx := command.ProjectContext{
Pull: models.PullRequest{
BaseRepo: models.Repo{
Owner: "test-owner",
diff --git a/server/server.go b/server/server.go
index 5045a9530..0d7e75054 100644
--- a/server/server.go
+++ b/server/server.go
@@ -52,6 +52,7 @@ import (
"github.com/runatlantis/atlantis/server/core/runtime/policy"
"github.com/runatlantis/atlantis/server/core/terraform"
"github.com/runatlantis/atlantis/server/events"
+ "github.com/runatlantis/atlantis/server/events/command"
"github.com/runatlantis/atlantis/server/events/models"
"github.com/runatlantis/atlantis/server/events/vcs"
"github.com/runatlantis/atlantis/server/events/vcs/bitbucketcloud"
@@ -651,12 +652,12 @@ func NewServer(userConfig UserConfig, config Config) (*Server, error) {
userConfig.SilenceNoProjects,
)
- commentCommandRunnerByCmd := map[models.CommandName]events.CommentCommandRunner{
- models.PlanCommand: planCommandRunner,
- models.ApplyCommand: applyCommandRunner,
- models.ApprovePoliciesCommand: approvePoliciesCommandRunner,
- models.UnlockCommand: unlockCommandRunner,
- models.VersionCommand: versionCommandRunner,
+ commentCommandRunnerByCmd := map[command.Name]events.CommentCommandRunner{
+ command.Plan: planCommandRunner,
+ command.Apply: applyCommandRunner,
+ command.ApprovePolicies: approvePoliciesCommandRunner,
+ command.Unlock: unlockCommandRunner,
+ command.Version: versionCommandRunner,
}
githubTeamAllowlistChecker, err := events.NewTeamAllowlistChecker(userConfig.GithubTeamAllowlist)
diff --git a/server/static/bindata_assetfs.go b/server/static/bindata_assetfs.go
index ef90aaf14..c4fdbfb5c 100644
--- a/server/static/bindata_assetfs.go
+++ b/server/static/bindata_assetfs.go
@@ -13,7 +13,6 @@
package static
import (
- "github.com/elazarl/go-bindata-assetfs"
"bytes"
"compress/gzip"
"fmt"
@@ -23,6 +22,8 @@ import (
"path/filepath"
"strings"
"time"
+
+ assetfs "github.com/elazarl/go-bindata-assetfs"
)
func bindataRead(data []byte, name string) ([]byte, error) {