diff --git a/server/azuredevops_request_validator.go b/server/controllers/events/azuredevops_request_validator.go similarity index 99% rename from server/azuredevops_request_validator.go rename to server/controllers/events/azuredevops_request_validator.go index f235d57b3..0b6e77e4f 100644 --- a/server/azuredevops_request_validator.go +++ b/server/controllers/events/azuredevops_request_validator.go @@ -1,4 +1,4 @@ -package server +package events import ( "fmt" diff --git a/server/azuredevops_request_validator_test.go b/server/controllers/events/azuredevops_request_validator_test.go similarity index 88% rename from server/azuredevops_request_validator_test.go rename to server/controllers/events/azuredevops_request_validator_test.go index 24b91e537..7416d0368 100644 --- a/server/azuredevops_request_validator_test.go +++ b/server/controllers/events/azuredevops_request_validator_test.go @@ -1,4 +1,4 @@ -package server_test +package events_test import ( "bytes" @@ -6,14 +6,14 @@ import ( "testing" . "github.com/petergtz/pegomock" - "github.com/runatlantis/atlantis/server" + "github.com/runatlantis/atlantis/server/controllers/events" . "github.com/runatlantis/atlantis/testing" ) func TestAzureDevopsValidate_WithBasicAuthErr(t *testing.T) { t.Log("if the request does not have a valid basic auth user and password there is an error") RegisterMockTestingT(t) - g := server.DefaultAzureDevopsRequestValidator{} + g := events.DefaultAzureDevopsRequestValidator{} buf := bytes.NewBufferString("") req, err := http.NewRequest("POST", "http://localhost/event", buf) Ok(t, err) @@ -28,7 +28,7 @@ func TestAzureDevopsValidate_WithBasicAuthErr(t *testing.T) { func TestAzureDevopsValidate_WithBasicAuth(t *testing.T) { t.Log("if the request has a valid basic auth user and password the payload is returned") RegisterMockTestingT(t) - g := server.DefaultAzureDevopsRequestValidator{} + g := events.DefaultAzureDevopsRequestValidator{} buf := bytes.NewBufferString(`{"yo":true}`) req, err := http.NewRequest("POST", "http://localhost/event", buf) Ok(t, err) @@ -43,7 +43,7 @@ func TestAzureDevopsValidate_WithBasicAuth(t *testing.T) { func TestAzureDevopsValidate_WithoutSecretInvalidContentType(t *testing.T) { t.Log("if the request has an invalid content type an error is returned") RegisterMockTestingT(t) - g := server.DefaultAzureDevopsRequestValidator{} + g := events.DefaultAzureDevopsRequestValidator{} buf := bytes.NewBufferString("") req, err := http.NewRequest("POST", "http://localhost/event", buf) Ok(t, err) @@ -57,7 +57,7 @@ func TestAzureDevopsValidate_WithoutSecretInvalidContentType(t *testing.T) { func TestAzureDevopsValidate_WithoutSecretJSON(t *testing.T) { t.Log("if the request is JSON the body is returned") RegisterMockTestingT(t) - g := server.DefaultAzureDevopsRequestValidator{} + g := events.DefaultAzureDevopsRequestValidator{} buf := bytes.NewBufferString(`{"yo":true}`) req, err := http.NewRequest("POST", "http://localhost/event", buf) Ok(t, err) diff --git a/server/events_controller.go b/server/controllers/events/events_controller.go similarity index 89% rename from server/events_controller.go rename to server/controllers/events/events_controller.go index dc7f5c18a..7164d10da 100644 --- a/server/events_controller.go +++ b/server/controllers/events/events_controller.go @@ -11,7 +11,7 @@ // limitations under the License. // Modified hereafter by contributors to runatlantis/atlantis. -package server +package events import ( "fmt" @@ -42,9 +42,9 @@ const bitbucketCloudRequestIDHeader = "X-Request-UUID" const bitbucketServerRequestIDHeader = "X-Request-ID" const bitbucketServerSignatureHeader = "X-Hub-Signature" -// EventsController handles all webhook requests which signify 'events' in the +// VCSEventsController handles all webhook requests which signify 'events' in the // VCS host, ex. GitHub. -type EventsController struct { +type VCSEventsController struct { CommandRunner events.CommandRunner PullCleaner events.PullCleaner Logger logging.SimpleLogging @@ -87,7 +87,7 @@ type EventsController struct { } // Post handles POST webhook requests. -func (e *EventsController) Post(w http.ResponseWriter, r *http.Request) { +func (e *VCSEventsController) Post(w http.ResponseWriter, r *http.Request) { if r.Header.Get(githubHeader) != "" { if !e.supportsHost(models.Github) { e.respond(w, logging.Debug, http.StatusBadRequest, "Ignoring request since not configured to support GitHub") @@ -136,7 +136,7 @@ func (e *EventsController) Post(w http.ResponseWriter, r *http.Request) { e.respond(w, logging.Debug, http.StatusBadRequest, "Ignoring request") } -func (e *EventsController) handleGithubPost(w http.ResponseWriter, r *http.Request) { +func (e *VCSEventsController) handleGithubPost(w http.ResponseWriter, r *http.Request) { // Validate the request against the optional webhook secret. payload, err := e.GithubRequestValidator.Validate(r, e.GithubWebhookSecret) if err != nil { @@ -159,7 +159,7 @@ func (e *EventsController) handleGithubPost(w http.ResponseWriter, r *http.Reque } } -func (e *EventsController) handleBitbucketCloudPost(w http.ResponseWriter, r *http.Request) { +func (e *VCSEventsController) handleBitbucketCloudPost(w http.ResponseWriter, r *http.Request) { eventType := r.Header.Get(bitbucketEventTypeHeader) reqID := r.Header.Get(bitbucketCloudRequestIDHeader) defer r.Body.Close() // nolint: errcheck @@ -182,7 +182,7 @@ func (e *EventsController) handleBitbucketCloudPost(w http.ResponseWriter, r *ht } } -func (e *EventsController) handleBitbucketServerPost(w http.ResponseWriter, r *http.Request) { +func (e *VCSEventsController) handleBitbucketServerPost(w http.ResponseWriter, r *http.Request) { eventType := r.Header.Get(bitbucketEventTypeHeader) reqID := r.Header.Get(bitbucketServerRequestIDHeader) sig := r.Header.Get(bitbucketServerSignatureHeader) @@ -218,7 +218,7 @@ func (e *EventsController) handleBitbucketServerPost(w http.ResponseWriter, r *h } } -func (e *EventsController) handleAzureDevopsPost(w http.ResponseWriter, r *http.Request) { +func (e *VCSEventsController) handleAzureDevopsPost(w http.ResponseWriter, r *http.Request) { // Validate the request against the optional basic auth username and password. payload, err := e.AzureDevopsRequestValidator.Validate(r, e.AzureDevopsWebhookBasicUser, e.AzureDevopsWebhookBasicPassword) if err != nil { @@ -247,7 +247,7 @@ func (e *EventsController) handleAzureDevopsPost(w http.ResponseWriter, r *http. // HandleGithubCommentEvent handles comment events from GitHub where Atlantis // commands can come from. It's exported to make testing easier. -func (e *EventsController) HandleGithubCommentEvent(w http.ResponseWriter, event *github.IssueCommentEvent, githubReqID string) { +func (e *VCSEventsController) HandleGithubCommentEvent(w http.ResponseWriter, event *github.IssueCommentEvent, githubReqID string) { if event.GetAction() != "created" { e.respond(w, logging.Debug, http.StatusOK, "Ignoring comment event since action was not created %s", githubReqID) return @@ -265,7 +265,7 @@ func (e *EventsController) HandleGithubCommentEvent(w http.ResponseWriter, event } // HandleBitbucketCloudCommentEvent handles comment events from Bitbucket. -func (e *EventsController) HandleBitbucketCloudCommentEvent(w http.ResponseWriter, body []byte, reqID string) { +func (e *VCSEventsController) HandleBitbucketCloudCommentEvent(w http.ResponseWriter, body []byte, reqID string) { pull, baseRepo, headRepo, user, comment, err := e.Parser.ParseBitbucketCloudPullCommentEvent(body) if err != nil { e.respond(w, logging.Error, http.StatusBadRequest, "Error parsing pull data: %s %s=%s", err, bitbucketCloudRequestIDHeader, reqID) @@ -275,7 +275,7 @@ func (e *EventsController) HandleBitbucketCloudCommentEvent(w http.ResponseWrite } // HandleBitbucketServerCommentEvent handles comment events from Bitbucket. -func (e *EventsController) HandleBitbucketServerCommentEvent(w http.ResponseWriter, body []byte, reqID string) { +func (e *VCSEventsController) HandleBitbucketServerCommentEvent(w http.ResponseWriter, body []byte, reqID string) { pull, baseRepo, headRepo, user, comment, err := e.Parser.ParseBitbucketServerPullCommentEvent(body) if err != nil { e.respond(w, logging.Error, http.StatusBadRequest, "Error parsing pull data: %s %s=%s", err, bitbucketCloudRequestIDHeader, reqID) @@ -284,7 +284,7 @@ func (e *EventsController) HandleBitbucketServerCommentEvent(w http.ResponseWrit e.handleCommentEvent(w, baseRepo, &headRepo, &pull, user, pull.Num, comment, models.BitbucketCloud) } -func (e *EventsController) handleBitbucketCloudPullRequestEvent(w http.ResponseWriter, eventType string, body []byte, reqID string) { +func (e *VCSEventsController) handleBitbucketCloudPullRequestEvent(w http.ResponseWriter, eventType string, body []byte, reqID string) { pull, baseRepo, headRepo, user, err := e.Parser.ParseBitbucketCloudPullEvent(body) if err != nil { e.respond(w, logging.Error, http.StatusBadRequest, "Error parsing pull data: %s %s=%s", err, bitbucketCloudRequestIDHeader, reqID) @@ -295,7 +295,7 @@ func (e *EventsController) handleBitbucketCloudPullRequestEvent(w http.ResponseW e.handlePullRequestEvent(w, baseRepo, headRepo, pull, user, pullEventType) } -func (e *EventsController) handleBitbucketServerPullRequestEvent(w http.ResponseWriter, eventType string, body []byte, reqID string) { +func (e *VCSEventsController) handleBitbucketServerPullRequestEvent(w http.ResponseWriter, eventType string, body []byte, reqID string) { pull, baseRepo, headRepo, user, err := e.Parser.ParseBitbucketServerPullEvent(body) if err != nil { e.respond(w, logging.Error, http.StatusBadRequest, "Error parsing pull data: %s %s=%s", err, bitbucketServerRequestIDHeader, reqID) @@ -309,7 +309,7 @@ func (e *EventsController) handleBitbucketServerPullRequestEvent(w http.Response // HandleGithubPullRequestEvent will delete any locks associated with the pull // request if the event is a pull request closed event. It's exported to make // testing easier. -func (e *EventsController) HandleGithubPullRequestEvent(w http.ResponseWriter, pullEvent *github.PullRequestEvent, githubReqID string) { +func (e *VCSEventsController) HandleGithubPullRequestEvent(w http.ResponseWriter, pullEvent *github.PullRequestEvent, githubReqID string) { pull, pullEventType, baseRepo, headRepo, user, err := e.Parser.ParseGithubPullEvent(pullEvent) if err != nil { e.respond(w, logging.Error, http.StatusBadRequest, "Error parsing pull data: %s %s", err, githubReqID) @@ -319,7 +319,7 @@ func (e *EventsController) HandleGithubPullRequestEvent(w http.ResponseWriter, p e.handlePullRequestEvent(w, baseRepo, headRepo, pull, user, pullEventType) } -func (e *EventsController) handlePullRequestEvent(w http.ResponseWriter, baseRepo models.Repo, headRepo models.Repo, pull models.PullRequest, user models.User, eventType models.PullRequestEventType) { +func (e *VCSEventsController) handlePullRequestEvent(w http.ResponseWriter, baseRepo models.Repo, headRepo models.Repo, pull models.PullRequest, user models.User, eventType models.PullRequestEventType) { if !e.RepoAllowlistChecker.IsAllowlisted(baseRepo.FullName, baseRepo.VCSHost.Hostname) { // If the repo isn't allowlisted and we receive an opened pull request // event we comment back on the pull request that the repo isn't @@ -367,7 +367,7 @@ func (e *EventsController) handlePullRequestEvent(w http.ResponseWriter, baseRep } } -func (e *EventsController) handleGitlabPost(w http.ResponseWriter, r *http.Request) { +func (e *VCSEventsController) handleGitlabPost(w http.ResponseWriter, r *http.Request) { event, err := e.GitlabRequestParserValidator.ParseAndValidate(r, e.GitlabWebhookSecret) if err != nil { e.respond(w, logging.Warn, http.StatusBadRequest, err.Error()) @@ -393,7 +393,7 @@ func (e *EventsController) handleGitlabPost(w http.ResponseWriter, r *http.Reque // HandleGitlabCommentEvent handles comment events from GitLab where Atlantis // commands can come from. It's exported to make testing easier. -func (e *EventsController) HandleGitlabCommentEvent(w http.ResponseWriter, event gitlab.MergeCommentEvent) { +func (e *VCSEventsController) HandleGitlabCommentEvent(w http.ResponseWriter, event gitlab.MergeCommentEvent) { // todo: can gitlab return the pull request here too? baseRepo, headRepo, user, err := e.Parser.ParseGitlabMergeRequestCommentEvent(event) if err != nil { @@ -403,7 +403,7 @@ func (e *EventsController) HandleGitlabCommentEvent(w http.ResponseWriter, event e.handleCommentEvent(w, baseRepo, &headRepo, nil, user, event.MergeRequest.IID, event.ObjectAttributes.Note, models.Gitlab) } -func (e *EventsController) handleCommentEvent(w http.ResponseWriter, baseRepo models.Repo, maybeHeadRepo *models.Repo, maybePull *models.PullRequest, user models.User, pullNum int, comment string, vcsHost models.VCSHostType) { +func (e *VCSEventsController) handleCommentEvent(w http.ResponseWriter, baseRepo models.Repo, maybeHeadRepo *models.Repo, maybePull *models.PullRequest, user models.User, pullNum int, comment string, vcsHost models.VCSHostType) { parseResult := e.CommentParser.Parse(comment, vcsHost) if parseResult.Ignore { truncated := comment @@ -452,7 +452,7 @@ func (e *EventsController) handleCommentEvent(w http.ResponseWriter, baseRepo mo // HandleGitlabMergeRequestEvent will delete any locks associated with the pull // request if the event is a merge request closed event. It's exported to make // testing easier. -func (e *EventsController) HandleGitlabMergeRequestEvent(w http.ResponseWriter, event gitlab.MergeEvent) { +func (e *VCSEventsController) HandleGitlabMergeRequestEvent(w http.ResponseWriter, event gitlab.MergeEvent) { pull, pullEventType, baseRepo, headRepo, user, err := e.Parser.ParseGitlabMergeRequestEvent(event) if err != nil { e.respond(w, logging.Error, http.StatusBadRequest, "Error parsing webhook: %s", err) @@ -466,7 +466,7 @@ func (e *EventsController) HandleGitlabMergeRequestEvent(w http.ResponseWriter, // commands can come from. It's exported to make testing easier. // Sometimes we may want data from the parent azuredevops.Event struct, so we handle type checking here. // Requires Resource Version 2.0 of the Pull Request Commented On webhook payload. -func (e *EventsController) HandleAzureDevopsPullRequestCommentedEvent(w http.ResponseWriter, event *azuredevops.Event, azuredevopsReqID string) { +func (e *VCSEventsController) HandleAzureDevopsPullRequestCommentedEvent(w http.ResponseWriter, event *azuredevops.Event, azuredevopsReqID string) { resource, ok := event.Resource.(*azuredevops.GitPullRequestWithComment) if !ok || event.PayloadType != azuredevops.PullRequestCommentedEvent { e.respond(w, logging.Error, http.StatusBadRequest, "Event.Resource is nil or received bad event type %v; %s", event.Resource, azuredevopsReqID) @@ -497,7 +497,7 @@ func (e *EventsController) HandleAzureDevopsPullRequestCommentedEvent(w http.Res // HandleAzureDevopsPullRequestEvent will delete any locks associated with the pull // request if the event is a pull request closed event. It's exported to make // testing easier. -func (e *EventsController) HandleAzureDevopsPullRequestEvent(w http.ResponseWriter, event *azuredevops.Event, azuredevopsReqID string) { +func (e *VCSEventsController) HandleAzureDevopsPullRequestEvent(w http.ResponseWriter, event *azuredevops.Event, azuredevopsReqID string) { prText := event.Message.GetText() ignoreEvents := []string{ "changed the reviewer list", @@ -525,7 +525,7 @@ func (e *EventsController) HandleAzureDevopsPullRequestEvent(w http.ResponseWrit } // supportsHost returns true if h is in e.SupportedVCSHosts and false otherwise. -func (e *EventsController) supportsHost(h models.VCSHostType) bool { +func (e *VCSEventsController) supportsHost(h models.VCSHostType) bool { for _, supported := range e.SupportedVCSHosts { if h == supported { return true @@ -534,7 +534,7 @@ func (e *EventsController) supportsHost(h models.VCSHostType) bool { return false } -func (e *EventsController) respond(w http.ResponseWriter, lvl logging.LogLevel, code int, format string, args ...interface{}) { +func (e *VCSEventsController) respond(w http.ResponseWriter, lvl logging.LogLevel, code int, format string, args ...interface{}) { response := fmt.Sprintf(format, args...) e.Logger.Log(lvl, response) w.WriteHeader(code) @@ -543,7 +543,7 @@ func (e *EventsController) respond(w http.ResponseWriter, lvl logging.LogLevel, // commentNotAllowlisted comments on the pull request that the repo is not // allowlisted unless allowlist error comments are disabled. -func (e *EventsController) commentNotAllowlisted(baseRepo models.Repo, pullNum int) { +func (e *VCSEventsController) commentNotAllowlisted(baseRepo models.Repo, pullNum int) { if e.SilenceAllowlistErrors { return } diff --git a/server/events_controller_e2e_test.go b/server/controllers/events/events_controller_e2e_test.go similarity index 97% rename from server/events_controller_e2e_test.go rename to server/controllers/events/events_controller_e2e_test.go index 3b1780baa..eabfda2c3 100644 --- a/server/events_controller_e2e_test.go +++ b/server/controllers/events/events_controller_e2e_test.go @@ -1,4 +1,4 @@ -package server_test +package events_test import ( "bytes" @@ -18,6 +18,7 @@ import ( "github.com/hashicorp/go-version" . "github.com/petergtz/pegomock" "github.com/runatlantis/atlantis/server" + events_controllers "github.com/runatlantis/atlantis/server/controllers/events" "github.com/runatlantis/atlantis/server/events" "github.com/runatlantis/atlantis/server/events/db" "github.com/runatlantis/atlantis/server/events/locking" @@ -400,7 +401,7 @@ func TestGitHubWorkflow(t *testing.T) { // First, send the open pull request event which triggers autoplan. pullOpenedReq := GitHubPullRequestOpenedEvent(t, headSHA) ctrl.Post(w, pullOpenedReq) - responseContains(t, w, 200, "Processing...") + ResponseContains(t, w, 200, "Processing...") // Create global apply lock if required if c.ApplyLock { @@ -412,7 +413,7 @@ func TestGitHubWorkflow(t *testing.T) { commentReq := GitHubCommentEvent(t, comment) w = httptest.NewRecorder() ctrl.Post(w, commentReq) - responseContains(t, w, 200, "Processing...") + ResponseContains(t, w, 200, "Processing...") } // Send the "pull closed" event which would be triggered by the @@ -420,7 +421,7 @@ func TestGitHubWorkflow(t *testing.T) { pullClosedReq := GitHubPullRequestClosedEvent(t) w = httptest.NewRecorder() ctrl.Post(w, pullClosedReq) - responseContains(t, w, 200, "Pull request cleaned successfully") + ResponseContains(t, w, 200, "Pull request cleaned successfully") // Let's verify the pre-workflow hook was called for each comment including the pull request opened event mockPreWorkflowHookRunner.VerifyWasCalled(Times(len(c.Comments)+1)).Run(runtimematchers.AnyModelsPreWorkflowHookCommandContext(), EqString("some dummy command"), AnyString()) @@ -587,14 +588,14 @@ func TestGitHubWorkflowWithPolicyCheck(t *testing.T) { // First, send the open pull request event which triggers autoplan. pullOpenedReq := GitHubPullRequestOpenedEvent(t, headSHA) ctrl.Post(w, pullOpenedReq) - responseContains(t, w, 200, "Processing...") + ResponseContains(t, w, 200, "Processing...") // Now send any other comments. for _, comment := range c.Comments { commentReq := GitHubCommentEvent(t, comment) w = httptest.NewRecorder() ctrl.Post(w, commentReq) - responseContains(t, w, 200, "Processing...") + ResponseContains(t, w, 200, "Processing...") } // Send the "pull closed" event which would be triggered by the @@ -602,7 +603,7 @@ func TestGitHubWorkflowWithPolicyCheck(t *testing.T) { pullClosedReq := GitHubPullRequestClosedEvent(t) w = httptest.NewRecorder() ctrl.Post(w, pullClosedReq) - responseContains(t, w, 200, "Pull request cleaned successfully") + ResponseContains(t, w, 200, "Pull request cleaned successfully") // Now we're ready to verify Atlantis made all the comments back (or // replies) that we expect. We expect each plan to have 2 comments, @@ -642,7 +643,7 @@ func TestGitHubWorkflowWithPolicyCheck(t *testing.T) { } } -func setupE2E(t *testing.T, repoDir string) (server.EventsController, *vcsmocks.MockClient, *mocks.MockGithubPullGetter, *events.FileWorkspace) { +func setupE2E(t *testing.T, repoDir string) (events_controllers.VCSEventsController, *vcsmocks.MockClient, *mocks.MockGithubPullGetter, *events.FileWorkspace) { allowForkPRs := false dataDir, binDir, cacheDir, cleanup := mkSubDirs(t) defer cleanup() @@ -881,7 +882,7 @@ func setupE2E(t *testing.T, repoDir string) (server.EventsController, *vcsmocks. repoAllowlistChecker, err := events.NewRepoAllowlistChecker("*") Ok(t, err) - ctrl := server.EventsController{ + ctrl := events_controllers.VCSEventsController{ TestingMode: true, CommandRunner: commandRunner, PullCleaner: &events.PullClosedExecutor{ @@ -894,8 +895,8 @@ func setupE2E(t *testing.T, repoDir string) (server.EventsController, *vcsmocks. Parser: eventParser, CommentParser: commentParser, GithubWebhookSecret: nil, - GithubRequestValidator: &server.DefaultGithubRequestValidator{}, - GitlabRequestParserValidator: &server.DefaultGitlabRequestParserValidator{}, + GithubRequestValidator: &events_controllers.DefaultGithubRequestValidator{}, + GitlabRequestParserValidator: &events_controllers.DefaultGitlabRequestParserValidator{}, GitlabWebhookSecret: nil, RepoAllowlistChecker: repoAllowlistChecker, SupportedVCSHosts: []models.VCSHostType{models.Gitlab, models.Github, models.BitbucketCloud}, diff --git a/server/events_controller_test.go b/server/controllers/events/events_controller_test.go similarity index 90% rename from server/events_controller_test.go rename to server/controllers/events/events_controller_test.go index 0b8ab903e..2ff5b1e4a 100644 --- a/server/events_controller_test.go +++ b/server/controllers/events/events_controller_test.go @@ -11,7 +11,7 @@ // limitations under the License. // Modified hereafter by contributors to runatlantis/atlantis. -package server_test +package events_test import ( "bytes" @@ -21,18 +21,19 @@ import ( "net/http" "net/http/httptest" "path/filepath" + "reflect" "strings" "testing" . "github.com/petergtz/pegomock" - "github.com/runatlantis/atlantis/server" + events_controllers "github.com/runatlantis/atlantis/server/controllers/events" + "github.com/runatlantis/atlantis/server/controllers/events/mocks" "github.com/runatlantis/atlantis/server/events" emocks "github.com/runatlantis/atlantis/server/events/mocks" "github.com/runatlantis/atlantis/server/events/mocks/matchers" "github.com/runatlantis/atlantis/server/events/models" vcsmocks "github.com/runatlantis/atlantis/server/events/vcs/mocks" "github.com/runatlantis/atlantis/server/logging" - "github.com/runatlantis/atlantis/server/mocks" . "github.com/runatlantis/atlantis/testing" gitlab "github.com/xanzy/go-gitlab" ) @@ -43,13 +44,18 @@ const azuredevopsHeader = "Request-Id" var secret = []byte("secret") +func AnyRepo() models.Repo { + RegisterMatcher(NewAnyMatcher(reflect.TypeOf(models.Repo{}))) + return models.Repo{} +} + func TestPost_NotGithubOrGitlab(t *testing.T) { t.Log("when the request is not for gitlab or github a 400 is returned") e, _, _, _, _, _, _, _ := setup(t) w := httptest.NewRecorder() req, _ := http.NewRequest("GET", "", bytes.NewBuffer(nil)) e.Post(w, req) - responseContains(t, w, http.StatusBadRequest, "Ignoring request") + ResponseContains(t, w, http.StatusBadRequest, "Ignoring request") } func TestPost_UnsupportedVCSGithub(t *testing.T) { @@ -60,7 +66,7 @@ func TestPost_UnsupportedVCSGithub(t *testing.T) { req.Header.Set(githubHeader, "value") w := httptest.NewRecorder() e.Post(w, req) - responseContains(t, w, http.StatusBadRequest, "Ignoring request since not configured to support GitHub") + ResponseContains(t, w, http.StatusBadRequest, "Ignoring request since not configured to support GitHub") } func TestPost_UnsupportedVCSGitlab(t *testing.T) { @@ -71,7 +77,7 @@ func TestPost_UnsupportedVCSGitlab(t *testing.T) { req.Header.Set(gitlabHeader, "value") w := httptest.NewRecorder() e.Post(w, req) - responseContains(t, w, http.StatusBadRequest, "Ignoring request since not configured to support GitLab") + ResponseContains(t, w, http.StatusBadRequest, "Ignoring request since not configured to support GitLab") } func TestPost_InvalidGithubSecret(t *testing.T) { @@ -82,7 +88,7 @@ func TestPost_InvalidGithubSecret(t *testing.T) { req.Header.Set(githubHeader, "value") When(v.Validate(req, secret)).ThenReturn(nil, errors.New("err")) e.Post(w, req) - responseContains(t, w, http.StatusBadRequest, "err") + ResponseContains(t, w, http.StatusBadRequest, "err") } func TestPost_InvalidGitlabSecret(t *testing.T) { @@ -93,7 +99,7 @@ func TestPost_InvalidGitlabSecret(t *testing.T) { req.Header.Set(gitlabHeader, "value") When(gl.ParseAndValidate(req, secret)).ThenReturn(nil, errors.New("err")) e.Post(w, req) - responseContains(t, w, http.StatusBadRequest, "err") + ResponseContains(t, w, http.StatusBadRequest, "err") } func TestPost_UnsupportedGithubEvent(t *testing.T) { @@ -104,7 +110,7 @@ func TestPost_UnsupportedGithubEvent(t *testing.T) { req.Header.Set(githubHeader, "value") When(v.Validate(req, nil)).ThenReturn([]byte(`{"not an event": ""}`), nil) e.Post(w, req) - responseContains(t, w, http.StatusOK, "Ignoring unsupported event") + ResponseContains(t, w, http.StatusOK, "Ignoring unsupported event") } func TestPost_UnsupportedGitlabEvent(t *testing.T) { @@ -115,7 +121,7 @@ func TestPost_UnsupportedGitlabEvent(t *testing.T) { req.Header.Set(gitlabHeader, "value") When(gl.ParseAndValidate(req, secret)).ThenReturn([]byte(`{"not an event": ""}`), nil) e.Post(w, req) - responseContains(t, w, http.StatusOK, "Ignoring unsupported event") + ResponseContains(t, w, http.StatusOK, "Ignoring unsupported event") } // Test that if the comment comes from a commit rather than a merge request, @@ -127,7 +133,7 @@ func TestPost_GitlabCommentOnCommit(t *testing.T) { req.Header.Set(gitlabHeader, "value") When(gl.ParseAndValidate(req, secret)).ThenReturn(gitlab.CommitCommentEvent{}, nil) e.Post(w, req) - responseContains(t, w, http.StatusOK, "Ignoring comment on commit event") + ResponseContains(t, w, http.StatusOK, "Ignoring comment on commit event") } func TestPost_GithubCommentNotCreated(t *testing.T) { @@ -140,7 +146,7 @@ func TestPost_GithubCommentNotCreated(t *testing.T) { When(v.Validate(req, secret)).ThenReturn([]byte(event), nil) w := httptest.NewRecorder() e.Post(w, req) - responseContains(t, w, http.StatusOK, "Ignoring comment event since action was not created") + ResponseContains(t, w, http.StatusOK, "Ignoring comment event since action was not created") } func TestPost_GithubInvalidComment(t *testing.T) { @@ -153,7 +159,7 @@ func TestPost_GithubInvalidComment(t *testing.T) { When(p.ParseGithubIssueCommentEvent(matchers.AnyPtrToGithubIssueCommentEvent())).ThenReturn(models.Repo{}, models.User{}, 1, errors.New("err")) w := httptest.NewRecorder() e.Post(w, req) - responseContains(t, w, http.StatusBadRequest, "Failed parsing event") + ResponseContains(t, w, http.StatusBadRequest, "Failed parsing event") } func TestPost_GitlabCommentInvalidCommand(t *testing.T) { @@ -165,7 +171,7 @@ func TestPost_GitlabCommentInvalidCommand(t *testing.T) { When(cp.Parse("", models.Gitlab)).ThenReturn(events.CommentParseResult{Ignore: true}) w := httptest.NewRecorder() e.Post(w, req) - responseContains(t, w, http.StatusOK, "Ignoring non-command comment: \"\"") + ResponseContains(t, w, http.StatusOK, "Ignoring non-command comment: \"\"") } func TestPost_GithubCommentInvalidCommand(t *testing.T) { @@ -179,17 +185,17 @@ func TestPost_GithubCommentInvalidCommand(t *testing.T) { When(cp.Parse("", models.Github)).ThenReturn(events.CommentParseResult{Ignore: true}) w := httptest.NewRecorder() e.Post(w, req) - responseContains(t, w, http.StatusOK, "Ignoring non-command comment: \"\"") + ResponseContains(t, w, http.StatusOK, "Ignoring non-command comment: \"\"") } func TestPost_GitlabCommentNotAllowlisted(t *testing.T) { t.Log("when the event is a gitlab comment from a repo that isn't allowlisted we comment with an error") RegisterMockTestingT(t) vcsClient := vcsmocks.NewMockClient() - e := server.EventsController{ + e := events_controllers.VCSEventsController{ Logger: logging.NewNoopLogger(t), CommentParser: &events.CommentParser{}, - GitlabRequestParserValidator: &server.DefaultGitlabRequestParserValidator{}, + GitlabRequestParserValidator: &events_controllers.DefaultGitlabRequestParserValidator{}, Parser: &events.EventParser{}, SupportedVCSHosts: []models.VCSHostType{models.Gitlab}, RepoAllowlistChecker: &events.RepoAllowlistChecker{}, @@ -214,10 +220,10 @@ func TestPost_GitlabCommentNotAllowlistedWithSilenceErrors(t *testing.T) { t.Log("when the event is a gitlab comment from a repo that isn't allowlisted and we are silencing errors, do not comment with an error") RegisterMockTestingT(t) vcsClient := vcsmocks.NewMockClient() - e := server.EventsController{ + e := events_controllers.VCSEventsController{ Logger: logging.NewNoopLogger(t), CommentParser: &events.CommentParser{}, - GitlabRequestParserValidator: &server.DefaultGitlabRequestParserValidator{}, + GitlabRequestParserValidator: &events_controllers.DefaultGitlabRequestParserValidator{}, Parser: &events.EventParser{}, SupportedVCSHosts: []models.VCSHostType{models.Gitlab}, RepoAllowlistChecker: &events.RepoAllowlistChecker{}, @@ -243,9 +249,9 @@ func TestPost_GithubCommentNotAllowlisted(t *testing.T) { t.Log("when the event is a github comment from a repo that isn't allowlisted we comment with an error") RegisterMockTestingT(t) vcsClient := vcsmocks.NewMockClient() - e := server.EventsController{ + e := events_controllers.VCSEventsController{ Logger: logging.NewNoopLogger(t), - GithubRequestValidator: &server.DefaultGithubRequestValidator{}, + GithubRequestValidator: &events_controllers.DefaultGithubRequestValidator{}, CommentParser: &events.CommentParser{}, Parser: &events.EventParser{}, SupportedVCSHosts: []models.VCSHostType{models.Github}, @@ -272,9 +278,9 @@ func TestPost_GithubCommentNotAllowlistedWithSilenceErrors(t *testing.T) { t.Log("when the event is a github comment from a repo that isn't allowlisted and we are silencing errors, do not comment with an error") RegisterMockTestingT(t) vcsClient := vcsmocks.NewMockClient() - e := server.EventsController{ + e := events_controllers.VCSEventsController{ Logger: logging.NewNoopLogger(t), - GithubRequestValidator: &server.DefaultGithubRequestValidator{}, + GithubRequestValidator: &events_controllers.DefaultGithubRequestValidator{}, CommentParser: &events.CommentParser{}, Parser: &events.EventParser{}, SupportedVCSHosts: []models.VCSHostType{models.Github}, @@ -307,7 +313,7 @@ func TestPost_GitlabCommentResponse(t *testing.T) { w := httptest.NewRecorder() e.Post(w, req) vcsClient.VerifyWasCalledOnce().CreateComment(models.Repo{}, 0, "a comment", "") - responseContains(t, w, http.StatusOK, "Commenting back on pull request") + ResponseContains(t, w, http.StatusOK, "Commenting back on pull request") } func TestPost_GithubCommentResponse(t *testing.T) { @@ -325,7 +331,7 @@ func TestPost_GithubCommentResponse(t *testing.T) { e.Post(w, req) vcsClient.VerifyWasCalledOnce().CreateComment(baseRepo, 1, "a comment", "") - responseContains(t, w, http.StatusOK, "Commenting back on pull request") + ResponseContains(t, w, http.StatusOK, "Commenting back on pull request") } func TestPost_GitlabCommentSuccess(t *testing.T) { @@ -336,7 +342,7 @@ func TestPost_GitlabCommentSuccess(t *testing.T) { When(gl.ParseAndValidate(req, secret)).ThenReturn(gitlab.MergeCommentEvent{}, nil) w := httptest.NewRecorder() e.Post(w, req) - responseContains(t, w, http.StatusOK, "Processing...") + ResponseContains(t, w, http.StatusOK, "Processing...") cr.VerifyWasCalledOnce().RunCommentCommand(models.Repo{}, &models.Repo{}, nil, models.User{}, 0, nil) } @@ -355,7 +361,7 @@ func TestPost_GithubCommentSuccess(t *testing.T) { When(cp.Parse("", models.Github)).ThenReturn(events.CommentParseResult{Command: &cmd}) w := httptest.NewRecorder() e.Post(w, req) - responseContains(t, w, http.StatusOK, "Processing...") + ResponseContains(t, w, http.StatusOK, "Processing...") cr.VerifyWasCalledOnce().RunCommentCommand(baseRepo, nil, nil, user, 1, &cmd) } @@ -371,7 +377,7 @@ func TestPost_GithubPullRequestInvalid(t *testing.T) { When(p.ParseGithubPullEvent(matchers.AnyPtrToGithubPullRequestEvent())).ThenReturn(models.PullRequest{}, models.OpenedPullEvent, models.Repo{}, models.Repo{}, models.User{}, errors.New("err")) w := httptest.NewRecorder() e.Post(w, req) - responseContains(t, w, http.StatusBadRequest, "Error parsing pull data: err") + ResponseContains(t, w, http.StatusBadRequest, "Error parsing pull data: err") } func TestPost_GitlabMergeRequestInvalid(t *testing.T) { @@ -385,7 +391,7 @@ func TestPost_GitlabMergeRequestInvalid(t *testing.T) { When(p.ParseGitlabMergeRequestEvent(gitlab.MergeEvent{})).ThenReturn(pullRequest, models.OpenedPullEvent, repo, repo, models.User{}, errors.New("err")) w := httptest.NewRecorder() e.Post(w, req) - responseContains(t, w, http.StatusBadRequest, "Error parsing webhook: err") + ResponseContains(t, w, http.StatusBadRequest, "Error parsing webhook: err") } func TestPost_GithubPullRequestNotAllowlisted(t *testing.T) { @@ -401,7 +407,7 @@ func TestPost_GithubPullRequestNotAllowlisted(t *testing.T) { When(v.Validate(req, secret)).ThenReturn([]byte(event), nil) w := httptest.NewRecorder() e.Post(w, req) - responseContains(t, w, http.StatusForbidden, "Ignoring pull request event from non-allowlisted repo") + ResponseContains(t, w, http.StatusForbidden, "Ignoring pull request event from non-allowlisted repo") } func TestPost_GitlabMergeRequestNotAllowlisted(t *testing.T) { @@ -420,7 +426,7 @@ func TestPost_GitlabMergeRequestNotAllowlisted(t *testing.T) { w := httptest.NewRecorder() e.Post(w, req) - responseContains(t, w, http.StatusForbidden, "Ignoring pull request event from non-allowlisted repo") + ResponseContains(t, w, http.StatusForbidden, "Ignoring pull request event from non-allowlisted repo") } func TestPost_GithubPullRequestUnsupportedAction(t *testing.T) { @@ -434,7 +440,7 @@ func TestPost_GithubPullRequestUnsupportedAction(t *testing.T) { w := httptest.NewRecorder() e.Parser = &events.EventParser{} e.Post(w, req) - responseContains(t, w, http.StatusOK, "Ignoring non-actionable pull request event") + ResponseContains(t, w, http.StatusOK, "Ignoring non-actionable pull request event") } func TestPost_GitlabMergeRequestUnsupportedAction(t *testing.T) { @@ -452,7 +458,7 @@ func TestPost_GitlabMergeRequestUnsupportedAction(t *testing.T) { w := httptest.NewRecorder() e.Post(w, req) - responseContains(t, w, http.StatusOK, "Ignoring non-actionable pull request event") + ResponseContains(t, w, http.StatusOK, "Ignoring non-actionable pull request event") } func TestPost_AzureDevopsPullRequestIgnoreEvent(t *testing.T) { @@ -469,7 +475,7 @@ func TestPost_AzureDevopsPullRequestIgnoreEvent(t *testing.T) { vcsmock := vcsmocks.NewMockClient() repoAllowlistChecker, err := events.NewRepoAllowlistChecker("*") Ok(t, err) - e := server.EventsController{ + e := events_controllers.VCSEventsController{ TestingMode: true, Logger: logging.NewNoopLogger(t), ApplyDisabled: false, @@ -528,7 +534,7 @@ func TestPost_AzureDevopsPullRequestIgnoreEvent(t *testing.T) { w := httptest.NewRecorder() e.Parser = &events.EventParser{} e.Post(w, req) - responseContains(t, w, http.StatusOK, "pull request updated event is not a supported type") + ResponseContains(t, w, http.StatusOK, "pull request updated event is not a supported type") }) } } @@ -549,7 +555,7 @@ func TestPost_GithubPullRequestClosedErrCleaningPull(t *testing.T) { When(c.CleanUpPull(repo, pull)).ThenReturn(errors.New("cleanup err")) w := httptest.NewRecorder() e.Post(w, req) - responseContains(t, w, http.StatusInternalServerError, "Error cleaning pull request: cleanup err") + ResponseContains(t, w, http.StatusInternalServerError, "Error cleaning pull request: cleanup err") } func TestPost_GitlabMergeRequestClosedErrCleaningPull(t *testing.T) { @@ -567,7 +573,7 @@ func TestPost_GitlabMergeRequestClosedErrCleaningPull(t *testing.T) { When(c.CleanUpPull(repo, pullRequest)).ThenReturn(errors.New("err")) w := httptest.NewRecorder() e.Post(w, req) - responseContains(t, w, http.StatusInternalServerError, "Error cleaning pull request: err") + ResponseContains(t, w, http.StatusInternalServerError, "Error cleaning pull request: err") } func TestPost_GithubClosedPullRequestSuccess(t *testing.T) { @@ -585,7 +591,7 @@ func TestPost_GithubClosedPullRequestSuccess(t *testing.T) { When(c.CleanUpPull(repo, pull)).ThenReturn(nil) w := httptest.NewRecorder() e.Post(w, req) - responseContains(t, w, http.StatusOK, "Pull request cleaned successfully") + ResponseContains(t, w, http.StatusOK, "Pull request cleaned successfully") } func TestPost_GitlabMergeRequestSuccess(t *testing.T) { @@ -600,7 +606,7 @@ func TestPost_GitlabMergeRequestSuccess(t *testing.T) { When(p.ParseGitlabMergeRequestEvent(gitlab.MergeEvent{})).ThenReturn(pullRequest, models.OpenedPullEvent, repo, repo, models.User{}, nil) w := httptest.NewRecorder() e.Post(w, req) - responseContains(t, w, http.StatusOK, "Pull request cleaned successfully") + ResponseContains(t, w, http.StatusOK, "Pull request cleaned successfully") } // Test Bitbucket server pull closed events. @@ -625,7 +631,7 @@ func TestPost_BBServerPullClosed(t *testing.T) { pullCleaner := emocks.NewMockPullCleaner() allowlist, err := events.NewRepoAllowlistChecker("*") Ok(t, err) - ec := &server.EventsController{ + ec := &events_controllers.VCSEventsController{ PullCleaner: pullCleaner, Parser: &events.EventParser{ BitbucketUser: "bb-user", @@ -654,7 +660,7 @@ func TestPost_BBServerPullClosed(t *testing.T) { ec.Post(w, req) // Make our assertions. - responseContains(t, w, 200, "Pull request cleaned successfully") + ResponseContains(t, w, 200, "Pull request cleaned successfully") expRepo := models.Repo{ FullName: "project/repository", @@ -736,13 +742,13 @@ func TestPost_PullOpenedOrUpdated(t *testing.T) { w := httptest.NewRecorder() e.Post(w, req) - responseContains(t, w, http.StatusOK, "Processing...") + ResponseContains(t, w, http.StatusOK, "Processing...") cr.VerifyWasCalledOnce().RunAutoplanCommand(models.Repo{}, models.Repo{}, models.PullRequest{State: models.ClosedPullState}, models.User{}) }) } } -func setup(t *testing.T) (server.EventsController, *mocks.MockGithubRequestValidator, *mocks.MockGitlabRequestParserValidator, *emocks.MockEventParsing, *emocks.MockCommandRunner, *emocks.MockPullCleaner, *vcsmocks.MockClient, *emocks.MockCommentParsing) { +func setup(t *testing.T) (events_controllers.VCSEventsController, *mocks.MockGithubRequestValidator, *mocks.MockGitlabRequestParserValidator, *emocks.MockEventParsing, *emocks.MockCommandRunner, *emocks.MockPullCleaner, *vcsmocks.MockClient, *emocks.MockCommentParsing) { RegisterMockTestingT(t) v := mocks.NewMockGithubRequestValidator() gl := mocks.NewMockGitlabRequestParserValidator() @@ -753,7 +759,7 @@ func setup(t *testing.T) (server.EventsController, *mocks.MockGithubRequestValid vcsmock := vcsmocks.NewMockClient() repoAllowlistChecker, err := events.NewRepoAllowlistChecker("*") Ok(t, err) - e := server.EventsController{ + e := events_controllers.VCSEventsController{ TestingMode: true, Logger: logging.NewNoopLogger(t), GithubRequestValidator: v, diff --git a/server/github_request_validator.go b/server/controllers/events/github_request_validator.go similarity index 99% rename from server/github_request_validator.go rename to server/controllers/events/github_request_validator.go index 6850b159c..0d5845c1e 100644 --- a/server/github_request_validator.go +++ b/server/controllers/events/github_request_validator.go @@ -11,7 +11,7 @@ // limitations under the License. // Modified hereafter by contributors to runatlantis/atlantis. -package server +package events import ( "errors" diff --git a/server/github_request_validator_test.go b/server/controllers/events/github_request_validator_test.go similarity index 91% rename from server/github_request_validator_test.go rename to server/controllers/events/github_request_validator_test.go index 0f2338810..71785bbd3 100644 --- a/server/github_request_validator_test.go +++ b/server/controllers/events/github_request_validator_test.go @@ -11,7 +11,7 @@ // limitations under the License. // Modified hereafter by contributors to runatlantis/atlantis. -package server_test +package events_test import ( "bytes" @@ -20,14 +20,14 @@ import ( "testing" . "github.com/petergtz/pegomock" - "github.com/runatlantis/atlantis/server" + "github.com/runatlantis/atlantis/server/controllers/events" . "github.com/runatlantis/atlantis/testing" ) func TestValidate_WithSecretErr(t *testing.T) { t.Log("if the request is not valid against the secret there is an error") RegisterMockTestingT(t) - g := server.DefaultGithubRequestValidator{} + g := events.DefaultGithubRequestValidator{} buf := bytes.NewBufferString("") req, err := http.NewRequest("POST", "http://localhost/event", buf) Ok(t, err) @@ -42,7 +42,7 @@ func TestValidate_WithSecretErr(t *testing.T) { func TestValidate_WithSecret(t *testing.T) { t.Log("if the request is valid against the secret the payload is returned") RegisterMockTestingT(t) - g := server.DefaultGithubRequestValidator{} + g := events.DefaultGithubRequestValidator{} buf := bytes.NewBufferString(`{"yo":true}`) req, err := http.NewRequest("POST", "http://localhost/event", buf) Ok(t, err) @@ -57,7 +57,7 @@ func TestValidate_WithSecret(t *testing.T) { func TestValidate_WithoutSecretInvalidContentType(t *testing.T) { t.Log("if the request has an invalid content type an error is returned") RegisterMockTestingT(t) - g := server.DefaultGithubRequestValidator{} + g := events.DefaultGithubRequestValidator{} buf := bytes.NewBufferString("") req, err := http.NewRequest("POST", "http://localhost/event", buf) Ok(t, err) @@ -71,7 +71,7 @@ func TestValidate_WithoutSecretInvalidContentType(t *testing.T) { func TestValidate_WithoutSecretJSON(t *testing.T) { t.Log("if the request is JSON the body is returned") RegisterMockTestingT(t) - g := server.DefaultGithubRequestValidator{} + g := events.DefaultGithubRequestValidator{} buf := bytes.NewBufferString(`{"yo":true}`) req, err := http.NewRequest("POST", "http://localhost/event", buf) Ok(t, err) @@ -85,7 +85,7 @@ func TestValidate_WithoutSecretJSON(t *testing.T) { func TestValidate_WithoutSecretFormNoPayload(t *testing.T) { t.Log("if the request is form encoded and does not contain a payload param an error is returned") RegisterMockTestingT(t) - g := server.DefaultGithubRequestValidator{} + g := events.DefaultGithubRequestValidator{} buf := bytes.NewBufferString("") req, err := http.NewRequest("POST", "http://localhost/event", buf) Ok(t, err) @@ -99,7 +99,7 @@ func TestValidate_WithoutSecretFormNoPayload(t *testing.T) { func TestValidate_WithoutSecretForm(t *testing.T) { t.Log("if the request is form encoded and does not contain a payload param an error is returned") RegisterMockTestingT(t) - g := server.DefaultGithubRequestValidator{} + g := events.DefaultGithubRequestValidator{} form := url.Values{} form.Set("payload", `{"yo":true}`) buf := bytes.NewBufferString(form.Encode()) diff --git a/server/gitlab_request_parser_validator.go b/server/controllers/events/gitlab_request_parser_validator.go similarity index 99% rename from server/gitlab_request_parser_validator.go rename to server/controllers/events/gitlab_request_parser_validator.go index 00b35a2fc..f1bffcceb 100644 --- a/server/gitlab_request_parser_validator.go +++ b/server/controllers/events/gitlab_request_parser_validator.go @@ -11,7 +11,7 @@ // limitations under the License. // Modified hereafter by contributors to runatlantis/atlantis. -package server +package events import ( "encoding/json" diff --git a/server/gitlab_request_parser_validator_test.go b/server/controllers/events/gitlab_request_parser_validator_test.go similarity index 99% rename from server/gitlab_request_parser_validator_test.go rename to server/controllers/events/gitlab_request_parser_validator_test.go index a0759b606..ae1269998 100644 --- a/server/gitlab_request_parser_validator_test.go +++ b/server/controllers/events/gitlab_request_parser_validator_test.go @@ -11,7 +11,7 @@ // limitations under the License. // Modified hereafter by contributors to runatlantis/atlantis. -package server_test +package events_test import ( "bytes" @@ -20,12 +20,12 @@ import ( "testing" . "github.com/petergtz/pegomock" - "github.com/runatlantis/atlantis/server" + "github.com/runatlantis/atlantis/server/controllers/events" . "github.com/runatlantis/atlantis/testing" gitlab "github.com/xanzy/go-gitlab" ) -var parser = server.DefaultGitlabRequestParserValidator{} +var parser = events.DefaultGitlabRequestParserValidator{} func TestValidate_InvalidSecret(t *testing.T) { t.Log("If the secret header is set and doesn't match expected an error is returned") diff --git a/server/mocks/matchers/ptr_to_http_request.go b/server/controllers/events/mocks/matchers/ptr_to_http_request.go similarity index 100% rename from server/mocks/matchers/ptr_to_http_request.go rename to server/controllers/events/mocks/matchers/ptr_to_http_request.go diff --git a/server/mocks/matchers/slice_of_byte.go b/server/controllers/events/mocks/matchers/slice_of_byte.go similarity index 100% rename from server/mocks/matchers/slice_of_byte.go rename to server/controllers/events/mocks/matchers/slice_of_byte.go diff --git a/server/mocks/mock_azuredevops_request_validator.go b/server/controllers/events/mocks/mock_azuredevops_request_validator.go similarity index 97% rename from server/mocks/mock_azuredevops_request_validator.go rename to server/controllers/events/mocks/mock_azuredevops_request_validator.go index ac84f5185..8d100d544 100644 --- a/server/mocks/mock_azuredevops_request_validator.go +++ b/server/controllers/events/mocks/mock_azuredevops_request_validator.go @@ -1,5 +1,5 @@ // Code generated by pegomock. DO NOT EDIT. -// Source: github.com/runatlantis/atlantis/server (interfaces: AzureDevopsRequestValidator) +// Source: github.com/runatlantis/atlantis/server/controllers/events (interfaces: AzureDevopsRequestValidator) package mocks diff --git a/server/mocks/mock_github_request_validator.go b/server/controllers/events/mocks/mock_github_request_validator.go similarity index 97% rename from server/mocks/mock_github_request_validator.go rename to server/controllers/events/mocks/mock_github_request_validator.go index 70e45e9e5..e36b79d74 100644 --- a/server/mocks/mock_github_request_validator.go +++ b/server/controllers/events/mocks/mock_github_request_validator.go @@ -1,5 +1,5 @@ // Code generated by pegomock. DO NOT EDIT. -// Source: github.com/runatlantis/atlantis/server (interfaces: GithubRequestValidator) +// Source: github.com/runatlantis/atlantis/server/controllers/events (interfaces: GithubRequestValidator) package mocks diff --git a/server/mocks/mock_gitlab_request_parser_validator.go b/server/controllers/events/mocks/mock_gitlab_request_parser_validator.go similarity index 97% rename from server/mocks/mock_gitlab_request_parser_validator.go rename to server/controllers/events/mocks/mock_gitlab_request_parser_validator.go index ac2db9856..5abefba54 100644 --- a/server/mocks/mock_gitlab_request_parser_validator.go +++ b/server/controllers/events/mocks/mock_gitlab_request_parser_validator.go @@ -1,5 +1,5 @@ // Code generated by pegomock. DO NOT EDIT. -// Source: github.com/runatlantis/atlantis/server (interfaces: GitlabRequestParserValidator) +// Source: github.com/runatlantis/atlantis/server/controllers/events (interfaces: GitlabRequestParserValidator) package mocks diff --git a/server/testfixtures/bb-server-pull-deleted-event.json b/server/controllers/events/testfixtures/bb-server-pull-deleted-event.json similarity index 100% rename from server/testfixtures/bb-server-pull-deleted-event.json rename to server/controllers/events/testfixtures/bb-server-pull-deleted-event.json diff --git a/server/testfixtures/githubIssueCommentEvent.json b/server/controllers/events/testfixtures/githubIssueCommentEvent.json similarity index 100% rename from server/testfixtures/githubIssueCommentEvent.json rename to server/controllers/events/testfixtures/githubIssueCommentEvent.json diff --git a/server/testfixtures/githubIssueCommentEvent_notAllowlisted.json b/server/controllers/events/testfixtures/githubIssueCommentEvent_notAllowlisted.json similarity index 100% rename from server/testfixtures/githubIssueCommentEvent_notAllowlisted.json rename to server/controllers/events/testfixtures/githubIssueCommentEvent_notAllowlisted.json diff --git a/server/testfixtures/githubPullRequestClosedEvent.json b/server/controllers/events/testfixtures/githubPullRequestClosedEvent.json similarity index 100% rename from server/testfixtures/githubPullRequestClosedEvent.json rename to server/controllers/events/testfixtures/githubPullRequestClosedEvent.json diff --git a/server/testfixtures/githubPullRequestOpenedEvent.json b/server/controllers/events/testfixtures/githubPullRequestOpenedEvent.json similarity index 100% rename from server/testfixtures/githubPullRequestOpenedEvent.json rename to server/controllers/events/testfixtures/githubPullRequestOpenedEvent.json diff --git a/server/testfixtures/gitlabMergeCommentEvent_notAllowlisted.json b/server/controllers/events/testfixtures/gitlabMergeCommentEvent_notAllowlisted.json similarity index 100% rename from server/testfixtures/gitlabMergeCommentEvent_notAllowlisted.json rename to server/controllers/events/testfixtures/gitlabMergeCommentEvent_notAllowlisted.json diff --git a/server/testfixtures/gitlabMergeCommentEvent_shouldIgnore.json b/server/controllers/events/testfixtures/gitlabMergeCommentEvent_shouldIgnore.json similarity index 100% rename from server/testfixtures/gitlabMergeCommentEvent_shouldIgnore.json rename to server/controllers/events/testfixtures/gitlabMergeCommentEvent_shouldIgnore.json diff --git a/server/testfixtures/test-repos/automerge/atlantis.yaml b/server/controllers/events/testfixtures/test-repos/automerge/atlantis.yaml similarity index 100% rename from server/testfixtures/test-repos/automerge/atlantis.yaml rename to server/controllers/events/testfixtures/test-repos/automerge/atlantis.yaml diff --git a/server/testfixtures/test-repos/automerge/dir1/main.tf b/server/controllers/events/testfixtures/test-repos/automerge/dir1/main.tf similarity index 100% rename from server/testfixtures/test-repos/automerge/dir1/main.tf rename to server/controllers/events/testfixtures/test-repos/automerge/dir1/main.tf diff --git a/server/testfixtures/test-repos/automerge/dir2/main.tf b/server/controllers/events/testfixtures/test-repos/automerge/dir2/main.tf similarity index 100% rename from server/testfixtures/test-repos/automerge/dir2/main.tf rename to server/controllers/events/testfixtures/test-repos/automerge/dir2/main.tf diff --git a/server/testfixtures/test-repos/automerge/exp-output-apply-dir1.txt b/server/controllers/events/testfixtures/test-repos/automerge/exp-output-apply-dir1.txt similarity index 100% rename from server/testfixtures/test-repos/automerge/exp-output-apply-dir1.txt rename to server/controllers/events/testfixtures/test-repos/automerge/exp-output-apply-dir1.txt diff --git a/server/controllers/events/testfixtures/test-repos/automerge/exp-output-apply-dir1.txt.act b/server/controllers/events/testfixtures/test-repos/automerge/exp-output-apply-dir1.txt.act new file mode 100644 index 000000000..19bf762f1 --- /dev/null +++ b/server/controllers/events/testfixtures/test-repos/automerge/exp-output-apply-dir1.txt.act @@ -0,0 +1,10 @@ +Ran Apply for dir: `dir1` workspace: `default` + +```diff +null_resource.automerge[0]: Creating... +null_resource.automerge[0]: Creation complete after *s [id=*******************] + +Apply complete! Resources: 1 added, 0 changed, 0 destroyed. + +``` + diff --git a/server/testfixtures/test-repos/automerge/exp-output-apply-dir2.txt b/server/controllers/events/testfixtures/test-repos/automerge/exp-output-apply-dir2.txt similarity index 100% rename from server/testfixtures/test-repos/automerge/exp-output-apply-dir2.txt rename to server/controllers/events/testfixtures/test-repos/automerge/exp-output-apply-dir2.txt diff --git a/server/controllers/events/testfixtures/test-repos/automerge/exp-output-apply-dir2.txt.act b/server/controllers/events/testfixtures/test-repos/automerge/exp-output-apply-dir2.txt.act new file mode 100644 index 000000000..f48696615 --- /dev/null +++ b/server/controllers/events/testfixtures/test-repos/automerge/exp-output-apply-dir2.txt.act @@ -0,0 +1,10 @@ +Ran Apply for dir: `dir2` workspace: `default` + +```diff +null_resource.automerge[0]: Creating... +null_resource.automerge[0]: Creation complete after *s [id=*******************] + +Apply complete! Resources: 1 added, 0 changed, 0 destroyed. + +``` + diff --git a/server/testfixtures/test-repos/automerge/exp-output-automerge.txt b/server/controllers/events/testfixtures/test-repos/automerge/exp-output-automerge.txt similarity index 100% rename from server/testfixtures/test-repos/automerge/exp-output-automerge.txt rename to server/controllers/events/testfixtures/test-repos/automerge/exp-output-automerge.txt diff --git a/server/testfixtures/test-repos/automerge/exp-output-autoplan.txt b/server/controllers/events/testfixtures/test-repos/automerge/exp-output-autoplan.txt similarity index 100% rename from server/testfixtures/test-repos/automerge/exp-output-autoplan.txt rename to server/controllers/events/testfixtures/test-repos/automerge/exp-output-autoplan.txt diff --git a/server/controllers/events/testfixtures/test-repos/automerge/exp-output-autoplan.txt.act b/server/controllers/events/testfixtures/test-repos/automerge/exp-output-autoplan.txt.act new file mode 100644 index 000000000..8aa62370f --- /dev/null +++ b/server/controllers/events/testfixtures/test-repos/automerge/exp-output-autoplan.txt.act @@ -0,0 +1,67 @@ +Ran Plan for 2 projects: + +1. dir: `dir1` workspace: `default` +1. dir: `dir2` workspace: `default` + +### 1. dir: `dir1` workspace: `default` +
Show Output + +```diff + +Terraform used the selected providers to generate the following execution +plan. Resource actions are indicated with the following symbols: ++ create + +Terraform will perform the following actions: + + # null_resource.automerge[0] will be created ++ resource "null_resource" "automerge" { + + id = (known after apply) + } + +Plan: 1 to add, 0 to change, 0 to destroy. + +``` + +* :arrow_forward: To **apply** this plan, comment: + * `atlantis apply -d dir1` +* :put_litter_in_its_place: To **delete** this plan click [here](lock-url) +* :repeat: To **plan** this project again, comment: + * `atlantis plan -d dir1` +
+Plan: 1 to add, 0 to change, 0 to destroy. + +--- +### 2. dir: `dir2` workspace: `default` +
Show Output + +```diff + +Terraform used the selected providers to generate the following execution +plan. Resource actions are indicated with the following symbols: ++ create + +Terraform will perform the following actions: + + # null_resource.automerge[0] will be created ++ resource "null_resource" "automerge" { + + id = (known after apply) + } + +Plan: 1 to add, 0 to change, 0 to destroy. + +``` + +* :arrow_forward: To **apply** this plan, comment: + * `atlantis apply -d dir2` +* :put_litter_in_its_place: To **delete** this plan click [here](lock-url) +* :repeat: To **plan** this project again, comment: + * `atlantis plan -d dir2` +
+Plan: 1 to add, 0 to change, 0 to destroy. + +--- +* :fast_forward: To **apply** all unapplied plans from this pull request, comment: + * `atlantis apply` +* :put_litter_in_its_place: To delete all plans and locks for the PR, comment: + * `atlantis unlock` diff --git a/server/testfixtures/test-repos/automerge/exp-output-merge.txt b/server/controllers/events/testfixtures/test-repos/automerge/exp-output-merge.txt similarity index 100% rename from server/testfixtures/test-repos/automerge/exp-output-merge.txt rename to server/controllers/events/testfixtures/test-repos/automerge/exp-output-merge.txt diff --git a/server/testfixtures/test-repos/modules-yaml/atlantis.yaml b/server/controllers/events/testfixtures/test-repos/modules-yaml/atlantis.yaml similarity index 100% rename from server/testfixtures/test-repos/modules-yaml/atlantis.yaml rename to server/controllers/events/testfixtures/test-repos/modules-yaml/atlantis.yaml diff --git a/server/testfixtures/test-repos/modules-yaml/exp-output-apply-production.txt b/server/controllers/events/testfixtures/test-repos/modules-yaml/exp-output-apply-production.txt similarity index 100% rename from server/testfixtures/test-repos/modules-yaml/exp-output-apply-production.txt rename to server/controllers/events/testfixtures/test-repos/modules-yaml/exp-output-apply-production.txt diff --git a/server/testfixtures/test-repos/modules/exp-output-apply-production.txt b/server/controllers/events/testfixtures/test-repos/modules-yaml/exp-output-apply-production.txt.act similarity index 100% rename from server/testfixtures/test-repos/modules/exp-output-apply-production.txt rename to server/controllers/events/testfixtures/test-repos/modules-yaml/exp-output-apply-production.txt.act diff --git a/server/testfixtures/test-repos/modules-yaml/exp-output-apply-staging.txt b/server/controllers/events/testfixtures/test-repos/modules-yaml/exp-output-apply-staging.txt similarity index 100% rename from server/testfixtures/test-repos/modules-yaml/exp-output-apply-staging.txt rename to server/controllers/events/testfixtures/test-repos/modules-yaml/exp-output-apply-staging.txt diff --git a/server/testfixtures/test-repos/modules/exp-output-apply-staging.txt b/server/controllers/events/testfixtures/test-repos/modules-yaml/exp-output-apply-staging.txt.act similarity index 100% rename from server/testfixtures/test-repos/modules/exp-output-apply-staging.txt rename to server/controllers/events/testfixtures/test-repos/modules-yaml/exp-output-apply-staging.txt.act diff --git a/server/testfixtures/test-repos/modules-yaml/exp-output-autoplan.txt b/server/controllers/events/testfixtures/test-repos/modules-yaml/exp-output-autoplan.txt similarity index 100% rename from server/testfixtures/test-repos/modules-yaml/exp-output-autoplan.txt rename to server/controllers/events/testfixtures/test-repos/modules-yaml/exp-output-autoplan.txt diff --git a/server/controllers/events/testfixtures/test-repos/modules-yaml/exp-output-autoplan.txt.act b/server/controllers/events/testfixtures/test-repos/modules-yaml/exp-output-autoplan.txt.act new file mode 100644 index 000000000..6b1c2e243 --- /dev/null +++ b/server/controllers/events/testfixtures/test-repos/modules-yaml/exp-output-autoplan.txt.act @@ -0,0 +1,73 @@ +Ran Plan for 2 projects: + +1. dir: `staging` workspace: `default` +1. dir: `production` workspace: `default` + +### 1. dir: `staging` workspace: `default` +
Show Output + +```diff + +Terraform used the selected providers to generate the following execution +plan. Resource actions are indicated with the following symbols: ++ create + +Terraform will perform the following actions: + + # module.null.null_resource.this will be created ++ resource "null_resource" "this" { + + id = (known after apply) + } + +Plan: 1 to add, 0 to change, 0 to destroy. + +Changes to Outputs: ++ var = "staging" + +``` + +* :arrow_forward: To **apply** this plan, comment: + * `atlantis apply -d staging` +* :put_litter_in_its_place: To **delete** this plan click [here](lock-url) +* :repeat: To **plan** this project again, comment: + * `atlantis plan -d staging` +
+Plan: 1 to add, 0 to change, 0 to destroy. + +--- +### 2. dir: `production` workspace: `default` +
Show Output + +```diff + +Terraform used the selected providers to generate the following execution +plan. Resource actions are indicated with the following symbols: ++ create + +Terraform will perform the following actions: + + # module.null.null_resource.this will be created ++ resource "null_resource" "this" { + + id = (known after apply) + } + +Plan: 1 to add, 0 to change, 0 to destroy. + +Changes to Outputs: ++ var = "production" + +``` + +* :arrow_forward: To **apply** this plan, comment: + * `atlantis apply -d production` +* :put_litter_in_its_place: To **delete** this plan click [here](lock-url) +* :repeat: To **plan** this project again, comment: + * `atlantis plan -d production` +
+Plan: 1 to add, 0 to change, 0 to destroy. + +--- +* :fast_forward: To **apply** all unapplied plans from this pull request, comment: + * `atlantis apply` +* :put_litter_in_its_place: To delete all plans and locks for the PR, comment: + * `atlantis unlock` diff --git a/server/testfixtures/test-repos/modules-yaml/exp-output-merge-all-dirs.txt b/server/controllers/events/testfixtures/test-repos/modules-yaml/exp-output-merge-all-dirs.txt similarity index 100% rename from server/testfixtures/test-repos/modules-yaml/exp-output-merge-all-dirs.txt rename to server/controllers/events/testfixtures/test-repos/modules-yaml/exp-output-merge-all-dirs.txt diff --git a/server/testfixtures/test-repos/modules-yaml/exp-output-merge-only-staging.txt b/server/controllers/events/testfixtures/test-repos/modules-yaml/exp-output-merge-only-staging.txt similarity index 100% rename from server/testfixtures/test-repos/modules-yaml/exp-output-merge-only-staging.txt rename to server/controllers/events/testfixtures/test-repos/modules-yaml/exp-output-merge-only-staging.txt diff --git a/server/testfixtures/test-repos/modules-yaml/exp-output-merge.txt b/server/controllers/events/testfixtures/test-repos/modules-yaml/exp-output-merge.txt similarity index 100% rename from server/testfixtures/test-repos/modules-yaml/exp-output-merge.txt rename to server/controllers/events/testfixtures/test-repos/modules-yaml/exp-output-merge.txt diff --git a/server/testfixtures/test-repos/modules-yaml/exp-output-plan-production.txt b/server/controllers/events/testfixtures/test-repos/modules-yaml/exp-output-plan-production.txt similarity index 100% rename from server/testfixtures/test-repos/modules-yaml/exp-output-plan-production.txt rename to server/controllers/events/testfixtures/test-repos/modules-yaml/exp-output-plan-production.txt diff --git a/server/testfixtures/test-repos/modules-yaml/exp-output-plan-staging.txt b/server/controllers/events/testfixtures/test-repos/modules-yaml/exp-output-plan-staging.txt similarity index 100% rename from server/testfixtures/test-repos/modules-yaml/exp-output-plan-staging.txt rename to server/controllers/events/testfixtures/test-repos/modules-yaml/exp-output-plan-staging.txt diff --git a/server/testfixtures/test-repos/modules-yaml/modules/null/main.tf b/server/controllers/events/testfixtures/test-repos/modules-yaml/modules/null/main.tf similarity index 100% rename from server/testfixtures/test-repos/modules-yaml/modules/null/main.tf rename to server/controllers/events/testfixtures/test-repos/modules-yaml/modules/null/main.tf diff --git a/server/testfixtures/test-repos/modules-yaml/production/main.tf b/server/controllers/events/testfixtures/test-repos/modules-yaml/production/main.tf similarity index 100% rename from server/testfixtures/test-repos/modules-yaml/production/main.tf rename to server/controllers/events/testfixtures/test-repos/modules-yaml/production/main.tf diff --git a/server/testfixtures/test-repos/modules-yaml/staging/main.tf b/server/controllers/events/testfixtures/test-repos/modules-yaml/staging/main.tf similarity index 100% rename from server/testfixtures/test-repos/modules-yaml/staging/main.tf rename to server/controllers/events/testfixtures/test-repos/modules-yaml/staging/main.tf diff --git a/server/controllers/events/testfixtures/test-repos/modules/exp-output-apply-production.txt b/server/controllers/events/testfixtures/test-repos/modules/exp-output-apply-production.txt new file mode 100644 index 000000000..4885579d1 --- /dev/null +++ b/server/controllers/events/testfixtures/test-repos/modules/exp-output-apply-production.txt @@ -0,0 +1,14 @@ +Ran Apply for dir: `production` workspace: `default` + +```diff +module.null.null_resource.this: Creating... +module.null.null_resource.this: Creation complete after *s [id=*******************] + +Apply complete! Resources: 1 added, 0 changed, 0 destroyed. + +Outputs: + +var = "production" + +``` + diff --git a/server/controllers/events/testfixtures/test-repos/modules/exp-output-apply-production.txt.act b/server/controllers/events/testfixtures/test-repos/modules/exp-output-apply-production.txt.act new file mode 100644 index 000000000..4885579d1 --- /dev/null +++ b/server/controllers/events/testfixtures/test-repos/modules/exp-output-apply-production.txt.act @@ -0,0 +1,14 @@ +Ran Apply for dir: `production` workspace: `default` + +```diff +module.null.null_resource.this: Creating... +module.null.null_resource.this: Creation complete after *s [id=*******************] + +Apply complete! Resources: 1 added, 0 changed, 0 destroyed. + +Outputs: + +var = "production" + +``` + diff --git a/server/controllers/events/testfixtures/test-repos/modules/exp-output-apply-staging.txt b/server/controllers/events/testfixtures/test-repos/modules/exp-output-apply-staging.txt new file mode 100644 index 000000000..44d7f3714 --- /dev/null +++ b/server/controllers/events/testfixtures/test-repos/modules/exp-output-apply-staging.txt @@ -0,0 +1,14 @@ +Ran Apply for dir: `staging` workspace: `default` + +```diff +module.null.null_resource.this: Creating... +module.null.null_resource.this: Creation complete after *s [id=*******************] + +Apply complete! Resources: 1 added, 0 changed, 0 destroyed. + +Outputs: + +var = "staging" + +``` + diff --git a/server/controllers/events/testfixtures/test-repos/modules/exp-output-apply-staging.txt.act b/server/controllers/events/testfixtures/test-repos/modules/exp-output-apply-staging.txt.act new file mode 100644 index 000000000..44d7f3714 --- /dev/null +++ b/server/controllers/events/testfixtures/test-repos/modules/exp-output-apply-staging.txt.act @@ -0,0 +1,14 @@ +Ran Apply for dir: `staging` workspace: `default` + +```diff +module.null.null_resource.this: Creating... +module.null.null_resource.this: Creation complete after *s [id=*******************] + +Apply complete! Resources: 1 added, 0 changed, 0 destroyed. + +Outputs: + +var = "staging" + +``` + diff --git a/server/testfixtures/test-repos/modules/exp-output-autoplan-only-staging.txt b/server/controllers/events/testfixtures/test-repos/modules/exp-output-autoplan-only-staging.txt similarity index 100% rename from server/testfixtures/test-repos/modules/exp-output-autoplan-only-staging.txt rename to server/controllers/events/testfixtures/test-repos/modules/exp-output-autoplan-only-staging.txt diff --git a/server/testfixtures/test-repos/modules/exp-output-plan-staging.txt b/server/controllers/events/testfixtures/test-repos/modules/exp-output-autoplan-only-staging.txt.act similarity index 100% rename from server/testfixtures/test-repos/modules/exp-output-plan-staging.txt rename to server/controllers/events/testfixtures/test-repos/modules/exp-output-autoplan-only-staging.txt.act diff --git a/server/testfixtures/test-repos/modules/exp-output-merge-all-dirs.txt b/server/controllers/events/testfixtures/test-repos/modules/exp-output-merge-all-dirs.txt similarity index 100% rename from server/testfixtures/test-repos/modules/exp-output-merge-all-dirs.txt rename to server/controllers/events/testfixtures/test-repos/modules/exp-output-merge-all-dirs.txt diff --git a/server/testfixtures/test-repos/modules/exp-output-merge-only-staging.txt b/server/controllers/events/testfixtures/test-repos/modules/exp-output-merge-only-staging.txt similarity index 100% rename from server/testfixtures/test-repos/modules/exp-output-merge-only-staging.txt rename to server/controllers/events/testfixtures/test-repos/modules/exp-output-merge-only-staging.txt diff --git a/server/testfixtures/test-repos/modules/exp-output-merge.txt b/server/controllers/events/testfixtures/test-repos/modules/exp-output-merge.txt similarity index 100% rename from server/testfixtures/test-repos/modules/exp-output-merge.txt rename to server/controllers/events/testfixtures/test-repos/modules/exp-output-merge.txt diff --git a/server/testfixtures/test-repos/modules/exp-output-plan-production.txt b/server/controllers/events/testfixtures/test-repos/modules/exp-output-plan-production.txt similarity index 100% rename from server/testfixtures/test-repos/modules/exp-output-plan-production.txt rename to server/controllers/events/testfixtures/test-repos/modules/exp-output-plan-production.txt diff --git a/server/controllers/events/testfixtures/test-repos/modules/exp-output-plan-production.txt.act b/server/controllers/events/testfixtures/test-repos/modules/exp-output-plan-production.txt.act new file mode 100644 index 000000000..e238d50a4 --- /dev/null +++ b/server/controllers/events/testfixtures/test-repos/modules/exp-output-plan-production.txt.act @@ -0,0 +1,37 @@ +Ran Plan for dir: `production` workspace: `default` + +
Show Output + +```diff + +Terraform used the selected providers to generate the following execution +plan. Resource actions are indicated with the following symbols: ++ create + +Terraform will perform the following actions: + + # module.null.null_resource.this will be created ++ resource "null_resource" "this" { + + id = (known after apply) + } + +Plan: 1 to add, 0 to change, 0 to destroy. + +Changes to Outputs: ++ var = "production" + +``` + +* :arrow_forward: To **apply** this plan, comment: + * `atlantis apply -d production` +* :put_litter_in_its_place: To **delete** this plan click [here](lock-url) +* :repeat: To **plan** this project again, comment: + * `atlantis plan -d production` +
+Plan: 1 to add, 0 to change, 0 to destroy. + +--- +* :fast_forward: To **apply** all unapplied plans from this pull request, comment: + * `atlantis apply` +* :put_litter_in_its_place: To delete all plans and locks for the PR, comment: + * `atlantis unlock` diff --git a/server/controllers/events/testfixtures/test-repos/modules/exp-output-plan-staging.txt b/server/controllers/events/testfixtures/test-repos/modules/exp-output-plan-staging.txt new file mode 100644 index 000000000..50f8aca13 --- /dev/null +++ b/server/controllers/events/testfixtures/test-repos/modules/exp-output-plan-staging.txt @@ -0,0 +1,37 @@ +Ran Plan for dir: `staging` workspace: `default` + +
Show Output + +```diff + +Terraform used the selected providers to generate the following execution +plan. Resource actions are indicated with the following symbols: ++ create + +Terraform will perform the following actions: + + # module.null.null_resource.this will be created ++ resource "null_resource" "this" { + + id = (known after apply) + } + +Plan: 1 to add, 0 to change, 0 to destroy. + +Changes to Outputs: ++ var = "staging" + +``` + +* :arrow_forward: To **apply** this plan, comment: + * `atlantis apply -d staging` +* :put_litter_in_its_place: To **delete** this plan click [here](lock-url) +* :repeat: To **plan** this project again, comment: + * `atlantis plan -d staging` +
+Plan: 1 to add, 0 to change, 0 to destroy. + +--- +* :fast_forward: To **apply** all unapplied plans from this pull request, comment: + * `atlantis apply` +* :put_litter_in_its_place: To delete all plans and locks for the PR, comment: + * `atlantis unlock` diff --git a/server/controllers/events/testfixtures/test-repos/modules/exp-output-plan-staging.txt.act b/server/controllers/events/testfixtures/test-repos/modules/exp-output-plan-staging.txt.act new file mode 100644 index 000000000..50f8aca13 --- /dev/null +++ b/server/controllers/events/testfixtures/test-repos/modules/exp-output-plan-staging.txt.act @@ -0,0 +1,37 @@ +Ran Plan for dir: `staging` workspace: `default` + +
Show Output + +```diff + +Terraform used the selected providers to generate the following execution +plan. Resource actions are indicated with the following symbols: ++ create + +Terraform will perform the following actions: + + # module.null.null_resource.this will be created ++ resource "null_resource" "this" { + + id = (known after apply) + } + +Plan: 1 to add, 0 to change, 0 to destroy. + +Changes to Outputs: ++ var = "staging" + +``` + +* :arrow_forward: To **apply** this plan, comment: + * `atlantis apply -d staging` +* :put_litter_in_its_place: To **delete** this plan click [here](lock-url) +* :repeat: To **plan** this project again, comment: + * `atlantis plan -d staging` +
+Plan: 1 to add, 0 to change, 0 to destroy. + +--- +* :fast_forward: To **apply** all unapplied plans from this pull request, comment: + * `atlantis apply` +* :put_litter_in_its_place: To delete all plans and locks for the PR, comment: + * `atlantis unlock` diff --git a/server/testfixtures/test-repos/modules/modules/null/main.tf b/server/controllers/events/testfixtures/test-repos/modules/modules/null/main.tf similarity index 100% rename from server/testfixtures/test-repos/modules/modules/null/main.tf rename to server/controllers/events/testfixtures/test-repos/modules/modules/null/main.tf diff --git a/server/testfixtures/test-repos/modules/production/main.tf b/server/controllers/events/testfixtures/test-repos/modules/production/main.tf similarity index 100% rename from server/testfixtures/test-repos/modules/production/main.tf rename to server/controllers/events/testfixtures/test-repos/modules/production/main.tf diff --git a/server/testfixtures/test-repos/modules/staging/main.tf b/server/controllers/events/testfixtures/test-repos/modules/staging/main.tf similarity index 100% rename from server/testfixtures/test-repos/modules/staging/main.tf rename to server/controllers/events/testfixtures/test-repos/modules/staging/main.tf diff --git a/server/testfixtures/test-repos/policy-checks-apply-reqs/atlantis.yaml b/server/controllers/events/testfixtures/test-repos/policy-checks-apply-reqs/atlantis.yaml similarity index 100% rename from server/testfixtures/test-repos/policy-checks-apply-reqs/atlantis.yaml rename to server/controllers/events/testfixtures/test-repos/policy-checks-apply-reqs/atlantis.yaml diff --git a/server/testfixtures/test-repos/policy-checks-apply-reqs/exp-output-apply-failed.txt b/server/controllers/events/testfixtures/test-repos/policy-checks-apply-reqs/exp-output-apply-failed.txt similarity index 100% rename from server/testfixtures/test-repos/policy-checks-apply-reqs/exp-output-apply-failed.txt rename to server/controllers/events/testfixtures/test-repos/policy-checks-apply-reqs/exp-output-apply-failed.txt diff --git a/server/testfixtures/test-repos/policy-checks-apply-reqs/exp-output-apply.txt b/server/controllers/events/testfixtures/test-repos/policy-checks-apply-reqs/exp-output-apply.txt similarity index 100% rename from server/testfixtures/test-repos/policy-checks-apply-reqs/exp-output-apply.txt rename to server/controllers/events/testfixtures/test-repos/policy-checks-apply-reqs/exp-output-apply.txt diff --git a/server/testfixtures/test-repos/policy-checks-apply-reqs/exp-output-approve-policies.txt b/server/controllers/events/testfixtures/test-repos/policy-checks-apply-reqs/exp-output-approve-policies.txt similarity index 100% rename from server/testfixtures/test-repos/policy-checks-apply-reqs/exp-output-approve-policies.txt rename to server/controllers/events/testfixtures/test-repos/policy-checks-apply-reqs/exp-output-approve-policies.txt diff --git a/server/testfixtures/test-repos/policy-checks-apply-reqs/exp-output-auto-policy-check.txt b/server/controllers/events/testfixtures/test-repos/policy-checks-apply-reqs/exp-output-auto-policy-check.txt similarity index 100% rename from server/testfixtures/test-repos/policy-checks-apply-reqs/exp-output-auto-policy-check.txt rename to server/controllers/events/testfixtures/test-repos/policy-checks-apply-reqs/exp-output-auto-policy-check.txt diff --git a/server/testfixtures/test-repos/policy-checks-apply-reqs/exp-output-autoplan.txt b/server/controllers/events/testfixtures/test-repos/policy-checks-apply-reqs/exp-output-autoplan.txt similarity index 100% rename from server/testfixtures/test-repos/policy-checks-apply-reqs/exp-output-autoplan.txt rename to server/controllers/events/testfixtures/test-repos/policy-checks-apply-reqs/exp-output-autoplan.txt diff --git a/server/testfixtures/test-repos/policy-checks-apply-reqs/exp-output-merge.txt b/server/controllers/events/testfixtures/test-repos/policy-checks-apply-reqs/exp-output-merge.txt similarity index 100% rename from server/testfixtures/test-repos/policy-checks-apply-reqs/exp-output-merge.txt rename to server/controllers/events/testfixtures/test-repos/policy-checks-apply-reqs/exp-output-merge.txt diff --git a/server/testfixtures/test-repos/policy-checks-apply-reqs/main.tf b/server/controllers/events/testfixtures/test-repos/policy-checks-apply-reqs/main.tf similarity index 100% rename from server/testfixtures/test-repos/policy-checks-apply-reqs/main.tf rename to server/controllers/events/testfixtures/test-repos/policy-checks-apply-reqs/main.tf diff --git a/server/testfixtures/test-repos/policy-checks-apply-reqs/policies/policy.rego b/server/controllers/events/testfixtures/test-repos/policy-checks-apply-reqs/policies/policy.rego similarity index 100% rename from server/testfixtures/test-repos/policy-checks-apply-reqs/policies/policy.rego rename to server/controllers/events/testfixtures/test-repos/policy-checks-apply-reqs/policies/policy.rego diff --git a/server/testfixtures/test-repos/policy-checks-apply-reqs/repos.yaml b/server/controllers/events/testfixtures/test-repos/policy-checks-apply-reqs/repos.yaml similarity index 100% rename from server/testfixtures/test-repos/policy-checks-apply-reqs/repos.yaml rename to server/controllers/events/testfixtures/test-repos/policy-checks-apply-reqs/repos.yaml diff --git a/server/testfixtures/test-repos/policy-checks-diff-owner/atlantis.yaml b/server/controllers/events/testfixtures/test-repos/policy-checks-diff-owner/atlantis.yaml similarity index 100% rename from server/testfixtures/test-repos/policy-checks-diff-owner/atlantis.yaml rename to server/controllers/events/testfixtures/test-repos/policy-checks-diff-owner/atlantis.yaml diff --git a/server/testfixtures/test-repos/policy-checks-diff-owner/exp-output-apply-failed.txt b/server/controllers/events/testfixtures/test-repos/policy-checks-diff-owner/exp-output-apply-failed.txt similarity index 100% rename from server/testfixtures/test-repos/policy-checks-diff-owner/exp-output-apply-failed.txt rename to server/controllers/events/testfixtures/test-repos/policy-checks-diff-owner/exp-output-apply-failed.txt diff --git a/server/testfixtures/test-repos/policy-checks-diff-owner/exp-output-approve-policies.txt b/server/controllers/events/testfixtures/test-repos/policy-checks-diff-owner/exp-output-approve-policies.txt similarity index 100% rename from server/testfixtures/test-repos/policy-checks-diff-owner/exp-output-approve-policies.txt rename to server/controllers/events/testfixtures/test-repos/policy-checks-diff-owner/exp-output-approve-policies.txt diff --git a/server/testfixtures/test-repos/policy-checks-diff-owner/exp-output-auto-policy-check.txt b/server/controllers/events/testfixtures/test-repos/policy-checks-diff-owner/exp-output-auto-policy-check.txt similarity index 100% rename from server/testfixtures/test-repos/policy-checks-diff-owner/exp-output-auto-policy-check.txt rename to server/controllers/events/testfixtures/test-repos/policy-checks-diff-owner/exp-output-auto-policy-check.txt diff --git a/server/testfixtures/test-repos/policy-checks-diff-owner/exp-output-autoplan.txt b/server/controllers/events/testfixtures/test-repos/policy-checks-diff-owner/exp-output-autoplan.txt similarity index 100% rename from server/testfixtures/test-repos/policy-checks-diff-owner/exp-output-autoplan.txt rename to server/controllers/events/testfixtures/test-repos/policy-checks-diff-owner/exp-output-autoplan.txt diff --git a/server/testfixtures/test-repos/policy-checks-diff-owner/exp-output-merge.txt b/server/controllers/events/testfixtures/test-repos/policy-checks-diff-owner/exp-output-merge.txt similarity index 100% rename from server/testfixtures/test-repos/policy-checks-diff-owner/exp-output-merge.txt rename to server/controllers/events/testfixtures/test-repos/policy-checks-diff-owner/exp-output-merge.txt diff --git a/server/testfixtures/test-repos/policy-checks-diff-owner/main.tf b/server/controllers/events/testfixtures/test-repos/policy-checks-diff-owner/main.tf similarity index 100% rename from server/testfixtures/test-repos/policy-checks-diff-owner/main.tf rename to server/controllers/events/testfixtures/test-repos/policy-checks-diff-owner/main.tf diff --git a/server/testfixtures/test-repos/policy-checks-diff-owner/policies/policy.rego b/server/controllers/events/testfixtures/test-repos/policy-checks-diff-owner/policies/policy.rego similarity index 100% rename from server/testfixtures/test-repos/policy-checks-diff-owner/policies/policy.rego rename to server/controllers/events/testfixtures/test-repos/policy-checks-diff-owner/policies/policy.rego diff --git a/server/testfixtures/test-repos/policy-checks-diff-owner/repos.yaml b/server/controllers/events/testfixtures/test-repos/policy-checks-diff-owner/repos.yaml similarity index 100% rename from server/testfixtures/test-repos/policy-checks-diff-owner/repos.yaml rename to server/controllers/events/testfixtures/test-repos/policy-checks-diff-owner/repos.yaml diff --git a/server/testfixtures/test-repos/policy-checks-extra-args/atlantis.yaml b/server/controllers/events/testfixtures/test-repos/policy-checks-extra-args/atlantis.yaml similarity index 100% rename from server/testfixtures/test-repos/policy-checks-extra-args/atlantis.yaml rename to server/controllers/events/testfixtures/test-repos/policy-checks-extra-args/atlantis.yaml diff --git a/server/testfixtures/test-repos/policy-checks-extra-args/exp-output-apply-failed.txt b/server/controllers/events/testfixtures/test-repos/policy-checks-extra-args/exp-output-apply-failed.txt similarity index 100% rename from server/testfixtures/test-repos/policy-checks-extra-args/exp-output-apply-failed.txt rename to server/controllers/events/testfixtures/test-repos/policy-checks-extra-args/exp-output-apply-failed.txt diff --git a/server/testfixtures/test-repos/policy-checks-extra-args/exp-output-apply.txt b/server/controllers/events/testfixtures/test-repos/policy-checks-extra-args/exp-output-apply.txt similarity index 100% rename from server/testfixtures/test-repos/policy-checks-extra-args/exp-output-apply.txt rename to server/controllers/events/testfixtures/test-repos/policy-checks-extra-args/exp-output-apply.txt diff --git a/server/testfixtures/test-repos/policy-checks-extra-args/exp-output-approve-policies.txt b/server/controllers/events/testfixtures/test-repos/policy-checks-extra-args/exp-output-approve-policies.txt similarity index 100% rename from server/testfixtures/test-repos/policy-checks-extra-args/exp-output-approve-policies.txt rename to server/controllers/events/testfixtures/test-repos/policy-checks-extra-args/exp-output-approve-policies.txt diff --git a/server/testfixtures/test-repos/policy-checks-extra-args/exp-output-auto-policy-check.txt b/server/controllers/events/testfixtures/test-repos/policy-checks-extra-args/exp-output-auto-policy-check.txt similarity index 100% rename from server/testfixtures/test-repos/policy-checks-extra-args/exp-output-auto-policy-check.txt rename to server/controllers/events/testfixtures/test-repos/policy-checks-extra-args/exp-output-auto-policy-check.txt diff --git a/server/testfixtures/test-repos/policy-checks-extra-args/exp-output-autoplan.txt b/server/controllers/events/testfixtures/test-repos/policy-checks-extra-args/exp-output-autoplan.txt similarity index 100% rename from server/testfixtures/test-repos/policy-checks-extra-args/exp-output-autoplan.txt rename to server/controllers/events/testfixtures/test-repos/policy-checks-extra-args/exp-output-autoplan.txt diff --git a/server/testfixtures/test-repos/policy-checks-extra-args/exp-output-merge.txt b/server/controllers/events/testfixtures/test-repos/policy-checks-extra-args/exp-output-merge.txt similarity index 100% rename from server/testfixtures/test-repos/policy-checks-extra-args/exp-output-merge.txt rename to server/controllers/events/testfixtures/test-repos/policy-checks-extra-args/exp-output-merge.txt diff --git a/server/testfixtures/test-repos/policy-checks-extra-args/main.tf b/server/controllers/events/testfixtures/test-repos/policy-checks-extra-args/main.tf similarity index 100% rename from server/testfixtures/test-repos/policy-checks-extra-args/main.tf rename to server/controllers/events/testfixtures/test-repos/policy-checks-extra-args/main.tf diff --git a/server/testfixtures/test-repos/policy-checks-extra-args/policies/policy.rego b/server/controllers/events/testfixtures/test-repos/policy-checks-extra-args/policies/policy.rego similarity index 100% rename from server/testfixtures/test-repos/policy-checks-extra-args/policies/policy.rego rename to server/controllers/events/testfixtures/test-repos/policy-checks-extra-args/policies/policy.rego diff --git a/server/testfixtures/test-repos/policy-checks-extra-args/repos.yaml b/server/controllers/events/testfixtures/test-repos/policy-checks-extra-args/repos.yaml similarity index 100% rename from server/testfixtures/test-repos/policy-checks-extra-args/repos.yaml rename to server/controllers/events/testfixtures/test-repos/policy-checks-extra-args/repos.yaml diff --git a/server/testfixtures/test-repos/policy-checks-multi-projects/atlantis.yaml b/server/controllers/events/testfixtures/test-repos/policy-checks-multi-projects/atlantis.yaml similarity index 100% rename from server/testfixtures/test-repos/policy-checks-multi-projects/atlantis.yaml rename to server/controllers/events/testfixtures/test-repos/policy-checks-multi-projects/atlantis.yaml diff --git a/server/testfixtures/test-repos/policy-checks-multi-projects/dir1/main.tf b/server/controllers/events/testfixtures/test-repos/policy-checks-multi-projects/dir1/main.tf similarity index 100% rename from server/testfixtures/test-repos/policy-checks-multi-projects/dir1/main.tf rename to server/controllers/events/testfixtures/test-repos/policy-checks-multi-projects/dir1/main.tf diff --git a/server/testfixtures/test-repos/policy-checks-multi-projects/dir2/main.tf b/server/controllers/events/testfixtures/test-repos/policy-checks-multi-projects/dir2/main.tf similarity index 100% rename from server/testfixtures/test-repos/policy-checks-multi-projects/dir2/main.tf rename to server/controllers/events/testfixtures/test-repos/policy-checks-multi-projects/dir2/main.tf diff --git a/server/testfixtures/test-repos/policy-checks-multi-projects/exp-output-apply.txt b/server/controllers/events/testfixtures/test-repos/policy-checks-multi-projects/exp-output-apply.txt similarity index 100% rename from server/testfixtures/test-repos/policy-checks-multi-projects/exp-output-apply.txt rename to server/controllers/events/testfixtures/test-repos/policy-checks-multi-projects/exp-output-apply.txt diff --git a/server/testfixtures/test-repos/policy-checks-multi-projects/exp-output-approve-policies.txt b/server/controllers/events/testfixtures/test-repos/policy-checks-multi-projects/exp-output-approve-policies.txt similarity index 100% rename from server/testfixtures/test-repos/policy-checks-multi-projects/exp-output-approve-policies.txt rename to server/controllers/events/testfixtures/test-repos/policy-checks-multi-projects/exp-output-approve-policies.txt diff --git a/server/testfixtures/test-repos/policy-checks-multi-projects/exp-output-auto-policy-check.txt b/server/controllers/events/testfixtures/test-repos/policy-checks-multi-projects/exp-output-auto-policy-check.txt similarity index 100% rename from server/testfixtures/test-repos/policy-checks-multi-projects/exp-output-auto-policy-check.txt rename to server/controllers/events/testfixtures/test-repos/policy-checks-multi-projects/exp-output-auto-policy-check.txt diff --git a/server/testfixtures/test-repos/policy-checks-multi-projects/exp-output-autoplan.txt b/server/controllers/events/testfixtures/test-repos/policy-checks-multi-projects/exp-output-autoplan.txt similarity index 100% rename from server/testfixtures/test-repos/policy-checks-multi-projects/exp-output-autoplan.txt rename to server/controllers/events/testfixtures/test-repos/policy-checks-multi-projects/exp-output-autoplan.txt diff --git a/server/testfixtures/test-repos/policy-checks-multi-projects/exp-output-merge.txt b/server/controllers/events/testfixtures/test-repos/policy-checks-multi-projects/exp-output-merge.txt similarity index 100% rename from server/testfixtures/test-repos/policy-checks-multi-projects/exp-output-merge.txt rename to server/controllers/events/testfixtures/test-repos/policy-checks-multi-projects/exp-output-merge.txt diff --git a/server/testfixtures/test-repos/policy-checks-multi-projects/policies/policy.rego b/server/controllers/events/testfixtures/test-repos/policy-checks-multi-projects/policies/policy.rego similarity index 100% rename from server/testfixtures/test-repos/policy-checks-multi-projects/policies/policy.rego rename to server/controllers/events/testfixtures/test-repos/policy-checks-multi-projects/policies/policy.rego diff --git a/server/testfixtures/test-repos/policy-checks-multi-projects/repos.yaml b/server/controllers/events/testfixtures/test-repos/policy-checks-multi-projects/repos.yaml similarity index 100% rename from server/testfixtures/test-repos/policy-checks-multi-projects/repos.yaml rename to server/controllers/events/testfixtures/test-repos/policy-checks-multi-projects/repos.yaml diff --git a/server/testfixtures/test-repos/policy-checks/atlantis.yaml b/server/controllers/events/testfixtures/test-repos/policy-checks/atlantis.yaml similarity index 100% rename from server/testfixtures/test-repos/policy-checks/atlantis.yaml rename to server/controllers/events/testfixtures/test-repos/policy-checks/atlantis.yaml diff --git a/server/testfixtures/test-repos/policy-checks/exp-output-apply-failed.txt b/server/controllers/events/testfixtures/test-repos/policy-checks/exp-output-apply-failed.txt similarity index 100% rename from server/testfixtures/test-repos/policy-checks/exp-output-apply-failed.txt rename to server/controllers/events/testfixtures/test-repos/policy-checks/exp-output-apply-failed.txt diff --git a/server/testfixtures/test-repos/policy-checks/exp-output-apply.txt b/server/controllers/events/testfixtures/test-repos/policy-checks/exp-output-apply.txt similarity index 100% rename from server/testfixtures/test-repos/policy-checks/exp-output-apply.txt rename to server/controllers/events/testfixtures/test-repos/policy-checks/exp-output-apply.txt diff --git a/server/testfixtures/test-repos/policy-checks/exp-output-approve-policies.txt b/server/controllers/events/testfixtures/test-repos/policy-checks/exp-output-approve-policies.txt similarity index 100% rename from server/testfixtures/test-repos/policy-checks/exp-output-approve-policies.txt rename to server/controllers/events/testfixtures/test-repos/policy-checks/exp-output-approve-policies.txt diff --git a/server/testfixtures/test-repos/policy-checks/exp-output-auto-policy-check.txt b/server/controllers/events/testfixtures/test-repos/policy-checks/exp-output-auto-policy-check.txt similarity index 100% rename from server/testfixtures/test-repos/policy-checks/exp-output-auto-policy-check.txt rename to server/controllers/events/testfixtures/test-repos/policy-checks/exp-output-auto-policy-check.txt diff --git a/server/testfixtures/test-repos/policy-checks/exp-output-autoplan.txt b/server/controllers/events/testfixtures/test-repos/policy-checks/exp-output-autoplan.txt similarity index 100% rename from server/testfixtures/test-repos/policy-checks/exp-output-autoplan.txt rename to server/controllers/events/testfixtures/test-repos/policy-checks/exp-output-autoplan.txt diff --git a/server/testfixtures/test-repos/policy-checks/exp-output-merge.txt b/server/controllers/events/testfixtures/test-repos/policy-checks/exp-output-merge.txt similarity index 100% rename from server/testfixtures/test-repos/policy-checks/exp-output-merge.txt rename to server/controllers/events/testfixtures/test-repos/policy-checks/exp-output-merge.txt diff --git a/server/testfixtures/test-repos/policy-checks/main.tf b/server/controllers/events/testfixtures/test-repos/policy-checks/main.tf similarity index 100% rename from server/testfixtures/test-repos/policy-checks/main.tf rename to server/controllers/events/testfixtures/test-repos/policy-checks/main.tf diff --git a/server/testfixtures/test-repos/policy-checks/policies/policy.rego b/server/controllers/events/testfixtures/test-repos/policy-checks/policies/policy.rego similarity index 100% rename from server/testfixtures/test-repos/policy-checks/policies/policy.rego rename to server/controllers/events/testfixtures/test-repos/policy-checks/policies/policy.rego diff --git a/server/testfixtures/test-repos/policy-checks/repos.yaml b/server/controllers/events/testfixtures/test-repos/policy-checks/repos.yaml similarity index 100% rename from server/testfixtures/test-repos/policy-checks/repos.yaml rename to server/controllers/events/testfixtures/test-repos/policy-checks/repos.yaml diff --git a/server/testfixtures/test-repos/server-side-cfg/atlantis.yaml b/server/controllers/events/testfixtures/test-repos/server-side-cfg/atlantis.yaml similarity index 100% rename from server/testfixtures/test-repos/server-side-cfg/atlantis.yaml rename to server/controllers/events/testfixtures/test-repos/server-side-cfg/atlantis.yaml diff --git a/server/testfixtures/test-repos/server-side-cfg/exp-output-apply-default-workspace.txt b/server/controllers/events/testfixtures/test-repos/server-side-cfg/exp-output-apply-default-workspace.txt similarity index 100% rename from server/testfixtures/test-repos/server-side-cfg/exp-output-apply-default-workspace.txt rename to server/controllers/events/testfixtures/test-repos/server-side-cfg/exp-output-apply-default-workspace.txt diff --git a/server/controllers/events/testfixtures/test-repos/server-side-cfg/exp-output-apply-default-workspace.txt.act b/server/controllers/events/testfixtures/test-repos/server-side-cfg/exp-output-apply-default-workspace.txt.act new file mode 100644 index 000000000..336a84955 --- /dev/null +++ b/server/controllers/events/testfixtures/test-repos/server-side-cfg/exp-output-apply-default-workspace.txt.act @@ -0,0 +1,14 @@ +Ran Apply for dir: `.` workspace: `default` + +```diff +null_resource.simple: +null_resource.simple: + +Apply complete! Resources: 1 added, 0 changed, 0 destroyed. + +Outputs: + +workspace = "default" + +``` + diff --git a/server/testfixtures/test-repos/server-side-cfg/exp-output-apply-staging-workspace.txt b/server/controllers/events/testfixtures/test-repos/server-side-cfg/exp-output-apply-staging-workspace.txt similarity index 100% rename from server/testfixtures/test-repos/server-side-cfg/exp-output-apply-staging-workspace.txt rename to server/controllers/events/testfixtures/test-repos/server-side-cfg/exp-output-apply-staging-workspace.txt diff --git a/server/controllers/events/testfixtures/test-repos/server-side-cfg/exp-output-apply-staging-workspace.txt.act b/server/controllers/events/testfixtures/test-repos/server-side-cfg/exp-output-apply-staging-workspace.txt.act new file mode 100644 index 000000000..b36f8209c --- /dev/null +++ b/server/controllers/events/testfixtures/test-repos/server-side-cfg/exp-output-apply-staging-workspace.txt.act @@ -0,0 +1,14 @@ +Ran Apply for dir: `.` workspace: `staging` + +```diff +null_resource.simple: +null_resource.simple: + +Apply complete! Resources: 1 added, 0 changed, 0 destroyed. + +Outputs: + +workspace = "staging" + +``` + diff --git a/server/testfixtures/test-repos/server-side-cfg/exp-output-autoplan.txt b/server/controllers/events/testfixtures/test-repos/server-side-cfg/exp-output-autoplan.txt similarity index 100% rename from server/testfixtures/test-repos/server-side-cfg/exp-output-autoplan.txt rename to server/controllers/events/testfixtures/test-repos/server-side-cfg/exp-output-autoplan.txt diff --git a/server/controllers/events/testfixtures/test-repos/server-side-cfg/exp-output-autoplan.txt.act b/server/controllers/events/testfixtures/test-repos/server-side-cfg/exp-output-autoplan.txt.act new file mode 100644 index 000000000..25eddec36 --- /dev/null +++ b/server/controllers/events/testfixtures/test-repos/server-side-cfg/exp-output-autoplan.txt.act @@ -0,0 +1,79 @@ +Ran Plan for 2 projects: + +1. dir: `.` workspace: `default` +1. dir: `.` workspace: `staging` + +### 1. dir: `.` workspace: `default` +
Show Output + +```diff +preinit custom + + +Terraform used the selected providers to generate the following execution +plan. Resource actions are indicated with the following symbols: ++ create + +Terraform will perform the following actions: + + # null_resource.simple[0] will be created ++ resource "null_resource" "simple" { + + id = (known after apply) + } + +Plan: 1 to add, 0 to change, 0 to destroy. + +Changes to Outputs: ++ workspace = "default" + +postplan custom + +``` + +* :arrow_forward: To **apply** this plan, comment: + * `atlantis apply -d .` +* :put_litter_in_its_place: To **delete** this plan click [here](lock-url) +* :repeat: To **plan** this project again, comment: + * `atlantis plan -d .` +
+Plan: 1 to add, 0 to change, 0 to destroy. + +--- +### 2. dir: `.` workspace: `staging` +
Show Output + +```diff +preinit staging + + +Terraform used the selected providers to generate the following execution +plan. Resource actions are indicated with the following symbols: ++ create + +Terraform will perform the following actions: + + # null_resource.simple[0] will be created ++ resource "null_resource" "simple" { + + id = (known after apply) + } + +Plan: 1 to add, 0 to change, 0 to destroy. + +Changes to Outputs: ++ workspace = "staging" + +``` + +* :arrow_forward: To **apply** this plan, comment: + * `atlantis apply -w staging` +* :put_litter_in_its_place: To **delete** this plan click [here](lock-url) +* :repeat: To **plan** this project again, comment: + * `atlantis plan -w staging` +
+Plan: 1 to add, 0 to change, 0 to destroy. + +--- +* :fast_forward: To **apply** all unapplied plans from this pull request, comment: + * `atlantis apply` +* :put_litter_in_its_place: To delete all plans and locks for the PR, comment: + * `atlantis unlock` diff --git a/server/testfixtures/test-repos/server-side-cfg/exp-output-merge.txt b/server/controllers/events/testfixtures/test-repos/server-side-cfg/exp-output-merge.txt similarity index 100% rename from server/testfixtures/test-repos/server-side-cfg/exp-output-merge.txt rename to server/controllers/events/testfixtures/test-repos/server-side-cfg/exp-output-merge.txt diff --git a/server/testfixtures/test-repos/server-side-cfg/main.tf b/server/controllers/events/testfixtures/test-repos/server-side-cfg/main.tf similarity index 100% rename from server/testfixtures/test-repos/server-side-cfg/main.tf rename to server/controllers/events/testfixtures/test-repos/server-side-cfg/main.tf diff --git a/server/testfixtures/test-repos/server-side-cfg/repos.yaml b/server/controllers/events/testfixtures/test-repos/server-side-cfg/repos.yaml similarity index 100% rename from server/testfixtures/test-repos/server-side-cfg/repos.yaml rename to server/controllers/events/testfixtures/test-repos/server-side-cfg/repos.yaml diff --git a/server/testfixtures/test-repos/simple-yaml/atlantis.yaml b/server/controllers/events/testfixtures/test-repos/simple-yaml/atlantis.yaml similarity index 100% rename from server/testfixtures/test-repos/simple-yaml/atlantis.yaml rename to server/controllers/events/testfixtures/test-repos/simple-yaml/atlantis.yaml diff --git a/server/testfixtures/test-repos/simple-yaml/exp-output-apply-all.txt b/server/controllers/events/testfixtures/test-repos/simple-yaml/exp-output-apply-all.txt similarity index 100% rename from server/testfixtures/test-repos/simple-yaml/exp-output-apply-all.txt rename to server/controllers/events/testfixtures/test-repos/simple-yaml/exp-output-apply-all.txt diff --git a/server/controllers/events/testfixtures/test-repos/simple-yaml/exp-output-apply-all.txt.act b/server/controllers/events/testfixtures/test-repos/simple-yaml/exp-output-apply-all.txt.act new file mode 100644 index 000000000..04b926ff5 --- /dev/null +++ b/server/controllers/events/testfixtures/test-repos/simple-yaml/exp-output-apply-all.txt.act @@ -0,0 +1,43 @@ +Ran Apply for 2 projects: + +1. dir: `.` workspace: `default` +1. dir: `.` workspace: `staging` + +### 1. dir: `.` workspace: `default` +```diff +null_resource.simple: +null_resource.simple: + +Apply complete! Resources: 1 added, 0 changed, 0 destroyed. + +Outputs: + +var = "fromconfig" +workspace = "default" + +``` + +--- +### 2. dir: `.` workspace: `staging` +
Show Output + +```diff +preapply + +null_resource.simple: +null_resource.simple: + +Apply complete! Resources: 1 added, 0 changed, 0 destroyed. + +Outputs: + +var = "fromfile" +workspace = "staging" + +postapply + +``` +
+ +--- + diff --git a/server/testfixtures/test-repos/simple-yaml/exp-output-apply-default.txt b/server/controllers/events/testfixtures/test-repos/simple-yaml/exp-output-apply-default.txt similarity index 100% rename from server/testfixtures/test-repos/simple-yaml/exp-output-apply-default.txt rename to server/controllers/events/testfixtures/test-repos/simple-yaml/exp-output-apply-default.txt diff --git a/server/controllers/events/testfixtures/test-repos/simple-yaml/exp-output-apply-default.txt.act b/server/controllers/events/testfixtures/test-repos/simple-yaml/exp-output-apply-default.txt.act new file mode 100644 index 000000000..5e3d22778 --- /dev/null +++ b/server/controllers/events/testfixtures/test-repos/simple-yaml/exp-output-apply-default.txt.act @@ -0,0 +1,15 @@ +Ran Apply for dir: `.` workspace: `default` + +```diff +null_resource.simple: +null_resource.simple: + +Apply complete! Resources: 1 added, 0 changed, 0 destroyed. + +Outputs: + +var = "fromconfig" +workspace = "default" + +``` + diff --git a/server/testfixtures/test-repos/simple-yaml/exp-output-apply-locked.txt b/server/controllers/events/testfixtures/test-repos/simple-yaml/exp-output-apply-locked.txt similarity index 100% rename from server/testfixtures/test-repos/simple-yaml/exp-output-apply-locked.txt rename to server/controllers/events/testfixtures/test-repos/simple-yaml/exp-output-apply-locked.txt diff --git a/server/testfixtures/test-repos/simple-yaml/exp-output-apply-staging.txt b/server/controllers/events/testfixtures/test-repos/simple-yaml/exp-output-apply-staging.txt similarity index 100% rename from server/testfixtures/test-repos/simple-yaml/exp-output-apply-staging.txt rename to server/controllers/events/testfixtures/test-repos/simple-yaml/exp-output-apply-staging.txt diff --git a/server/controllers/events/testfixtures/test-repos/simple-yaml/exp-output-apply-staging.txt.act b/server/controllers/events/testfixtures/test-repos/simple-yaml/exp-output-apply-staging.txt.act new file mode 100644 index 000000000..88f2698f0 --- /dev/null +++ b/server/controllers/events/testfixtures/test-repos/simple-yaml/exp-output-apply-staging.txt.act @@ -0,0 +1,22 @@ +Ran Apply for dir: `.` workspace: `staging` + +
Show Output + +```diff +preapply + +null_resource.simple: +null_resource.simple: + +Apply complete! Resources: 1 added, 0 changed, 0 destroyed. + +Outputs: + +var = "fromfile" +workspace = "staging" + +postapply + +``` +
+ diff --git a/server/testfixtures/test-repos/simple-yaml/exp-output-autoplan.txt b/server/controllers/events/testfixtures/test-repos/simple-yaml/exp-output-autoplan.txt similarity index 100% rename from server/testfixtures/test-repos/simple-yaml/exp-output-autoplan.txt rename to server/controllers/events/testfixtures/test-repos/simple-yaml/exp-output-autoplan.txt diff --git a/server/controllers/events/testfixtures/test-repos/simple-yaml/exp-output-autoplan.txt.act b/server/controllers/events/testfixtures/test-repos/simple-yaml/exp-output-autoplan.txt.act new file mode 100644 index 000000000..5145516ef --- /dev/null +++ b/server/controllers/events/testfixtures/test-repos/simple-yaml/exp-output-autoplan.txt.act @@ -0,0 +1,79 @@ +Ran Plan for 2 projects: + +1. dir: `.` workspace: `default` +1. dir: `.` workspace: `staging` + +### 1. dir: `.` workspace: `default` +
Show Output + +```diff +preinit + + +Terraform used the selected providers to generate the following execution +plan. Resource actions are indicated with the following symbols: ++ create + +Terraform will perform the following actions: + + # null_resource.simple[0] will be created ++ resource "null_resource" "simple" { + + id = (known after apply) + } + +Plan: 1 to add, 0 to change, 0 to destroy. + +Changes to Outputs: ++ var = "fromconfig" ++ workspace = "default" + +postplan + +``` + +* :arrow_forward: To **apply** this plan, comment: + * `atlantis apply -d .` +* :put_litter_in_its_place: To **delete** this plan click [here](lock-url) +* :repeat: To **plan** this project again, comment: + * `atlantis plan -d .` +
+Plan: 1 to add, 0 to change, 0 to destroy. + +--- +### 2. dir: `.` workspace: `staging` +
Show Output + +```diff + +Terraform used the selected providers to generate the following execution +plan. Resource actions are indicated with the following symbols: ++ create + +Terraform will perform the following actions: + + # null_resource.simple[0] will be created ++ resource "null_resource" "simple" { + + id = (known after apply) + } + +Plan: 1 to add, 0 to change, 0 to destroy. + +Changes to Outputs: ++ var = "fromfile" ++ workspace = "staging" + +``` + +* :arrow_forward: To **apply** this plan, comment: + * `atlantis apply -w staging` +* :put_litter_in_its_place: To **delete** this plan click [here](lock-url) +* :repeat: To **plan** this project again, comment: + * `atlantis plan -w staging` +
+Plan: 1 to add, 0 to change, 0 to destroy. + +--- +* :fast_forward: To **apply** all unapplied plans from this pull request, comment: + * `atlantis apply` +* :put_litter_in_its_place: To delete all plans and locks for the PR, comment: + * `atlantis unlock` diff --git a/server/testfixtures/test-repos/simple-yaml/exp-output-merge.txt b/server/controllers/events/testfixtures/test-repos/simple-yaml/exp-output-merge.txt similarity index 100% rename from server/testfixtures/test-repos/simple-yaml/exp-output-merge.txt rename to server/controllers/events/testfixtures/test-repos/simple-yaml/exp-output-merge.txt diff --git a/server/testfixtures/test-repos/simple-yaml/main.tf b/server/controllers/events/testfixtures/test-repos/simple-yaml/main.tf similarity index 100% rename from server/testfixtures/test-repos/simple-yaml/main.tf rename to server/controllers/events/testfixtures/test-repos/simple-yaml/main.tf diff --git a/server/testfixtures/test-repos/simple-yaml/staging.tfvars b/server/controllers/events/testfixtures/test-repos/simple-yaml/staging.tfvars similarity index 100% rename from server/testfixtures/test-repos/simple-yaml/staging.tfvars rename to server/controllers/events/testfixtures/test-repos/simple-yaml/staging.tfvars diff --git a/server/testfixtures/test-repos/simple/exp-output-apply-var-all.txt b/server/controllers/events/testfixtures/test-repos/simple/exp-output-apply-var-all.txt similarity index 100% rename from server/testfixtures/test-repos/simple/exp-output-apply-var-all.txt rename to server/controllers/events/testfixtures/test-repos/simple/exp-output-apply-var-all.txt diff --git a/server/controllers/events/testfixtures/test-repos/simple/exp-output-apply-var-all.txt.act b/server/controllers/events/testfixtures/test-repos/simple/exp-output-apply-var-all.txt.act new file mode 100644 index 000000000..11f65032d --- /dev/null +++ b/server/controllers/events/testfixtures/test-repos/simple/exp-output-apply-var-all.txt.act @@ -0,0 +1,50 @@ +Ran Apply for 2 projects: + +1. dir: `.` workspace: `default` +1. dir: `.` workspace: `new_workspace` + +### 1. dir: `.` workspace: `default` +
Show Output + +```diff +null_resource.simple: +null_resource.simple: +null_resource.simple: +null_resource.simple: +null_resource.simple: +null_resource.simple: + +Apply complete! Resources: 3 added, 0 changed, 0 destroyed. + +Outputs: + +var = "default_workspace" +workspace = "default" + +``` +
+ +--- +### 2. dir: `.` workspace: `new_workspace` +
Show Output + +```diff +null_resource.simple: +null_resource.simple: +null_resource.simple: +null_resource.simple: +null_resource.simple: +null_resource.simple: + +Apply complete! Resources: 3 added, 0 changed, 0 destroyed. + +Outputs: + +var = "new_workspace" +workspace = "new_workspace" + +``` +
+ +--- + diff --git a/server/testfixtures/test-repos/simple/exp-output-apply-var-default-workspace.txt b/server/controllers/events/testfixtures/test-repos/simple/exp-output-apply-var-default-workspace.txt similarity index 100% rename from server/testfixtures/test-repos/simple/exp-output-apply-var-default-workspace.txt rename to server/controllers/events/testfixtures/test-repos/simple/exp-output-apply-var-default-workspace.txt diff --git a/server/controllers/events/testfixtures/test-repos/simple/exp-output-apply-var-default-workspace.txt.act b/server/controllers/events/testfixtures/test-repos/simple/exp-output-apply-var-default-workspace.txt.act new file mode 100644 index 000000000..cfa21dde3 --- /dev/null +++ b/server/controllers/events/testfixtures/test-repos/simple/exp-output-apply-var-default-workspace.txt.act @@ -0,0 +1,22 @@ +Ran Apply for dir: `.` workspace: `default` + +
Show Output + +```diff +null_resource.simple: +null_resource.simple: +null_resource.simple: +null_resource.simple: +null_resource.simple: +null_resource.simple: + +Apply complete! Resources: 3 added, 0 changed, 0 destroyed. + +Outputs: + +var = "default_workspace" +workspace = "default" + +``` +
+ diff --git a/server/testfixtures/test-repos/simple/exp-output-apply-var-new-workspace.txt b/server/controllers/events/testfixtures/test-repos/simple/exp-output-apply-var-new-workspace.txt similarity index 100% rename from server/testfixtures/test-repos/simple/exp-output-apply-var-new-workspace.txt rename to server/controllers/events/testfixtures/test-repos/simple/exp-output-apply-var-new-workspace.txt diff --git a/server/controllers/events/testfixtures/test-repos/simple/exp-output-apply-var-new-workspace.txt.act b/server/controllers/events/testfixtures/test-repos/simple/exp-output-apply-var-new-workspace.txt.act new file mode 100644 index 000000000..8c1a0bac5 --- /dev/null +++ b/server/controllers/events/testfixtures/test-repos/simple/exp-output-apply-var-new-workspace.txt.act @@ -0,0 +1,22 @@ +Ran Apply for dir: `.` workspace: `new_workspace` + +
Show Output + +```diff +null_resource.simple: +null_resource.simple: +null_resource.simple: +null_resource.simple: +null_resource.simple: +null_resource.simple: + +Apply complete! Resources: 3 added, 0 changed, 0 destroyed. + +Outputs: + +var = "new_workspace" +workspace = "new_workspace" + +``` +
+ diff --git a/server/testfixtures/test-repos/simple/exp-output-apply-var.txt b/server/controllers/events/testfixtures/test-repos/simple/exp-output-apply-var.txt similarity index 100% rename from server/testfixtures/test-repos/simple/exp-output-apply-var.txt rename to server/controllers/events/testfixtures/test-repos/simple/exp-output-apply-var.txt diff --git a/server/controllers/events/testfixtures/test-repos/simple/exp-output-apply-var.txt.act b/server/controllers/events/testfixtures/test-repos/simple/exp-output-apply-var.txt.act new file mode 100644 index 000000000..59aff5f18 --- /dev/null +++ b/server/controllers/events/testfixtures/test-repos/simple/exp-output-apply-var.txt.act @@ -0,0 +1,22 @@ +Ran Apply for dir: `.` workspace: `default` + +
Show Output + +```diff +null_resource.simple: +null_resource.simple: +null_resource.simple: +null_resource.simple: +null_resource.simple: +null_resource.simple: + +Apply complete! Resources: 3 added, 0 changed, 0 destroyed. + +Outputs: + +var = "overridden" +workspace = "default" + +``` +
+ diff --git a/server/testfixtures/test-repos/simple/exp-output-apply.txt b/server/controllers/events/testfixtures/test-repos/simple/exp-output-apply.txt similarity index 100% rename from server/testfixtures/test-repos/simple/exp-output-apply.txt rename to server/controllers/events/testfixtures/test-repos/simple/exp-output-apply.txt diff --git a/server/controllers/events/testfixtures/test-repos/simple/exp-output-apply.txt.act b/server/controllers/events/testfixtures/test-repos/simple/exp-output-apply.txt.act new file mode 100644 index 000000000..98ffd366e --- /dev/null +++ b/server/controllers/events/testfixtures/test-repos/simple/exp-output-apply.txt.act @@ -0,0 +1,22 @@ +Ran Apply for dir: `.` workspace: `default` + +
Show Output + +```diff +null_resource.simple: +null_resource.simple: +null_resource.simple: +null_resource.simple: +null_resource.simple: +null_resource.simple: + +Apply complete! Resources: 3 added, 0 changed, 0 destroyed. + +Outputs: + +var = "default" +workspace = "default" + +``` +
+ diff --git a/server/testfixtures/test-repos/simple/exp-output-atlantis-plan-new-workspace.txt b/server/controllers/events/testfixtures/test-repos/simple/exp-output-atlantis-plan-new-workspace.txt similarity index 100% rename from server/testfixtures/test-repos/simple/exp-output-atlantis-plan-new-workspace.txt rename to server/controllers/events/testfixtures/test-repos/simple/exp-output-atlantis-plan-new-workspace.txt diff --git a/server/controllers/events/testfixtures/test-repos/simple/exp-output-atlantis-plan-new-workspace.txt.act b/server/controllers/events/testfixtures/test-repos/simple/exp-output-atlantis-plan-new-workspace.txt.act new file mode 100644 index 000000000..b725eb1bf --- /dev/null +++ b/server/controllers/events/testfixtures/test-repos/simple/exp-output-atlantis-plan-new-workspace.txt.act @@ -0,0 +1,48 @@ +Ran Plan for dir: `.` workspace: `new_workspace` + +
Show Output + +```diff + +Terraform used the selected providers to generate the following execution +plan. Resource actions are indicated with the following symbols: ++ create + +Terraform will perform the following actions: + + # null_resource.simple[0] will be created ++ resource "null_resource" "simple" { + + id = (known after apply) + } + + # null_resource.simple2 will be created ++ resource "null_resource" "simple2" { + + id = (known after apply) + } + + # null_resource.simple3 will be created ++ resource "null_resource" "simple3" { + + id = (known after apply) + } + +Plan: 3 to add, 0 to change, 0 to destroy. + +Changes to Outputs: ++ var = "new_workspace" ++ workspace = "new_workspace" + +``` + +* :arrow_forward: To **apply** this plan, comment: + * `atlantis apply -w new_workspace` +* :put_litter_in_its_place: To **delete** this plan click [here](lock-url) +* :repeat: To **plan** this project again, comment: + * `atlantis plan -w new_workspace -- -var var=new_workspace` +
+Plan: 3 to add, 0 to change, 0 to destroy. + +--- +* :fast_forward: To **apply** all unapplied plans from this pull request, comment: + * `atlantis apply` +* :put_litter_in_its_place: To delete all plans and locks for the PR, comment: + * `atlantis unlock` diff --git a/server/testfixtures/test-repos/simple/exp-output-atlantis-plan-var-overridden.txt b/server/controllers/events/testfixtures/test-repos/simple/exp-output-atlantis-plan-var-overridden.txt similarity index 100% rename from server/testfixtures/test-repos/simple/exp-output-atlantis-plan-var-overridden.txt rename to server/controllers/events/testfixtures/test-repos/simple/exp-output-atlantis-plan-var-overridden.txt diff --git a/server/controllers/events/testfixtures/test-repos/simple/exp-output-atlantis-plan-var-overridden.txt.act b/server/controllers/events/testfixtures/test-repos/simple/exp-output-atlantis-plan-var-overridden.txt.act new file mode 100644 index 000000000..bc608ceb1 --- /dev/null +++ b/server/controllers/events/testfixtures/test-repos/simple/exp-output-atlantis-plan-var-overridden.txt.act @@ -0,0 +1,48 @@ +Ran Plan for dir: `.` workspace: `default` + +
Show Output + +```diff + +Terraform used the selected providers to generate the following execution +plan. Resource actions are indicated with the following symbols: ++ create + +Terraform will perform the following actions: + + # null_resource.simple[0] will be created ++ resource "null_resource" "simple" { + + id = (known after apply) + } + + # null_resource.simple2 will be created ++ resource "null_resource" "simple2" { + + id = (known after apply) + } + + # null_resource.simple3 will be created ++ resource "null_resource" "simple3" { + + id = (known after apply) + } + +Plan: 3 to add, 0 to change, 0 to destroy. + +Changes to Outputs: ++ var = "overridden" ++ workspace = "default" + +``` + +* :arrow_forward: To **apply** this plan, comment: + * `atlantis apply -d .` +* :put_litter_in_its_place: To **delete** this plan click [here](lock-url) +* :repeat: To **plan** this project again, comment: + * `atlantis plan -d . -- -var var=overridden` +
+Plan: 3 to add, 0 to change, 0 to destroy. + +--- +* :fast_forward: To **apply** all unapplied plans from this pull request, comment: + * `atlantis apply` +* :put_litter_in_its_place: To delete all plans and locks for the PR, comment: + * `atlantis unlock` diff --git a/server/testfixtures/test-repos/simple/exp-output-atlantis-plan.txt b/server/controllers/events/testfixtures/test-repos/simple/exp-output-atlantis-plan.txt similarity index 100% rename from server/testfixtures/test-repos/simple/exp-output-atlantis-plan.txt rename to server/controllers/events/testfixtures/test-repos/simple/exp-output-atlantis-plan.txt diff --git a/server/controllers/events/testfixtures/test-repos/simple/exp-output-atlantis-plan.txt.act b/server/controllers/events/testfixtures/test-repos/simple/exp-output-atlantis-plan.txt.act new file mode 100644 index 000000000..c56cd47e1 --- /dev/null +++ b/server/controllers/events/testfixtures/test-repos/simple/exp-output-atlantis-plan.txt.act @@ -0,0 +1,48 @@ +Ran Plan for dir: `.` workspace: `default` + +
Show Output + +```diff + +Terraform used the selected providers to generate the following execution +plan. Resource actions are indicated with the following symbols: ++ create + +Terraform will perform the following actions: + + # null_resource.simple[0] will be created ++ resource "null_resource" "simple" { + + id = (known after apply) + } + + # null_resource.simple2 will be created ++ resource "null_resource" "simple2" { + + id = (known after apply) + } + + # null_resource.simple3 will be created ++ resource "null_resource" "simple3" { + + id = (known after apply) + } + +Plan: 3 to add, 0 to change, 0 to destroy. + +Changes to Outputs: ++ var = "default_workspace" ++ workspace = "default" + +``` + +* :arrow_forward: To **apply** this plan, comment: + * `atlantis apply -d .` +* :put_litter_in_its_place: To **delete** this plan click [here](lock-url) +* :repeat: To **plan** this project again, comment: + * `atlantis plan -d . -- -var var=default_workspace` +
+Plan: 3 to add, 0 to change, 0 to destroy. + +--- +* :fast_forward: To **apply** all unapplied plans from this pull request, comment: + * `atlantis apply` +* :put_litter_in_its_place: To delete all plans and locks for the PR, comment: + * `atlantis unlock` diff --git a/server/testfixtures/test-repos/simple/exp-output-auto-policy-check.txt b/server/controllers/events/testfixtures/test-repos/simple/exp-output-auto-policy-check.txt similarity index 100% rename from server/testfixtures/test-repos/simple/exp-output-auto-policy-check.txt rename to server/controllers/events/testfixtures/test-repos/simple/exp-output-auto-policy-check.txt diff --git a/server/testfixtures/test-repos/simple/exp-output-autoplan.txt b/server/controllers/events/testfixtures/test-repos/simple/exp-output-autoplan.txt similarity index 100% rename from server/testfixtures/test-repos/simple/exp-output-autoplan.txt rename to server/controllers/events/testfixtures/test-repos/simple/exp-output-autoplan.txt diff --git a/server/controllers/events/testfixtures/test-repos/simple/exp-output-autoplan.txt.act b/server/controllers/events/testfixtures/test-repos/simple/exp-output-autoplan.txt.act new file mode 100644 index 000000000..b301024b0 --- /dev/null +++ b/server/controllers/events/testfixtures/test-repos/simple/exp-output-autoplan.txt.act @@ -0,0 +1,48 @@ +Ran Plan for dir: `.` workspace: `default` + +
Show Output + +```diff + +Terraform used the selected providers to generate the following execution +plan. Resource actions are indicated with the following symbols: ++ create + +Terraform will perform the following actions: + + # null_resource.simple[0] will be created ++ resource "null_resource" "simple" { + + id = (known after apply) + } + + # null_resource.simple2 will be created ++ resource "null_resource" "simple2" { + + id = (known after apply) + } + + # null_resource.simple3 will be created ++ resource "null_resource" "simple3" { + + id = (known after apply) + } + +Plan: 3 to add, 0 to change, 0 to destroy. + +Changes to Outputs: ++ var = "default" ++ workspace = "default" + +``` + +* :arrow_forward: To **apply** this plan, comment: + * `atlantis apply -d .` +* :put_litter_in_its_place: To **delete** this plan click [here](lock-url) +* :repeat: To **plan** this project again, comment: + * `atlantis plan -d .` +
+Plan: 3 to add, 0 to change, 0 to destroy. + +--- +* :fast_forward: To **apply** all unapplied plans from this pull request, comment: + * `atlantis apply` +* :put_litter_in_its_place: To delete all plans and locks for the PR, comment: + * `atlantis unlock` diff --git a/server/testfixtures/test-repos/simple/exp-output-merge-workspaces.txt b/server/controllers/events/testfixtures/test-repos/simple/exp-output-merge-workspaces.txt similarity index 100% rename from server/testfixtures/test-repos/simple/exp-output-merge-workspaces.txt rename to server/controllers/events/testfixtures/test-repos/simple/exp-output-merge-workspaces.txt diff --git a/server/testfixtures/test-repos/simple/exp-output-merge.txt b/server/controllers/events/testfixtures/test-repos/simple/exp-output-merge.txt similarity index 100% rename from server/testfixtures/test-repos/simple/exp-output-merge.txt rename to server/controllers/events/testfixtures/test-repos/simple/exp-output-merge.txt diff --git a/server/testfixtures/test-repos/simple/main.tf b/server/controllers/events/testfixtures/test-repos/simple/main.tf similarity index 100% rename from server/testfixtures/test-repos/simple/main.tf rename to server/controllers/events/testfixtures/test-repos/simple/main.tf diff --git a/server/testfixtures/test-repos/tfvars-yaml-no-autoplan/atlantis.yaml b/server/controllers/events/testfixtures/test-repos/tfvars-yaml-no-autoplan/atlantis.yaml similarity index 100% rename from server/testfixtures/test-repos/tfvars-yaml-no-autoplan/atlantis.yaml rename to server/controllers/events/testfixtures/test-repos/tfvars-yaml-no-autoplan/atlantis.yaml diff --git a/server/testfixtures/test-repos/tfvars-yaml-no-autoplan/default.backend.tfvars b/server/controllers/events/testfixtures/test-repos/tfvars-yaml-no-autoplan/default.backend.tfvars similarity index 100% rename from server/testfixtures/test-repos/tfvars-yaml-no-autoplan/default.backend.tfvars rename to server/controllers/events/testfixtures/test-repos/tfvars-yaml-no-autoplan/default.backend.tfvars diff --git a/server/testfixtures/test-repos/tfvars-yaml-no-autoplan/default.tfvars b/server/controllers/events/testfixtures/test-repos/tfvars-yaml-no-autoplan/default.tfvars similarity index 100% rename from server/testfixtures/test-repos/tfvars-yaml-no-autoplan/default.tfvars rename to server/controllers/events/testfixtures/test-repos/tfvars-yaml-no-autoplan/default.tfvars diff --git a/server/testfixtures/test-repos/tfvars-yaml-no-autoplan/exp-output-apply-default.txt b/server/controllers/events/testfixtures/test-repos/tfvars-yaml-no-autoplan/exp-output-apply-default.txt similarity index 100% rename from server/testfixtures/test-repos/tfvars-yaml-no-autoplan/exp-output-apply-default.txt rename to server/controllers/events/testfixtures/test-repos/tfvars-yaml-no-autoplan/exp-output-apply-default.txt diff --git a/server/testfixtures/test-repos/tfvars-yaml/exp-output-apply-default.txt b/server/controllers/events/testfixtures/test-repos/tfvars-yaml-no-autoplan/exp-output-apply-default.txt.act similarity index 100% rename from server/testfixtures/test-repos/tfvars-yaml/exp-output-apply-default.txt rename to server/controllers/events/testfixtures/test-repos/tfvars-yaml-no-autoplan/exp-output-apply-default.txt.act diff --git a/server/testfixtures/test-repos/tfvars-yaml-no-autoplan/exp-output-apply-staging.txt b/server/controllers/events/testfixtures/test-repos/tfvars-yaml-no-autoplan/exp-output-apply-staging.txt similarity index 100% rename from server/testfixtures/test-repos/tfvars-yaml-no-autoplan/exp-output-apply-staging.txt rename to server/controllers/events/testfixtures/test-repos/tfvars-yaml-no-autoplan/exp-output-apply-staging.txt diff --git a/server/testfixtures/test-repos/tfvars-yaml/exp-output-apply-staging.txt b/server/controllers/events/testfixtures/test-repos/tfvars-yaml-no-autoplan/exp-output-apply-staging.txt.act similarity index 100% rename from server/testfixtures/test-repos/tfvars-yaml/exp-output-apply-staging.txt rename to server/controllers/events/testfixtures/test-repos/tfvars-yaml-no-autoplan/exp-output-apply-staging.txt.act diff --git a/server/testfixtures/test-repos/tfvars-yaml-no-autoplan/exp-output-merge.txt b/server/controllers/events/testfixtures/test-repos/tfvars-yaml-no-autoplan/exp-output-merge.txt similarity index 100% rename from server/testfixtures/test-repos/tfvars-yaml-no-autoplan/exp-output-merge.txt rename to server/controllers/events/testfixtures/test-repos/tfvars-yaml-no-autoplan/exp-output-merge.txt diff --git a/server/testfixtures/test-repos/tfvars-yaml-no-autoplan/exp-output-plan-default.txt b/server/controllers/events/testfixtures/test-repos/tfvars-yaml-no-autoplan/exp-output-plan-default.txt similarity index 100% rename from server/testfixtures/test-repos/tfvars-yaml-no-autoplan/exp-output-plan-default.txt rename to server/controllers/events/testfixtures/test-repos/tfvars-yaml-no-autoplan/exp-output-plan-default.txt diff --git a/server/controllers/events/testfixtures/test-repos/tfvars-yaml-no-autoplan/exp-output-plan-default.txt.act b/server/controllers/events/testfixtures/test-repos/tfvars-yaml-no-autoplan/exp-output-plan-default.txt.act new file mode 100644 index 000000000..c97767f65 --- /dev/null +++ b/server/controllers/events/testfixtures/test-repos/tfvars-yaml-no-autoplan/exp-output-plan-default.txt.act @@ -0,0 +1,38 @@ +Ran Plan for project: `default` dir: `.` workspace: `default` + +
Show Output + +```diff + +Terraform used the selected providers to generate the following execution +plan. Resource actions are indicated with the following symbols: ++ create + +Terraform will perform the following actions: + + # null_resource.simple[0] will be created ++ resource "null_resource" "simple" { + + id = (known after apply) + } + +Plan: 1 to add, 0 to change, 0 to destroy. + +Changes to Outputs: ++ var = "default" ++ workspace = "default" + +``` + +* :arrow_forward: To **apply** this plan, comment: + * `atlantis apply -p default` +* :put_litter_in_its_place: To **delete** this plan click [here](lock-url) +* :repeat: To **plan** this project again, comment: + * `atlantis plan -p default` +
+Plan: 1 to add, 0 to change, 0 to destroy. + +--- +* :fast_forward: To **apply** all unapplied plans from this pull request, comment: + * `atlantis apply` +* :put_litter_in_its_place: To delete all plans and locks for the PR, comment: + * `atlantis unlock` diff --git a/server/testfixtures/test-repos/tfvars-yaml-no-autoplan/exp-output-plan-staging.txt b/server/controllers/events/testfixtures/test-repos/tfvars-yaml-no-autoplan/exp-output-plan-staging.txt similarity index 100% rename from server/testfixtures/test-repos/tfvars-yaml-no-autoplan/exp-output-plan-staging.txt rename to server/controllers/events/testfixtures/test-repos/tfvars-yaml-no-autoplan/exp-output-plan-staging.txt diff --git a/server/controllers/events/testfixtures/test-repos/tfvars-yaml-no-autoplan/exp-output-plan-staging.txt.act b/server/controllers/events/testfixtures/test-repos/tfvars-yaml-no-autoplan/exp-output-plan-staging.txt.act new file mode 100644 index 000000000..1c367d94b --- /dev/null +++ b/server/controllers/events/testfixtures/test-repos/tfvars-yaml-no-autoplan/exp-output-plan-staging.txt.act @@ -0,0 +1,38 @@ +Ran Plan for project: `staging` dir: `.` workspace: `default` + +
Show Output + +```diff + +Terraform used the selected providers to generate the following execution +plan. Resource actions are indicated with the following symbols: ++ create + +Terraform will perform the following actions: + + # null_resource.simple[0] will be created ++ resource "null_resource" "simple" { + + id = (known after apply) + } + +Plan: 1 to add, 0 to change, 0 to destroy. + +Changes to Outputs: ++ var = "staging" ++ workspace = "default" + +``` + +* :arrow_forward: To **apply** this plan, comment: + * `atlantis apply -p staging` +* :put_litter_in_its_place: To **delete** this plan click [here](lock-url) +* :repeat: To **plan** this project again, comment: + * `atlantis plan -p staging` +
+Plan: 1 to add, 0 to change, 0 to destroy. + +--- +* :fast_forward: To **apply** all unapplied plans from this pull request, comment: + * `atlantis apply` +* :put_litter_in_its_place: To delete all plans and locks for the PR, comment: + * `atlantis unlock` diff --git a/server/testfixtures/test-repos/tfvars-yaml-no-autoplan/main.tf b/server/controllers/events/testfixtures/test-repos/tfvars-yaml-no-autoplan/main.tf similarity index 100% rename from server/testfixtures/test-repos/tfvars-yaml-no-autoplan/main.tf rename to server/controllers/events/testfixtures/test-repos/tfvars-yaml-no-autoplan/main.tf diff --git a/server/testfixtures/test-repos/tfvars-yaml-no-autoplan/staging.backend.tfvars b/server/controllers/events/testfixtures/test-repos/tfvars-yaml-no-autoplan/staging.backend.tfvars similarity index 100% rename from server/testfixtures/test-repos/tfvars-yaml-no-autoplan/staging.backend.tfvars rename to server/controllers/events/testfixtures/test-repos/tfvars-yaml-no-autoplan/staging.backend.tfvars diff --git a/server/testfixtures/test-repos/tfvars-yaml-no-autoplan/staging.tfvars b/server/controllers/events/testfixtures/test-repos/tfvars-yaml-no-autoplan/staging.tfvars similarity index 100% rename from server/testfixtures/test-repos/tfvars-yaml-no-autoplan/staging.tfvars rename to server/controllers/events/testfixtures/test-repos/tfvars-yaml-no-autoplan/staging.tfvars diff --git a/server/testfixtures/test-repos/tfvars-yaml/atlantis.yaml b/server/controllers/events/testfixtures/test-repos/tfvars-yaml/atlantis.yaml similarity index 100% rename from server/testfixtures/test-repos/tfvars-yaml/atlantis.yaml rename to server/controllers/events/testfixtures/test-repos/tfvars-yaml/atlantis.yaml diff --git a/server/testfixtures/test-repos/tfvars-yaml/default.backend.tfvars b/server/controllers/events/testfixtures/test-repos/tfvars-yaml/default.backend.tfvars similarity index 100% rename from server/testfixtures/test-repos/tfvars-yaml/default.backend.tfvars rename to server/controllers/events/testfixtures/test-repos/tfvars-yaml/default.backend.tfvars diff --git a/server/testfixtures/test-repos/tfvars-yaml/default.tfvars b/server/controllers/events/testfixtures/test-repos/tfvars-yaml/default.tfvars similarity index 100% rename from server/testfixtures/test-repos/tfvars-yaml/default.tfvars rename to server/controllers/events/testfixtures/test-repos/tfvars-yaml/default.tfvars diff --git a/server/controllers/events/testfixtures/test-repos/tfvars-yaml/exp-output-apply-default.txt b/server/controllers/events/testfixtures/test-repos/tfvars-yaml/exp-output-apply-default.txt new file mode 100644 index 000000000..ccc0bfe01 --- /dev/null +++ b/server/controllers/events/testfixtures/test-repos/tfvars-yaml/exp-output-apply-default.txt @@ -0,0 +1,15 @@ +Ran Apply for project: `default` dir: `.` workspace: `default` + +```diff +null_resource.simple: +null_resource.simple: + +Apply complete! Resources: 1 added, 0 changed, 0 destroyed. + +Outputs: + +var = "default" +workspace = "default" + +``` + diff --git a/server/controllers/events/testfixtures/test-repos/tfvars-yaml/exp-output-apply-default.txt.act b/server/controllers/events/testfixtures/test-repos/tfvars-yaml/exp-output-apply-default.txt.act new file mode 100644 index 000000000..ccc0bfe01 --- /dev/null +++ b/server/controllers/events/testfixtures/test-repos/tfvars-yaml/exp-output-apply-default.txt.act @@ -0,0 +1,15 @@ +Ran Apply for project: `default` dir: `.` workspace: `default` + +```diff +null_resource.simple: +null_resource.simple: + +Apply complete! Resources: 1 added, 0 changed, 0 destroyed. + +Outputs: + +var = "default" +workspace = "default" + +``` + diff --git a/server/controllers/events/testfixtures/test-repos/tfvars-yaml/exp-output-apply-staging.txt b/server/controllers/events/testfixtures/test-repos/tfvars-yaml/exp-output-apply-staging.txt new file mode 100644 index 000000000..6d217cc7f --- /dev/null +++ b/server/controllers/events/testfixtures/test-repos/tfvars-yaml/exp-output-apply-staging.txt @@ -0,0 +1,15 @@ +Ran Apply for project: `staging` dir: `.` workspace: `default` + +```diff +null_resource.simple: +null_resource.simple: + +Apply complete! Resources: 1 added, 0 changed, 0 destroyed. + +Outputs: + +var = "staging" +workspace = "default" + +``` + diff --git a/server/controllers/events/testfixtures/test-repos/tfvars-yaml/exp-output-apply-staging.txt.act b/server/controllers/events/testfixtures/test-repos/tfvars-yaml/exp-output-apply-staging.txt.act new file mode 100644 index 000000000..6d217cc7f --- /dev/null +++ b/server/controllers/events/testfixtures/test-repos/tfvars-yaml/exp-output-apply-staging.txt.act @@ -0,0 +1,15 @@ +Ran Apply for project: `staging` dir: `.` workspace: `default` + +```diff +null_resource.simple: +null_resource.simple: + +Apply complete! Resources: 1 added, 0 changed, 0 destroyed. + +Outputs: + +var = "staging" +workspace = "default" + +``` + diff --git a/server/testfixtures/test-repos/tfvars-yaml/exp-output-autoplan.txt b/server/controllers/events/testfixtures/test-repos/tfvars-yaml/exp-output-autoplan.txt similarity index 100% rename from server/testfixtures/test-repos/tfvars-yaml/exp-output-autoplan.txt rename to server/controllers/events/testfixtures/test-repos/tfvars-yaml/exp-output-autoplan.txt diff --git a/server/controllers/events/testfixtures/test-repos/tfvars-yaml/exp-output-autoplan.txt.act b/server/controllers/events/testfixtures/test-repos/tfvars-yaml/exp-output-autoplan.txt.act new file mode 100644 index 000000000..73619713a --- /dev/null +++ b/server/controllers/events/testfixtures/test-repos/tfvars-yaml/exp-output-autoplan.txt.act @@ -0,0 +1,77 @@ +Ran Plan for 2 projects: + +1. project: `default` dir: `.` workspace: `default` +1. project: `staging` dir: `.` workspace: `default` + +### 1. project: `default` dir: `.` workspace: `default` +
Show Output + +```diff + +Terraform used the selected providers to generate the following execution +plan. Resource actions are indicated with the following symbols: ++ create + +Terraform will perform the following actions: + + # null_resource.simple[0] will be created ++ resource "null_resource" "simple" { + + id = (known after apply) + } + +Plan: 1 to add, 0 to change, 0 to destroy. + +Changes to Outputs: ++ var = "default" ++ workspace = "default" + +workspace=default + +``` + +* :arrow_forward: To **apply** this plan, comment: + * `atlantis apply -p default` +* :put_litter_in_its_place: To **delete** this plan click [here](lock-url) +* :repeat: To **plan** this project again, comment: + * `atlantis plan -p default` +
+Plan: 1 to add, 0 to change, 0 to destroy. + +--- +### 2. project: `staging` dir: `.` workspace: `default` +
Show Output + +```diff + +Terraform used the selected providers to generate the following execution +plan. Resource actions are indicated with the following symbols: ++ create + +Terraform will perform the following actions: + + # null_resource.simple[0] will be created ++ resource "null_resource" "simple" { + + id = (known after apply) + } + +Plan: 1 to add, 0 to change, 0 to destroy. + +Changes to Outputs: ++ var = "staging" ++ workspace = "default" + +``` + +* :arrow_forward: To **apply** this plan, comment: + * `atlantis apply -p staging` +* :put_litter_in_its_place: To **delete** this plan click [here](lock-url) +* :repeat: To **plan** this project again, comment: + * `atlantis plan -p staging` +
+Plan: 1 to add, 0 to change, 0 to destroy. + +--- +* :fast_forward: To **apply** all unapplied plans from this pull request, comment: + * `atlantis apply` +* :put_litter_in_its_place: To delete all plans and locks for the PR, comment: + * `atlantis unlock` diff --git a/server/testfixtures/test-repos/tfvars-yaml/exp-output-merge.txt b/server/controllers/events/testfixtures/test-repos/tfvars-yaml/exp-output-merge.txt similarity index 100% rename from server/testfixtures/test-repos/tfvars-yaml/exp-output-merge.txt rename to server/controllers/events/testfixtures/test-repos/tfvars-yaml/exp-output-merge.txt diff --git a/server/testfixtures/test-repos/tfvars-yaml/main.tf b/server/controllers/events/testfixtures/test-repos/tfvars-yaml/main.tf similarity index 100% rename from server/testfixtures/test-repos/tfvars-yaml/main.tf rename to server/controllers/events/testfixtures/test-repos/tfvars-yaml/main.tf diff --git a/server/testfixtures/test-repos/tfvars-yaml/staging.backend.tfvars b/server/controllers/events/testfixtures/test-repos/tfvars-yaml/staging.backend.tfvars similarity index 100% rename from server/testfixtures/test-repos/tfvars-yaml/staging.backend.tfvars rename to server/controllers/events/testfixtures/test-repos/tfvars-yaml/staging.backend.tfvars diff --git a/server/testfixtures/test-repos/tfvars-yaml/staging.tfvars b/server/controllers/events/testfixtures/test-repos/tfvars-yaml/staging.tfvars similarity index 100% rename from server/testfixtures/test-repos/tfvars-yaml/staging.tfvars rename to server/controllers/events/testfixtures/test-repos/tfvars-yaml/staging.tfvars diff --git a/server/testfixtures/test-repos/workspace-parallel-yaml/atlantis.yaml b/server/controllers/events/testfixtures/test-repos/workspace-parallel-yaml/atlantis.yaml similarity index 100% rename from server/testfixtures/test-repos/workspace-parallel-yaml/atlantis.yaml rename to server/controllers/events/testfixtures/test-repos/workspace-parallel-yaml/atlantis.yaml diff --git a/server/testfixtures/test-repos/workspace-parallel-yaml/exp-output-apply-all-production.txt b/server/controllers/events/testfixtures/test-repos/workspace-parallel-yaml/exp-output-apply-all-production.txt similarity index 100% rename from server/testfixtures/test-repos/workspace-parallel-yaml/exp-output-apply-all-production.txt rename to server/controllers/events/testfixtures/test-repos/workspace-parallel-yaml/exp-output-apply-all-production.txt diff --git a/server/controllers/events/testfixtures/test-repos/workspace-parallel-yaml/exp-output-apply-all-production.txt.act b/server/controllers/events/testfixtures/test-repos/workspace-parallel-yaml/exp-output-apply-all-production.txt.act new file mode 100644 index 000000000..b82518ed6 --- /dev/null +++ b/server/controllers/events/testfixtures/test-repos/workspace-parallel-yaml/exp-output-apply-all-production.txt.act @@ -0,0 +1,34 @@ +Ran Apply for 2 projects: + +1. dir: `production` workspace: `production` +1. dir: `staging` workspace: `staging` + +### 1. dir: `production` workspace: `production` +```diff +null_resource.this: Creating... +null_resource.this: Creation complete after *s [id=*******************] + +Apply complete! Resources: 1 added, 0 changed, 0 destroyed. + +Outputs: + +workspace = "production" + +``` + +--- +### 2. dir: `staging` workspace: `staging` +```diff +null_resource.this: Creating... +null_resource.this: Creation complete after *s [id=*******************] + +Apply complete! Resources: 1 added, 0 changed, 0 destroyed. + +Outputs: + +workspace = "staging" + +``` + +--- + diff --git a/server/testfixtures/test-repos/workspace-parallel-yaml/exp-output-apply-all-staging.txt b/server/controllers/events/testfixtures/test-repos/workspace-parallel-yaml/exp-output-apply-all-staging.txt similarity index 100% rename from server/testfixtures/test-repos/workspace-parallel-yaml/exp-output-apply-all-staging.txt rename to server/controllers/events/testfixtures/test-repos/workspace-parallel-yaml/exp-output-apply-all-staging.txt diff --git a/server/controllers/events/testfixtures/test-repos/workspace-parallel-yaml/exp-output-apply-all-staging.txt.act b/server/controllers/events/testfixtures/test-repos/workspace-parallel-yaml/exp-output-apply-all-staging.txt.act new file mode 100644 index 000000000..b82518ed6 --- /dev/null +++ b/server/controllers/events/testfixtures/test-repos/workspace-parallel-yaml/exp-output-apply-all-staging.txt.act @@ -0,0 +1,34 @@ +Ran Apply for 2 projects: + +1. dir: `production` workspace: `production` +1. dir: `staging` workspace: `staging` + +### 1. dir: `production` workspace: `production` +```diff +null_resource.this: Creating... +null_resource.this: Creation complete after *s [id=*******************] + +Apply complete! Resources: 1 added, 0 changed, 0 destroyed. + +Outputs: + +workspace = "production" + +``` + +--- +### 2. dir: `staging` workspace: `staging` +```diff +null_resource.this: Creating... +null_resource.this: Creation complete after *s [id=*******************] + +Apply complete! Resources: 1 added, 0 changed, 0 destroyed. + +Outputs: + +workspace = "staging" + +``` + +--- + diff --git a/server/testfixtures/test-repos/workspace-parallel-yaml/exp-output-autoplan-production.txt b/server/controllers/events/testfixtures/test-repos/workspace-parallel-yaml/exp-output-autoplan-production.txt similarity index 100% rename from server/testfixtures/test-repos/workspace-parallel-yaml/exp-output-autoplan-production.txt rename to server/controllers/events/testfixtures/test-repos/workspace-parallel-yaml/exp-output-autoplan-production.txt diff --git a/server/testfixtures/test-repos/workspace-parallel-yaml/exp-output-autoplan-staging.txt b/server/controllers/events/testfixtures/test-repos/workspace-parallel-yaml/exp-output-autoplan-production.txt.act similarity index 100% rename from server/testfixtures/test-repos/workspace-parallel-yaml/exp-output-autoplan-staging.txt rename to server/controllers/events/testfixtures/test-repos/workspace-parallel-yaml/exp-output-autoplan-production.txt.act diff --git a/server/controllers/events/testfixtures/test-repos/workspace-parallel-yaml/exp-output-autoplan-staging.txt b/server/controllers/events/testfixtures/test-repos/workspace-parallel-yaml/exp-output-autoplan-staging.txt new file mode 100644 index 000000000..a8f4b695a --- /dev/null +++ b/server/controllers/events/testfixtures/test-repos/workspace-parallel-yaml/exp-output-autoplan-staging.txt @@ -0,0 +1,73 @@ +Ran Plan for 2 projects: + +1. dir: `production` workspace: `production` +1. dir: `staging` workspace: `staging` + +### 1. dir: `production` workspace: `production` +
Show Output + +```diff + +Terraform used the selected providers to generate the following execution +plan. Resource actions are indicated with the following symbols: ++ create + +Terraform will perform the following actions: + + # null_resource.this will be created ++ resource "null_resource" "this" { + + id = (known after apply) + } + +Plan: 1 to add, 0 to change, 0 to destroy. + +Changes to Outputs: ++ workspace = "production" + +``` + +* :arrow_forward: To **apply** this plan, comment: + * `atlantis apply -d production -w production` +* :put_litter_in_its_place: To **delete** this plan click [here](lock-url) +* :repeat: To **plan** this project again, comment: + * `atlantis plan -d production -w production` +
+Plan: 1 to add, 0 to change, 0 to destroy. + +--- +### 2. dir: `staging` workspace: `staging` +
Show Output + +```diff + +Terraform used the selected providers to generate the following execution +plan. Resource actions are indicated with the following symbols: ++ create + +Terraform will perform the following actions: + + # null_resource.this will be created ++ resource "null_resource" "this" { + + id = (known after apply) + } + +Plan: 1 to add, 0 to change, 0 to destroy. + +Changes to Outputs: ++ workspace = "staging" + +``` + +* :arrow_forward: To **apply** this plan, comment: + * `atlantis apply -d staging -w staging` +* :put_litter_in_its_place: To **delete** this plan click [here](lock-url) +* :repeat: To **plan** this project again, comment: + * `atlantis plan -d staging -w staging` +
+Plan: 1 to add, 0 to change, 0 to destroy. + +--- +* :fast_forward: To **apply** all unapplied plans from this pull request, comment: + * `atlantis apply` +* :put_litter_in_its_place: To delete all plans and locks for the PR, comment: + * `atlantis unlock` diff --git a/server/controllers/events/testfixtures/test-repos/workspace-parallel-yaml/exp-output-autoplan-staging.txt.act b/server/controllers/events/testfixtures/test-repos/workspace-parallel-yaml/exp-output-autoplan-staging.txt.act new file mode 100644 index 000000000..a8f4b695a --- /dev/null +++ b/server/controllers/events/testfixtures/test-repos/workspace-parallel-yaml/exp-output-autoplan-staging.txt.act @@ -0,0 +1,73 @@ +Ran Plan for 2 projects: + +1. dir: `production` workspace: `production` +1. dir: `staging` workspace: `staging` + +### 1. dir: `production` workspace: `production` +
Show Output + +```diff + +Terraform used the selected providers to generate the following execution +plan. Resource actions are indicated with the following symbols: ++ create + +Terraform will perform the following actions: + + # null_resource.this will be created ++ resource "null_resource" "this" { + + id = (known after apply) + } + +Plan: 1 to add, 0 to change, 0 to destroy. + +Changes to Outputs: ++ workspace = "production" + +``` + +* :arrow_forward: To **apply** this plan, comment: + * `atlantis apply -d production -w production` +* :put_litter_in_its_place: To **delete** this plan click [here](lock-url) +* :repeat: To **plan** this project again, comment: + * `atlantis plan -d production -w production` +
+Plan: 1 to add, 0 to change, 0 to destroy. + +--- +### 2. dir: `staging` workspace: `staging` +
Show Output + +```diff + +Terraform used the selected providers to generate the following execution +plan. Resource actions are indicated with the following symbols: ++ create + +Terraform will perform the following actions: + + # null_resource.this will be created ++ resource "null_resource" "this" { + + id = (known after apply) + } + +Plan: 1 to add, 0 to change, 0 to destroy. + +Changes to Outputs: ++ workspace = "staging" + +``` + +* :arrow_forward: To **apply** this plan, comment: + * `atlantis apply -d staging -w staging` +* :put_litter_in_its_place: To **delete** this plan click [here](lock-url) +* :repeat: To **plan** this project again, comment: + * `atlantis plan -d staging -w staging` +
+Plan: 1 to add, 0 to change, 0 to destroy. + +--- +* :fast_forward: To **apply** all unapplied plans from this pull request, comment: + * `atlantis apply` +* :put_litter_in_its_place: To delete all plans and locks for the PR, comment: + * `atlantis unlock` diff --git a/server/testfixtures/test-repos/workspace-parallel-yaml/exp-output-merge.txt b/server/controllers/events/testfixtures/test-repos/workspace-parallel-yaml/exp-output-merge.txt similarity index 100% rename from server/testfixtures/test-repos/workspace-parallel-yaml/exp-output-merge.txt rename to server/controllers/events/testfixtures/test-repos/workspace-parallel-yaml/exp-output-merge.txt diff --git a/server/testfixtures/test-repos/workspace-parallel-yaml/production/main.tf b/server/controllers/events/testfixtures/test-repos/workspace-parallel-yaml/production/main.tf similarity index 100% rename from server/testfixtures/test-repos/workspace-parallel-yaml/production/main.tf rename to server/controllers/events/testfixtures/test-repos/workspace-parallel-yaml/production/main.tf diff --git a/server/testfixtures/test-repos/workspace-parallel-yaml/staging/main.tf b/server/controllers/events/testfixtures/test-repos/workspace-parallel-yaml/staging/main.tf similarity index 100% rename from server/testfixtures/test-repos/workspace-parallel-yaml/staging/main.tf rename to server/controllers/events/testfixtures/test-repos/workspace-parallel-yaml/staging/main.tf diff --git a/server/github_app_controller.go b/server/controllers/github_app_controller.go similarity index 95% rename from server/github_app_controller.go rename to server/controllers/github_app_controller.go index 4fed5968d..d8808cd83 100644 --- a/server/github_app_controller.go +++ b/server/controllers/github_app_controller.go @@ -1,4 +1,4 @@ -package server +package controllers import ( "encoding/json" @@ -6,6 +6,7 @@ import ( "net/http" "net/url" + "github.com/runatlantis/atlantis/server/controllers/templates" "github.com/runatlantis/atlantis/server/events/vcs" "github.com/runatlantis/atlantis/server/logging" ) @@ -68,7 +69,7 @@ func (g *GithubAppController) ExchangeCode(w http.ResponseWriter, r *http.Reques g.Logger.Debug("Found credentials for GitHub app %q with id %d", app.Name, app.ID) - err = githubAppSetupTemplate.Execute(w, GithubSetupData{ + err = templates.GithubAppSetupTemplate.Execute(w, templates.GithubSetupData{ Target: "", Manifest: "", ID: app.ID, @@ -137,7 +138,7 @@ func (g *GithubAppController) New(w http.ResponseWriter, r *http.Request) { return } - err = githubAppSetupTemplate.Execute(w, GithubSetupData{ + err = templates.GithubAppSetupTemplate.Execute(w, templates.GithubSetupData{ Target: url.String(), Manifest: string(jsonManifest), }) diff --git a/server/locks_controller.go b/server/controllers/locks_controller.go similarity index 97% rename from server/locks_controller.go rename to server/controllers/locks_controller.go index 8d7eebcfb..efe5d7c4e 100644 --- a/server/locks_controller.go +++ b/server/controllers/locks_controller.go @@ -1,10 +1,11 @@ -package server +package controllers import ( "fmt" "net/http" "net/url" + "github.com/runatlantis/atlantis/server/controllers/templates" "github.com/runatlantis/atlantis/server/events/db" "github.com/gorilla/mux" @@ -23,7 +24,7 @@ type LocksController struct { Logger logging.SimpleLogging ApplyLocker locking.ApplyLocker VCSClient vcs.Client - LockDetailTemplate TemplateWriter + LockDetailTemplate templates.TemplateWriter WorkingDir events.WorkingDir WorkingDirLocker events.WorkingDirLocker DB *db.BoltDB @@ -78,7 +79,7 @@ func (l *LocksController) GetLock(w http.ResponseWriter, r *http.Request) { } owner, repo := models.SplitRepoFullName(lock.Project.RepoFullName) - viewData := LockDetailData{ + viewData := templates.LockDetailData{ LockKeyEncoded: id, LockKey: idUnencoded, PullRequestLink: lock.Pull.URL, diff --git a/server/locks_controller_test.go b/server/controllers/locks_controller_test.go similarity index 84% rename from server/locks_controller_test.go rename to server/controllers/locks_controller_test.go index 82ef0c191..d440ee2e5 100644 --- a/server/locks_controller_test.go +++ b/server/controllers/locks_controller_test.go @@ -1,4 +1,4 @@ -package server_test +package controllers_test import ( "bytes" @@ -11,12 +11,14 @@ import ( "testing" "time" + "github.com/runatlantis/atlantis/server/controllers" + "github.com/runatlantis/atlantis/server/controllers/templates" + tMocks "github.com/runatlantis/atlantis/server/controllers/templates/mocks" "github.com/runatlantis/atlantis/server/events/db" "github.com/runatlantis/atlantis/server/events/locking" "github.com/gorilla/mux" . "github.com/petergtz/pegomock" - "github.com/runatlantis/atlantis/server" "github.com/runatlantis/atlantis/server/events" "github.com/runatlantis/atlantis/server/events/locking/mocks" @@ -24,7 +26,6 @@ import ( "github.com/runatlantis/atlantis/server/events/models" vcsmocks "github.com/runatlantis/atlantis/server/events/vcs/mocks" "github.com/runatlantis/atlantis/server/logging" - sMocks "github.com/runatlantis/atlantis/server/mocks" . "github.com/runatlantis/atlantis/testing" ) @@ -49,13 +50,13 @@ func TestCreateApplyLock(t *testing.T) { Time: lockTime, }, nil) - lc := server.LocksController{ + lc := controllers.LocksController{ Logger: logging.NewNoopLogger(t), ApplyLocker: l, } lc.LockApply(w, req) - responseContains(t, w, http.StatusOK, fmt.Sprintf("Apply Lock is acquired on %s", expLockTime)) + ResponseContains(t, w, http.StatusOK, fmt.Sprintf("Apply Lock is acquired on %s", expLockTime)) }) t.Run("Apply lock creation fails", func(t *testing.T) { @@ -67,13 +68,13 @@ func TestCreateApplyLock(t *testing.T) { Locked: false, }, errors.New("failed to acquire lock")) - lc := server.LocksController{ + lc := controllers.LocksController{ Logger: logging.NewNoopLogger(t), ApplyLocker: l, } lc.LockApply(w, req) - responseContains(t, w, http.StatusInternalServerError, "creating apply lock failed with: failed to acquire lock") + ResponseContains(t, w, http.StatusInternalServerError, "creating apply lock failed with: failed to acquire lock") }) } @@ -85,13 +86,13 @@ func TestUnlockApply(t *testing.T) { l := mocks.NewMockApplyLocker() When(l.UnlockApply()).ThenReturn(nil) - lc := server.LocksController{ + lc := controllers.LocksController{ Logger: logging.NewNoopLogger(t), ApplyLocker: l, } lc.UnlockApply(w, req) - responseContains(t, w, http.StatusOK, "Deleted apply lock") + ResponseContains(t, w, http.StatusOK, "Deleted apply lock") }) t.Run("Apply lock deletion failed", func(t *testing.T) { @@ -101,13 +102,13 @@ func TestUnlockApply(t *testing.T) { l := mocks.NewMockApplyLocker() When(l.UnlockApply()).ThenReturn(errors.New("failed to delete lock")) - lc := server.LocksController{ + lc := controllers.LocksController{ Logger: logging.NewNoopLogger(t), ApplyLocker: l, } lc.UnlockApply(w, req) - responseContains(t, w, http.StatusInternalServerError, "deleting apply lock failed with: failed to delete lock") + ResponseContains(t, w, http.StatusInternalServerError, "deleting apply lock failed with: failed to delete lock") }) } @@ -115,23 +116,23 @@ func TestGetLockRoute_NoLockID(t *testing.T) { t.Log("If there is no lock ID in the request then we should get a 400") req, _ := http.NewRequest("GET", "", bytes.NewBuffer(nil)) w := httptest.NewRecorder() - lc := server.LocksController{ + lc := controllers.LocksController{ Logger: logging.NewNoopLogger(t), } lc.GetLock(w, req) - responseContains(t, w, http.StatusBadRequest, "No lock id in request") + ResponseContains(t, w, http.StatusBadRequest, "No lock id in request") } func TestGetLock_InvalidLockID(t *testing.T) { t.Log("If the lock ID is invalid then we should get a 400") - lc := server.LocksController{ + lc := controllers.LocksController{ Logger: logging.NewNoopLogger(t), } req, _ := http.NewRequest("GET", "", bytes.NewBuffer(nil)) req = mux.SetURLVars(req, map[string]string{"id": "%A@"}) w := httptest.NewRecorder() lc.GetLock(w, req) - responseContains(t, w, http.StatusBadRequest, "Invalid lock id") + ResponseContains(t, w, http.StatusBadRequest, "Invalid lock id") } func TestGetLock_LockerErr(t *testing.T) { @@ -139,7 +140,7 @@ func TestGetLock_LockerErr(t *testing.T) { RegisterMockTestingT(t) l := mocks.NewMockLocker() When(l.GetLock("id")).ThenReturn(nil, errors.New("err")) - lc := server.LocksController{ + lc := controllers.LocksController{ Logger: logging.NewNoopLogger(t), Locker: l, } @@ -147,7 +148,7 @@ func TestGetLock_LockerErr(t *testing.T) { req = mux.SetURLVars(req, map[string]string{"id": "id"}) w := httptest.NewRecorder() lc.GetLock(w, req) - responseContains(t, w, http.StatusInternalServerError, "err") + ResponseContains(t, w, http.StatusInternalServerError, "err") } func TestGetLock_None(t *testing.T) { @@ -155,7 +156,7 @@ func TestGetLock_None(t *testing.T) { RegisterMockTestingT(t) l := mocks.NewMockLocker() When(l.GetLock("id")).ThenReturn(nil, nil) - lc := server.LocksController{ + lc := controllers.LocksController{ Logger: logging.NewNoopLogger(t), Locker: l, } @@ -163,7 +164,7 @@ func TestGetLock_None(t *testing.T) { req = mux.SetURLVars(req, map[string]string{"id": "id"}) w := httptest.NewRecorder() lc.GetLock(w, req) - responseContains(t, w, http.StatusNotFound, "No lock found at id \"id\"") + ResponseContains(t, w, http.StatusNotFound, "No lock found at id \"id\"") } func TestGetLock_Success(t *testing.T) { @@ -175,10 +176,10 @@ func TestGetLock_Success(t *testing.T) { Pull: models.PullRequest{URL: "url", Author: "lkysow"}, Workspace: "workspace", }, nil) - tmpl := sMocks.NewMockTemplateWriter() + tmpl := tMocks.NewMockTemplateWriter() atlantisURL, err := url.Parse("https://example.com/basepath") Ok(t, err) - lc := server.LocksController{ + lc := controllers.LocksController{ Logger: logging.NewNoopLogger(t), Locker: l, LockDetailTemplate: tmpl, @@ -189,7 +190,7 @@ func TestGetLock_Success(t *testing.T) { req = mux.SetURLVars(req, map[string]string{"id": "id"}) w := httptest.NewRecorder() lc.GetLock(w, req) - tmpl.VerifyWasCalledOnce().Execute(w, server.LockDetailData{ + tmpl.VerifyWasCalledOnce().Execute(w, templates.LockDetailData{ LockKeyEncoded: "id", LockKey: "id", RepoOwner: "owner", @@ -200,26 +201,26 @@ func TestGetLock_Success(t *testing.T) { AtlantisVersion: "1300135", CleanedBasePath: "/basepath", }) - responseContains(t, w, http.StatusOK, "") + ResponseContains(t, w, http.StatusOK, "") } func TestDeleteLock_NoLockID(t *testing.T) { t.Log("If there is no lock ID in the request then we should get a 400") req, _ := http.NewRequest("GET", "", bytes.NewBuffer(nil)) w := httptest.NewRecorder() - lc := server.LocksController{Logger: logging.NewNoopLogger(t)} + lc := controllers.LocksController{Logger: logging.NewNoopLogger(t)} lc.DeleteLock(w, req) - responseContains(t, w, http.StatusBadRequest, "No lock id in request") + ResponseContains(t, w, http.StatusBadRequest, "No lock id in request") } func TestDeleteLock_InvalidLockID(t *testing.T) { t.Log("If the lock ID is invalid then we should get a 400") - lc := server.LocksController{Logger: logging.NewNoopLogger(t)} + lc := controllers.LocksController{Logger: logging.NewNoopLogger(t)} req, _ := http.NewRequest("GET", "", bytes.NewBuffer(nil)) req = mux.SetURLVars(req, map[string]string{"id": "%A@"}) w := httptest.NewRecorder() lc.DeleteLock(w, req) - responseContains(t, w, http.StatusBadRequest, "Invalid lock id \"%A@\"") + ResponseContains(t, w, http.StatusBadRequest, "Invalid lock id \"%A@\"") } func TestDeleteLock_LockerErr(t *testing.T) { @@ -227,7 +228,7 @@ func TestDeleteLock_LockerErr(t *testing.T) { RegisterMockTestingT(t) dlc := mocks2.NewMockDeleteLockCommand() When(dlc.DeleteLock("id")).ThenReturn(nil, errors.New("err")) - lc := server.LocksController{ + lc := controllers.LocksController{ DeleteLockCommand: dlc, Logger: logging.NewNoopLogger(t), } @@ -235,7 +236,7 @@ func TestDeleteLock_LockerErr(t *testing.T) { req = mux.SetURLVars(req, map[string]string{"id": "id"}) w := httptest.NewRecorder() lc.DeleteLock(w, req) - responseContains(t, w, http.StatusInternalServerError, "err") + ResponseContains(t, w, http.StatusInternalServerError, "err") } func TestDeleteLock_None(t *testing.T) { @@ -243,7 +244,7 @@ func TestDeleteLock_None(t *testing.T) { RegisterMockTestingT(t) dlc := mocks2.NewMockDeleteLockCommand() When(dlc.DeleteLock("id")).ThenReturn(nil, nil) - lc := server.LocksController{ + lc := controllers.LocksController{ DeleteLockCommand: dlc, Logger: logging.NewNoopLogger(t), } @@ -251,7 +252,7 @@ func TestDeleteLock_None(t *testing.T) { req = mux.SetURLVars(req, map[string]string{"id": "id"}) w := httptest.NewRecorder() lc.DeleteLock(w, req) - responseContains(t, w, http.StatusNotFound, "No lock found at id \"id\"") + ResponseContains(t, w, http.StatusNotFound, "No lock found at id \"id\"") } func TestDeleteLock_OldFormat(t *testing.T) { @@ -260,7 +261,7 @@ func TestDeleteLock_OldFormat(t *testing.T) { cp := vcsmocks.NewMockClient() dlc := mocks2.NewMockDeleteLockCommand() When(dlc.DeleteLock("id")).ThenReturn(&models.ProjectLock{}, nil) - lc := server.LocksController{ + lc := controllers.LocksController{ DeleteLockCommand: dlc, Logger: logging.NewNoopLogger(t), VCSClient: cp, @@ -269,7 +270,7 @@ func TestDeleteLock_OldFormat(t *testing.T) { req = mux.SetURLVars(req, map[string]string{"id": "id"}) w := httptest.NewRecorder() lc.DeleteLock(w, req) - responseContains(t, w, http.StatusOK, "Deleted lock id \"id\"") + ResponseContains(t, w, http.StatusOK, "Deleted lock id \"id\"") cp.VerifyWasCalled(Never()).CreateComment(AnyRepo(), AnyInt(), AnyString(), AnyString()) } @@ -313,7 +314,7 @@ func TestDeleteLock_UpdateProjectStatus(t *testing.T) { }, }) Ok(t, err) - lc := server.LocksController{ + lc := controllers.LocksController{ DeleteLockCommand: l, Logger: logging.NewNoopLogger(t), VCSClient: cp, @@ -325,7 +326,7 @@ func TestDeleteLock_UpdateProjectStatus(t *testing.T) { req = mux.SetURLVars(req, map[string]string{"id": "id"}) w := httptest.NewRecorder() lc.DeleteLock(w, req) - responseContains(t, w, http.StatusOK, "Deleted lock id \"id\"") + ResponseContains(t, w, http.StatusOK, "Deleted lock id \"id\"") status, err := db.GetPullStatus(pull) Ok(t, err) Assert(t, status.Projects != nil, "status projects was nil") @@ -355,7 +356,7 @@ func TestDeleteLock_CommentFailed(t *testing.T) { defer cleanup() db, err := db.New(tmp) Ok(t, err) - lc := server.LocksController{ + lc := controllers.LocksController{ DeleteLockCommand: dlc, Logger: logging.NewNoopLogger(t), VCSClient: cp, @@ -367,7 +368,7 @@ func TestDeleteLock_CommentFailed(t *testing.T) { req = mux.SetURLVars(req, map[string]string{"id": "id"}) w := httptest.NewRecorder() lc.DeleteLock(w, req) - responseContains(t, w, http.StatusOK, "Deleted lock id \"id\"") + ResponseContains(t, w, http.StatusOK, "Deleted lock id \"id\"") } func TestDeleteLock_CommentSuccess(t *testing.T) { @@ -392,7 +393,7 @@ func TestDeleteLock_CommentSuccess(t *testing.T) { defer cleanup() db, err := db.New(tmp) Ok(t, err) - lc := server.LocksController{ + lc := controllers.LocksController{ DeleteLockCommand: dlc, Logger: logging.NewNoopLogger(t), VCSClient: cp, @@ -404,7 +405,7 @@ func TestDeleteLock_CommentSuccess(t *testing.T) { req = mux.SetURLVars(req, map[string]string{"id": "id"}) w := httptest.NewRecorder() lc.DeleteLock(w, req) - responseContains(t, w, http.StatusOK, "Deleted lock id \"id\"") + ResponseContains(t, w, http.StatusOK, "Deleted lock id \"id\"") cp.VerifyWasCalled(Once()).CreateComment(pull.BaseRepo, pull.Num, "**Warning**: The plan for dir: `path` workspace: `workspace` was **discarded** via the Atlantis UI.\n\n"+ "To `apply` this plan you must run `plan` again.", "") diff --git a/server/status_controller.go b/server/controllers/status_controller.go similarity index 97% rename from server/status_controller.go rename to server/controllers/status_controller.go index 411176437..e54b3e114 100644 --- a/server/status_controller.go +++ b/server/controllers/status_controller.go @@ -1,4 +1,4 @@ -package server +package controllers import ( "encoding/json" diff --git a/server/status_controller_test.go b/server/controllers/status_controller_test.go similarity index 84% rename from server/status_controller_test.go rename to server/controllers/status_controller_test.go index 9032febb0..e809099e1 100644 --- a/server/status_controller_test.go +++ b/server/controllers/status_controller_test.go @@ -1,4 +1,4 @@ -package server_test +package controllers_test import ( "bytes" @@ -8,7 +8,7 @@ import ( "net/http/httptest" "testing" - "github.com/runatlantis/atlantis/server" + "github.com/runatlantis/atlantis/server/controllers" "github.com/runatlantis/atlantis/server/events" "github.com/runatlantis/atlantis/server/logging" . "github.com/runatlantis/atlantis/testing" @@ -19,13 +19,13 @@ func TestStatusController_Startup(t *testing.T) { r, _ := http.NewRequest("GET", "/status", bytes.NewBuffer(nil)) w := httptest.NewRecorder() dr := &events.Drainer{} - d := &server.StatusController{ + d := &controllers.StatusController{ Logger: logger, Drainer: dr, } d.Get(w, r) - var result server.StatusResponse + var result controllers.StatusResponse body, err := ioutil.ReadAll(w.Result().Body) Ok(t, err) Equals(t, 200, w.Result().StatusCode) @@ -42,13 +42,13 @@ func TestStatusController_InProgress(t *testing.T) { dr := &events.Drainer{} dr.StartOp() - d := &server.StatusController{ + d := &controllers.StatusController{ Logger: logger, Drainer: dr, } d.Get(w, r) - var result server.StatusResponse + var result controllers.StatusResponse body, err := ioutil.ReadAll(w.Result().Body) Ok(t, err) Equals(t, 200, w.Result().StatusCode) @@ -65,13 +65,13 @@ func TestStatusController_Shutdown(t *testing.T) { dr := &events.Drainer{} dr.ShutdownBlocking() - d := &server.StatusController{ + d := &controllers.StatusController{ Logger: logger, Drainer: dr, } d.Get(w, r) - var result server.StatusResponse + var result controllers.StatusResponse body, err := ioutil.ReadAll(w.Result().Body) Ok(t, err) Equals(t, 200, w.Result().StatusCode) diff --git a/server/mocks/matchers/io_writer.go b/server/controllers/templates/mocks/matchers/io_writer.go similarity index 100% rename from server/mocks/matchers/io_writer.go rename to server/controllers/templates/mocks/matchers/io_writer.go diff --git a/server/mocks/mock_template_writer.go b/server/controllers/templates/mocks/mock_template_writer.go similarity index 97% rename from server/mocks/mock_template_writer.go rename to server/controllers/templates/mocks/mock_template_writer.go index 11bfd3575..14a3daff5 100644 --- a/server/mocks/mock_template_writer.go +++ b/server/controllers/templates/mocks/mock_template_writer.go @@ -1,5 +1,5 @@ // Code generated by pegomock. DO NOT EDIT. -// Source: github.com/runatlantis/atlantis/server (interfaces: TemplateWriter) +// Source: github.com/runatlantis/atlantis/server/controllers/templates (interfaces: TemplateWriter) package mocks diff --git a/server/web_templates.go b/server/controllers/templates/web_templates.go similarity index 98% rename from server/web_templates.go rename to server/controllers/templates/web_templates.go index 5aefa76dc..4c120d455 100644 --- a/server/web_templates.go +++ b/server/controllers/templates/web_templates.go @@ -11,7 +11,7 @@ // limitations under the License. // Modified hereafter by contributors to runatlantis/atlantis. -package server +package templates import ( "html/template" @@ -58,7 +58,7 @@ type IndexData struct { CleanedBasePath string } -var indexTemplate = template.Must(template.New("index.html.tmpl").Parse(` +var IndexTemplate = template.Must(template.New("index.html.tmpl").Parse(` @@ -250,7 +250,7 @@ type LockDetailData struct { CleanedBasePath string } -var lockTemplate = template.Must(template.New("lock.html.tmpl").Parse(` +var LockTemplate = template.Must(template.New("lock.html.tmpl").Parse(` @@ -362,7 +362,7 @@ type GithubSetupData struct { URL string } -var githubAppSetupTemplate = template.Must(template.New("github-app.html.tmpl").Parse(` +var GithubAppSetupTemplate = template.Must(template.New("github-app.html.tmpl").Parse(` diff --git a/server/server.go b/server/server.go index 5b1875768..7b3d24b82 100644 --- a/server/server.go +++ b/server/server.go @@ -38,6 +38,9 @@ import ( assetfs "github.com/elazarl/go-bindata-assetfs" "github.com/gorilla/mux" "github.com/pkg/errors" + "github.com/runatlantis/atlantis/server/controllers" + events_controllers "github.com/runatlantis/atlantis/server/controllers/events" + "github.com/runatlantis/atlantis/server/controllers/templates" "github.com/runatlantis/atlantis/server/events" "github.com/runatlantis/atlantis/server/events/locking" "github.com/runatlantis/atlantis/server/events/models" @@ -85,12 +88,12 @@ type Server struct { Logger logging.SimpleLogging Locker locking.Locker ApplyLocker locking.ApplyLocker - EventsController *EventsController - GithubAppController *GithubAppController - LocksController *LocksController - StatusController *StatusController - IndexTemplate TemplateWriter - LockDetailTemplate TemplateWriter + VCSEventsController *events_controllers.VCSEventsController + GithubAppController *controllers.GithubAppController + LocksController *controllers.LocksController + StatusController *controllers.StatusController + IndexTemplate templates.TemplateWriter + LockDetailTemplate templates.TemplateWriter SSLCertFile string SSLKeyFile string Drainer *events.Drainer @@ -404,7 +407,7 @@ func NewServer(userConfig UserConfig, config Config) (*Server, error) { TerraformBinDir: terraformClient.TerraformBinDir(), } drainer := &events.Drainer{} - statusController := &StatusController{ + statusController := &controllers.StatusController{ Logger: logger, Drainer: drainer, } @@ -577,20 +580,20 @@ func NewServer(userConfig UserConfig, config Config) (*Server, error) { if err != nil { return nil, err } - locksController := &LocksController{ + locksController := &controllers.LocksController{ AtlantisVersion: config.AtlantisVersion, AtlantisURL: parsedURL, Locker: lockingClient, ApplyLocker: applyLockingClient, Logger: logger, VCSClient: vcsClient, - LockDetailTemplate: lockTemplate, + LockDetailTemplate: templates.LockTemplate, WorkingDir: workingDir, WorkingDirLocker: workingDirLocker, DB: boltdb, DeleteLockCommand: deleteLockCommand, } - eventsController := &EventsController{ + eventsController := &events_controllers.VCSEventsController{ CommandRunner: commandRunner, PullCleaner: pullClosedExecutor, Parser: eventParser, @@ -598,8 +601,8 @@ func NewServer(userConfig UserConfig, config Config) (*Server, error) { Logger: logger, ApplyDisabled: userConfig.DisableApply, GithubWebhookSecret: []byte(userConfig.GithubWebhookSecret), - GithubRequestValidator: &DefaultGithubRequestValidator{}, - GitlabRequestParserValidator: &DefaultGitlabRequestParserValidator{}, + GithubRequestValidator: &events_controllers.DefaultGithubRequestValidator{}, + GitlabRequestParserValidator: &events_controllers.DefaultGitlabRequestParserValidator{}, GitlabWebhookSecret: []byte(userConfig.GitlabWebhookSecret), RepoAllowlistChecker: repoAllowlist, SilenceAllowlistErrors: userConfig.SilenceAllowlistErrors, @@ -608,9 +611,9 @@ func NewServer(userConfig UserConfig, config Config) (*Server, error) { BitbucketWebhookSecret: []byte(userConfig.BitbucketWebhookSecret), AzureDevopsWebhookBasicUser: []byte(userConfig.AzureDevopsWebhookUser), AzureDevopsWebhookBasicPassword: []byte(userConfig.AzureDevopsWebhookPassword), - AzureDevopsRequestValidator: &DefaultAzureDevopsRequestValidator{}, + AzureDevopsRequestValidator: &events_controllers.DefaultAzureDevopsRequestValidator{}, } - githubAppController := &GithubAppController{ + githubAppController := &controllers.GithubAppController{ AtlantisURL: parsedURL, Logger: logger, GithubSetupComplete: githubAppEnabled, @@ -628,12 +631,12 @@ func NewServer(userConfig UserConfig, config Config) (*Server, error) { Logger: logger, Locker: lockingClient, ApplyLocker: applyLockingClient, - EventsController: eventsController, + VCSEventsController: eventsController, GithubAppController: githubAppController, LocksController: locksController, StatusController: statusController, - IndexTemplate: indexTemplate, - LockDetailTemplate: lockTemplate, + IndexTemplate: templates.IndexTemplate, + LockDetailTemplate: templates.LockTemplate, SSLKeyFile: userConfig.SSLKeyFile, SSLCertFile: userConfig.SSLCertFile, Drainer: drainer, @@ -648,7 +651,7 @@ func (s *Server) Start() error { s.Router.HandleFunc("/healthz", s.Healthz).Methods("GET") s.Router.HandleFunc("/status", s.StatusController.Get).Methods("GET") s.Router.PathPrefix("/static/").Handler(http.FileServer(&assetfs.AssetFS{Asset: static.Asset, AssetDir: static.AssetDir, AssetInfo: static.AssetInfo})) - s.Router.HandleFunc("/events", s.EventsController.Post).Methods("POST") + s.Router.HandleFunc("/events", s.VCSEventsController.Post).Methods("POST") s.Router.HandleFunc("/github-app/exchange-code", s.GithubAppController.ExchangeCode).Methods("GET") s.Router.HandleFunc("/github-app/setup", s.GithubAppController.New).Methods("GET") s.Router.HandleFunc("/apply/lock", s.LocksController.LockApply).Methods("POST").Queries() @@ -725,10 +728,10 @@ func (s *Server) Index(w http.ResponseWriter, _ *http.Request) { return } - var lockResults []LockIndexData + var lockResults []templates.LockIndexData for id, v := range locks { lockURL, _ := s.Router.Get(LockViewRouteName).URL("id", url.QueryEscape(id)) - lockResults = append(lockResults, LockIndexData{ + lockResults = append(lockResults, templates.LockIndexData{ // NOTE: must use .String() instead of .Path because we need the // query params as part of the lock URL. LockPath: lockURL.String(), @@ -749,7 +752,7 @@ func (s *Server) Index(w http.ResponseWriter, _ *http.Request) { return } - applyLockData := ApplyLockData{ + applyLockData := templates.ApplyLockData{ Time: applyCmdLock.Time, Locked: applyCmdLock.Locked, TimeFormatted: applyCmdLock.Time.Format("02-01-2006 15:04:05"), @@ -757,7 +760,7 @@ func (s *Server) Index(w http.ResponseWriter, _ *http.Request) { //Sort by date - newest to oldest. sort.SliceStable(lockResults, func(i, j int) bool { return lockResults[i].Time.After(lockResults[j].Time) }) - err = s.IndexTemplate.Execute(w, IndexData{ + err = s.IndexTemplate.Execute(w, templates.IndexData{ Locks: lockResults, ApplyLock: applyLockData, AtlantisVersion: s.AtlantisVersion, diff --git a/server/server_test.go b/server/server_test.go index 4b22cdf6a..5ee623cf7 100644 --- a/server/server_test.go +++ b/server/server_test.go @@ -20,17 +20,17 @@ import ( "net/http" "net/http/httptest" "net/url" - "strings" "testing" "time" "github.com/gorilla/mux" . "github.com/petergtz/pegomock" "github.com/runatlantis/atlantis/server" + "github.com/runatlantis/atlantis/server/controllers/templates" + tMocks "github.com/runatlantis/atlantis/server/controllers/templates/mocks" "github.com/runatlantis/atlantis/server/events/locking/mocks" "github.com/runatlantis/atlantis/server/events/models" "github.com/runatlantis/atlantis/server/logging" - sMocks "github.com/runatlantis/atlantis/server/mocks" . "github.com/runatlantis/atlantis/testing" ) @@ -70,7 +70,7 @@ func TestIndex_LockErr(t *testing.T) { req, _ := http.NewRequest("GET", "", bytes.NewBuffer(nil)) w := httptest.NewRecorder() s.Index(w, req) - responseContains(t, w, 503, "Could not retrieve locks: err") + ResponseContains(t, w, 503, "Could not retrieve locks: err") } func TestIndex_Success(t *testing.T) { @@ -92,7 +92,7 @@ func TestIndex_Success(t *testing.T) { }, } When(l.List()).ThenReturn(locks, nil) - it := sMocks.NewMockTemplateWriter() + it := tMocks.NewMockTemplateWriter() r := mux.NewRouter() atlantisVersion := "0.3.1" // Need to create a lock route since the server expects this route to exist. @@ -112,13 +112,13 @@ func TestIndex_Success(t *testing.T) { req, _ := http.NewRequest("GET", "", bytes.NewBuffer(nil)) w := httptest.NewRecorder() s.Index(w, req) - it.VerifyWasCalledOnce().Execute(w, server.IndexData{ - ApplyLock: server.ApplyLockData{ + it.VerifyWasCalledOnce().Execute(w, templates.IndexData{ + ApplyLock: templates.ApplyLockData{ Locked: false, Time: time.Time{}, TimeFormatted: "01-01-0001 00:00:00", }, - Locks: []server.LockIndexData{ + Locks: []templates.LockIndexData{ { LockPath: "/lock?id=lkysow%252Fatlantis-example%252F.%252Fdefault", RepoFullName: "lkysow/atlantis-example", @@ -129,7 +129,7 @@ func TestIndex_Success(t *testing.T) { }, AtlantisVersion: atlantisVersion, }) - responseContains(t, w, http.StatusOK, "") + ResponseContains(t, w, http.StatusOK, "") } func TestHealthz(t *testing.T) { @@ -225,11 +225,3 @@ func TestParseAtlantisURL(t *testing.T) { }) } } - -func responseContains(t *testing.T, r *httptest.ResponseRecorder, status int, bodySubstr string) { - t.Helper() - body, err := ioutil.ReadAll(r.Result().Body) - Ok(t, err) - Assert(t, status == r.Result().StatusCode, "exp %d got %d, body: %s", status, r.Result().StatusCode, string(body)) - Assert(t, strings.Contains(string(body), bodySubstr), "exp %q to be contained in %q", bodySubstr, string(body)) -} diff --git a/testing/http.go b/testing/http.go new file mode 100644 index 000000000..ba19b5408 --- /dev/null +++ b/testing/http.go @@ -0,0 +1,16 @@ +package testing + +import ( + "io/ioutil" + "net/http/httptest" + "strings" + "testing" +) + +func ResponseContains(t *testing.T, r *httptest.ResponseRecorder, status int, bodySubstr string) { + t.Helper() + body, err := ioutil.ReadAll(r.Result().Body) + Ok(t, err) + Assert(t, status == r.Result().StatusCode, "exp %d got %d, body: %s", status, r.Result().StatusCode, string(body)) + Assert(t, strings.Contains(string(body), bodySubstr), "exp %q to be contained in %q", bodySubstr, string(body)) +}