Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support multi node setup #2

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
18 changes: 9 additions & 9 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ env:
- CGO_ENABLED=0
builds:
- targets:
- darwin_amd64
- darwin_arm64
- linux_386
- linux_amd64
- linux_arm
- linux_arm64
- windows_386
- windows_amd64
# - darwin_amd64
# - darwin_arm64
# - linux_386
- linux_amd64
- linux_arm
- linux_arm64
# - windows_386
# - windows_amd64

archives:
- id: zip
Expand All @@ -26,7 +26,7 @@ changelog:

release:
github:
owner: runatlantis
owner: gojekfarm
name: atlantis

# If set to true, will not auto-publish the release.
Expand Down
2 changes: 1 addition & 1 deletion cmd/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"fmt"
"os"

"github.com/runatlantis/atlantis/testdrive"
"github.com/gojekfarm/atlantis/testdrive"
"github.com/spf13/cobra"
)

Expand Down
13 changes: 9 additions & 4 deletions cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ import (
"path/filepath"
"strings"

"github.com/gojekfarm/atlantis/server"
"github.com/gojekfarm/atlantis/server/core/config/valid"
"github.com/gojekfarm/atlantis/server/events/vcs/bitbucketcloud"
"github.com/gojekfarm/atlantis/server/logging"
homedir "github.com/mitchellh/go-homedir"
"github.com/moby/moby/pkg/fileutils"
"github.com/pkg/errors"
"github.com/runatlantis/atlantis/server"
"github.com/runatlantis/atlantis/server/core/config/valid"
"github.com/runatlantis/atlantis/server/events/vcs/bitbucketcloud"
"github.com/runatlantis/atlantis/server/logging"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
Expand Down Expand Up @@ -63,6 +63,7 @@ const (
EnablePolicyChecksFlag = "enable-policy-checks"
EnableRegExpCmdFlag = "enable-regexp-cmd"
EnableDiffMarkdownFormat = "enable-diff-markdown-format"
EnableServerProfiling = "enable-server-profiling"
GHHostnameFlag = "gh-hostname"
GHTeamAllowlistFlag = "gh-team-allowlist"
GHTokenFlag = "gh-token"
Expand Down Expand Up @@ -397,6 +398,10 @@ var boolFlags = map[string]boolFlag{
description: "Enable Atlantis to format Terraform plan output into a markdown-diff friendly format for color-coding purposes.",
defaultValue: false,
},
EnableServerProfiling: {
description: "Enables profiler",
defaultValue: false,
},
GHAllowMergeableBypassApply: {
description: "Feature flag to enable functionality to allow mergeable check to ignore apply required check",
defaultValue: false,
Expand Down
8 changes: 4 additions & 4 deletions cmd/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ import (
"testing"

homedir "github.com/mitchellh/go-homedir"
"github.com/runatlantis/atlantis/server"
"github.com/runatlantis/atlantis/server/events/vcs/fixtures"
"github.com/runatlantis/atlantis/server/logging"
. "github.com/runatlantis/atlantis/testing"
"github.com/gojekfarm/atlantis/server"
"github.com/gojekfarm/atlantis/server/events/vcs/fixtures"
"github.com/gojekfarm/atlantis/server/logging"
. "github.com/gojekfarm/atlantis/testing"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"gopkg.in/yaml.v2"
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/runatlantis/atlantis
module github.com/gojekfarm/atlantis

go 1.17

Expand Down
6 changes: 3 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ package main
import (
"fmt"

"github.com/runatlantis/atlantis/cmd"
"github.com/runatlantis/atlantis/server/logging"
"github.com/gojekfarm/atlantis/cmd"
"github.com/gojekfarm/atlantis/server/logging"
"github.com/spf13/viper"
)

const atlantisVersion = "0.19.9"
const atlantisVersion = "0.19.13"

func main() {
v := viper.New()
Expand Down
12 changes: 6 additions & 6 deletions server/controllers/api_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import (
"net/http"
"strings"

"github.com/runatlantis/atlantis/server/core/locking"
"github.com/runatlantis/atlantis/server/events"
"github.com/runatlantis/atlantis/server/events/command"
"github.com/runatlantis/atlantis/server/events/models"
"github.com/runatlantis/atlantis/server/events/vcs"
"github.com/runatlantis/atlantis/server/logging"
"github.com/gojekfarm/atlantis/server/core/locking"
"github.com/gojekfarm/atlantis/server/events"
"github.com/gojekfarm/atlantis/server/events/command"
"github.com/gojekfarm/atlantis/server/events/models"
"github.com/gojekfarm/atlantis/server/events/vcs"
"github.com/gojekfarm/atlantis/server/logging"
"github.com/uber-go/tally"
"gopkg.in/go-playground/validator.v9"
)
Expand Down
22 changes: 11 additions & 11 deletions server/controllers/api_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@ package controllers_test
import (
"bytes"
"encoding/json"
"github.com/runatlantis/atlantis/server/events/command"
"github.com/runatlantis/atlantis/server/events/models"
"github.com/gojekfarm/atlantis/server/events/command"
"github.com/gojekfarm/atlantis/server/events/models"
"net/http"
"net/http/httptest"
"testing"

. "github.com/petergtz/pegomock"
"github.com/runatlantis/atlantis/server/controllers"
. "github.com/runatlantis/atlantis/server/core/locking/mocks"
"github.com/runatlantis/atlantis/server/events"
. "github.com/runatlantis/atlantis/server/events/mocks"
. "github.com/runatlantis/atlantis/server/events/mocks/matchers"
. "github.com/runatlantis/atlantis/server/events/vcs/mocks"
"github.com/runatlantis/atlantis/server/logging"
"github.com/runatlantis/atlantis/server/metrics"
. "github.com/runatlantis/atlantis/testing"
"github.com/gojekfarm/atlantis/server/controllers"
. "github.com/gojekfarm/atlantis/server/core/locking/mocks"
"github.com/gojekfarm/atlantis/server/events"
. "github.com/gojekfarm/atlantis/server/events/mocks"
. "github.com/gojekfarm/atlantis/server/events/mocks/matchers"
. "github.com/gojekfarm/atlantis/server/events/vcs/mocks"
"github.com/gojekfarm/atlantis/server/logging"
"github.com/gojekfarm/atlantis/server/metrics"
. "github.com/gojekfarm/atlantis/testing"
)

const atlantisTokenHeader = "X-Atlantis-Token"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"testing"

. "github.com/petergtz/pegomock"
"github.com/runatlantis/atlantis/server/controllers/events"
. "github.com/runatlantis/atlantis/testing"
"github.com/gojekfarm/atlantis/server/controllers/events"
. "github.com/gojekfarm/atlantis/testing"
)

func TestAzureDevopsValidate_WithBasicAuthErr(t *testing.T) {
Expand Down
29 changes: 23 additions & 6 deletions server/controllers/events/events_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ import (
"net/http"
"strings"

"github.com/gojekfarm/atlantis/server/events"
"github.com/gojekfarm/atlantis/server/events/models"
"github.com/gojekfarm/atlantis/server/events/vcs"
"github.com/gojekfarm/atlantis/server/events/vcs/bitbucketcloud"
"github.com/gojekfarm/atlantis/server/events/vcs/bitbucketserver"
"github.com/gojekfarm/atlantis/server/logging"
"github.com/google/go-github/v31/github"
"github.com/mcdafydd/go-azuredevops/azuredevops"
"github.com/microcosm-cc/bluemonday"
"github.com/pkg/errors"
"github.com/runatlantis/atlantis/server/events"
"github.com/runatlantis/atlantis/server/events/models"
"github.com/runatlantis/atlantis/server/events/vcs"
"github.com/runatlantis/atlantis/server/events/vcs/bitbucketcloud"
"github.com/runatlantis/atlantis/server/events/vcs/bitbucketserver"
"github.com/runatlantis/atlantis/server/logging"
"github.com/uber-go/tally"
gitlab "github.com/xanzy/go-gitlab"
)
Expand Down Expand Up @@ -104,6 +104,10 @@ func (e *VCSEventsController) Post(w http.ResponseWriter, r *http.Request) {
return
}
e.Logger.Debug("handling GitLab post")
scope := e.Scope.SubScope("gitlab_post")
timer := scope.Timer("execution_time").Start()
defer timer.Stop()

e.handleGitlabPost(w, r)
return
} else if r.Header.Get(bitbucketEventTypeHeader) != "" {
Expand Down Expand Up @@ -472,7 +476,10 @@ func (e *VCSEventsController) handlePullRequestEvent(logger logging.SimpleLoggin
}

func (e *VCSEventsController) handleGitlabPost(w http.ResponseWriter, r *http.Request) {

timer := e.Scope.SubScope("gitlab_parser_validator").Timer("execution_time").Start()
event, err := e.GitlabRequestParserValidator.ParseAndValidate(r, e.GitlabWebhookSecret)
timer.Stop()
if err != nil {
e.respond(w, logging.Warn, http.StatusBadRequest, err.Error())
return
Expand All @@ -482,11 +489,21 @@ func (e *VCSEventsController) handleGitlabPost(w http.ResponseWriter, r *http.Re
switch event := event.(type) {
case gitlab.MergeCommentEvent:
e.Logger.Debug("handling as comment event")

scope := e.Scope.SubScope("merge_comment_event")
timer := scope.Timer("execution_time").Start()
defer timer.Stop()
e.HandleGitlabCommentEvent(w, event)
case gitlab.MergeEvent:
scope := e.Scope.SubScope("merge_event")
timer := scope.Timer("execution_time").Start()
defer timer.Stop()
e.Logger.Debug("handling as pull request event")
e.HandleGitlabMergeRequestEvent(w, event)
case gitlab.CommitCommentEvent:
scope := e.Scope.SubScope("commit_comment_event")
timer := scope.Timer("execution_time").Start()
defer timer.Stop()
e.Logger.Debug("comments on commits are not supported, only comments on merge requests")
e.respond(w, logging.Debug, http.StatusOK, "Ignoring comment on commit event")
default:
Expand Down
46 changes: 23 additions & 23 deletions server/controllers/events/events_controller_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,29 @@ import (
"github.com/hashicorp/go-getter"
"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/core/config"
"github.com/runatlantis/atlantis/server/core/config/valid"
"github.com/runatlantis/atlantis/server/core/db"
"github.com/runatlantis/atlantis/server/core/locking"
"github.com/runatlantis/atlantis/server/core/runtime"
runtimemocks "github.com/runatlantis/atlantis/server/core/runtime/mocks"
runtimematchers "github.com/runatlantis/atlantis/server/core/runtime/mocks/matchers"
"github.com/runatlantis/atlantis/server/core/runtime/policy"
"github.com/runatlantis/atlantis/server/core/terraform"
"github.com/runatlantis/atlantis/server/events"
"github.com/runatlantis/atlantis/server/events/command"
"github.com/runatlantis/atlantis/server/events/mocks"
"github.com/runatlantis/atlantis/server/events/mocks/matchers"
"github.com/runatlantis/atlantis/server/events/models"
"github.com/runatlantis/atlantis/server/events/vcs"
vcsmocks "github.com/runatlantis/atlantis/server/events/vcs/mocks"
"github.com/runatlantis/atlantis/server/events/webhooks"
jobmocks "github.com/runatlantis/atlantis/server/jobs/mocks"
"github.com/runatlantis/atlantis/server/logging"
"github.com/runatlantis/atlantis/server/metrics"
. "github.com/runatlantis/atlantis/testing"
"github.com/gojekfarm/atlantis/server"
events_controllers "github.com/gojekfarm/atlantis/server/controllers/events"
"github.com/gojekfarm/atlantis/server/core/config"
"github.com/gojekfarm/atlantis/server/core/config/valid"
"github.com/gojekfarm/atlantis/server/core/db"
"github.com/gojekfarm/atlantis/server/core/locking"
"github.com/gojekfarm/atlantis/server/core/runtime"
runtimemocks "github.com/gojekfarm/atlantis/server/core/runtime/mocks"
runtimematchers "github.com/gojekfarm/atlantis/server/core/runtime/mocks/matchers"
"github.com/gojekfarm/atlantis/server/core/runtime/policy"
"github.com/gojekfarm/atlantis/server/core/terraform"
"github.com/gojekfarm/atlantis/server/events"
"github.com/gojekfarm/atlantis/server/events/command"
"github.com/gojekfarm/atlantis/server/events/mocks"
"github.com/gojekfarm/atlantis/server/events/mocks/matchers"
"github.com/gojekfarm/atlantis/server/events/models"
"github.com/gojekfarm/atlantis/server/events/vcs"
vcsmocks "github.com/gojekfarm/atlantis/server/events/vcs/mocks"
"github.com/gojekfarm/atlantis/server/events/webhooks"
jobmocks "github.com/gojekfarm/atlantis/server/jobs/mocks"
"github.com/gojekfarm/atlantis/server/logging"
"github.com/gojekfarm/atlantis/server/metrics"
. "github.com/gojekfarm/atlantis/testing"
)

const ConftestVersion = "0.25.0"
Expand Down
20 changes: 10 additions & 10 deletions server/controllers/events/events_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ import (
"errors"
"fmt"
. "github.com/petergtz/pegomock"
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/metrics"
. "github.com/runatlantis/atlantis/testing"
events_controllers "github.com/gojekfarm/atlantis/server/controllers/events"
"github.com/gojekfarm/atlantis/server/controllers/events/mocks"
"github.com/gojekfarm/atlantis/server/events"
emocks "github.com/gojekfarm/atlantis/server/events/mocks"
"github.com/gojekfarm/atlantis/server/events/mocks/matchers"
"github.com/gojekfarm/atlantis/server/events/models"
vcsmocks "github.com/gojekfarm/atlantis/server/events/vcs/mocks"
"github.com/gojekfarm/atlantis/server/logging"
"github.com/gojekfarm/atlantis/server/metrics"
. "github.com/gojekfarm/atlantis/testing"
gitlab "github.com/xanzy/go-gitlab"
"io"
"net/http"
Expand Down
4 changes: 2 additions & 2 deletions server/controllers/events/github_request_validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import (
"testing"

. "github.com/petergtz/pegomock"
"github.com/runatlantis/atlantis/server/controllers/events"
. "github.com/runatlantis/atlantis/testing"
"github.com/gojekfarm/atlantis/server/controllers/events"
. "github.com/gojekfarm/atlantis/testing"
)

func TestValidate_WithSecretErr(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import (
"testing"

. "github.com/petergtz/pegomock"
"github.com/runatlantis/atlantis/server/controllers/events"
. "github.com/runatlantis/atlantis/testing"
"github.com/gojekfarm/atlantis/server/controllers/events"
. "github.com/gojekfarm/atlantis/testing"
gitlab "github.com/xanzy/go-gitlab"
)

Expand Down
6 changes: 3 additions & 3 deletions server/controllers/github_app_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ 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"
"github.com/gojekfarm/atlantis/server/controllers/templates"
"github.com/gojekfarm/atlantis/server/events/vcs"
"github.com/gojekfarm/atlantis/server/logging"
)

// GithubAppController handles the creation and setup of a new GitHub app
Expand Down
10 changes: 5 additions & 5 deletions server/controllers/jobs_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import (
"net/url"

"github.com/gorilla/mux"
"github.com/runatlantis/atlantis/server/controllers/templates"
"github.com/runatlantis/atlantis/server/controllers/websocket"
"github.com/runatlantis/atlantis/server/core/locking"
"github.com/runatlantis/atlantis/server/logging"
"github.com/runatlantis/atlantis/server/metrics"
"github.com/gojekfarm/atlantis/server/controllers/templates"
"github.com/gojekfarm/atlantis/server/controllers/websocket"
"github.com/gojekfarm/atlantis/server/core/locking"
"github.com/gojekfarm/atlantis/server/logging"
"github.com/gojekfarm/atlantis/server/metrics"
"github.com/uber-go/tally"
)

Expand Down
12 changes: 6 additions & 6 deletions server/controllers/locks_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import (
"net/http"
"net/url"

"github.com/runatlantis/atlantis/server/controllers/templates"
"github.com/gojekfarm/atlantis/server/controllers/templates"

"github.com/gorilla/mux"
"github.com/runatlantis/atlantis/server/core/locking"
"github.com/runatlantis/atlantis/server/events"
"github.com/runatlantis/atlantis/server/events/models"
"github.com/runatlantis/atlantis/server/events/vcs"
"github.com/runatlantis/atlantis/server/logging"
"github.com/gojekfarm/atlantis/server/core/locking"
"github.com/gojekfarm/atlantis/server/events"
"github.com/gojekfarm/atlantis/server/events/models"
"github.com/gojekfarm/atlantis/server/events/vcs"
"github.com/gojekfarm/atlantis/server/logging"
)

// LocksController handles all requests relating to Atlantis locks.
Expand Down
Loading