diff --git a/Makefile b/Makefile index d2dc4c6d9..0e0fa9bf0 100644 --- a/Makefile +++ b/Makefile @@ -25,6 +25,9 @@ deps: ## Download dependencies build-service: ## Build the main Go service CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -o atlantis . +go-generate: ## Run go generate in all packages + go generate $(PKG) + test: ## Run tests, coverage reports, and clean (coverage taints the compiled code) go test $(PKG) @@ -36,7 +39,7 @@ test-coverage-html: go tool cover -html .cover/cover.out dist: ## Package up everything in static/ using go-bindata-assetfs so it can be served by a single binary - go-bindata-assetfs -pkg static static/... && mv bindata_assetfs.go static + rm -f server/static/bindata_assetfs.go && go-bindata-assetfs -pkg static -prefix server server/static/... && mv bindata_assetfs.go server/static release: ## Create packages for a release ./scripts/binary-release.sh diff --git a/server/apply_executor.go b/server/apply_executor.go index 400cddb44..c0b2eb118 100644 --- a/server/apply_executor.go +++ b/server/apply_executor.go @@ -9,11 +9,11 @@ import ( "path/filepath" version "github.com/hashicorp/go-version" - "github.com/hootsuite/atlantis/github" - "github.com/hootsuite/atlantis/locking" - "github.com/hootsuite/atlantis/models" - "github.com/hootsuite/atlantis/run" - "github.com/hootsuite/atlantis/terraform" + "github.com/hootsuite/atlantis/server/github" + "github.com/hootsuite/atlantis/server/locking" + "github.com/hootsuite/atlantis/server/models" + "github.com/hootsuite/atlantis/server/run" + "github.com/hootsuite/atlantis/server/terraform" ) type ApplyExecutor struct { diff --git a/server/command_handler.go b/server/command_handler.go index dec0d6553..f830a770d 100644 --- a/server/command_handler.go +++ b/server/command_handler.go @@ -3,9 +3,9 @@ package server import ( "fmt" - "github.com/hootsuite/atlantis/github" - "github.com/hootsuite/atlantis/logging" - "github.com/hootsuite/atlantis/recovery" + "github.com/hootsuite/atlantis/server/github" + "github.com/hootsuite/atlantis/server/logging" + "github.com/hootsuite/atlantis/server/recovery" ) // CommandHandler is the first step when processing a comment command. diff --git a/server/command_handler_test.go b/server/command_handler_test.go index e76ee6f51..e6531ff16 100644 --- a/server/command_handler_test.go +++ b/server/command_handler_test.go @@ -9,10 +9,10 @@ import ( "strings" "github.com/google/go-github/github" - gh "github.com/hootsuite/atlantis/github/fixtures" - ghmocks "github.com/hootsuite/atlantis/github/mocks" - "github.com/hootsuite/atlantis/logging" - "github.com/hootsuite/atlantis/models/fixtures" + gh "github.com/hootsuite/atlantis/server/github/fixtures" + ghmocks "github.com/hootsuite/atlantis/server/github/mocks" + "github.com/hootsuite/atlantis/server/logging" + "github.com/hootsuite/atlantis/server/models/fixtures" "github.com/hootsuite/atlantis/server" "github.com/hootsuite/atlantis/server/mocks" . "github.com/hootsuite/atlantis/testing_util" diff --git a/server/event_parser.go b/server/event_parser.go index ac8f21359..ab0541199 100644 --- a/server/event_parser.go +++ b/server/event_parser.go @@ -6,10 +6,11 @@ import ( "strings" "github.com/google/go-github/github" - "github.com/hootsuite/atlantis/models" + "github.com/hootsuite/atlantis/server/models" ) //go:generate pegomock generate --use-experimental-model-gen --package mocks -o mocks/mock_event_parsing.go EventParsing +//go:generate sed -i "" -e "s#github.com/hootsuite/atlantis/vendor/github.com/google/go-github/github#github.com/google/go-github/github#" mocks/mock_event_parsing.go type Command struct { Name CommandName diff --git a/server/event_parser_test.go b/server/event_parser_test.go index c49726096..5cbf7682c 100644 --- a/server/event_parser_test.go +++ b/server/event_parser_test.go @@ -7,8 +7,8 @@ import ( "strings" "github.com/google/go-github/github" - . "github.com/hootsuite/atlantis/github/fixtures" - "github.com/hootsuite/atlantis/models" + . "github.com/hootsuite/atlantis/server/github/fixtures" + "github.com/hootsuite/atlantis/server/models" "github.com/hootsuite/atlantis/server" . "github.com/hootsuite/atlantis/testing_util" "github.com/mohae/deepcopy" diff --git a/github/client.go b/server/github/client.go similarity index 98% rename from github/client.go rename to server/github/client.go index f07d7eef7..1f2083c47 100644 --- a/github/client.go +++ b/server/github/client.go @@ -9,7 +9,7 @@ import ( "strings" "github.com/google/go-github/github" - "github.com/hootsuite/atlantis/models" + "github.com/hootsuite/atlantis/server/models" "github.com/pkg/errors" ) diff --git a/github/fixtures/fixtures.go b/server/github/fixtures/fixtures.go similarity index 100% rename from github/fixtures/fixtures.go rename to server/github/fixtures/fixtures.go diff --git a/github/mocks/mock_client.go b/server/github/mocks/mock_client.go similarity index 99% rename from github/mocks/mock_client.go rename to server/github/mocks/mock_client.go index e562a4cf6..31efa3bad 100644 --- a/github/mocks/mock_client.go +++ b/server/github/mocks/mock_client.go @@ -5,7 +5,7 @@ package mocks import ( github "github.com/google/go-github/github" - models "github.com/hootsuite/atlantis/models" + models "github.com/hootsuite/atlantis/server/models" pegomock "github.com/petergtz/pegomock" "reflect" ) diff --git a/server/github_status.go b/server/github_status.go index b193c8b79..40e3cefb0 100644 --- a/server/github_status.go +++ b/server/github_status.go @@ -5,8 +5,8 @@ import ( "strings" - "github.com/hootsuite/atlantis/github" - "github.com/hootsuite/atlantis/models" + "github.com/hootsuite/atlantis/server/github" + "github.com/hootsuite/atlantis/server/models" ) type Status int diff --git a/server/github_status_test.go b/server/github_status_test.go index e13eb3b1c..5b8438b67 100644 --- a/server/github_status_test.go +++ b/server/github_status_test.go @@ -6,8 +6,8 @@ import ( "errors" "strings" - "github.com/hootsuite/atlantis/github/mocks" - "github.com/hootsuite/atlantis/models" + "github.com/hootsuite/atlantis/server/github/mocks" + "github.com/hootsuite/atlantis/server/models" "github.com/hootsuite/atlantis/server" . "github.com/hootsuite/atlantis/testing_util" . "github.com/petergtz/pegomock" diff --git a/locking/boltdb/boltdb.go b/server/locking/boltdb/boltdb.go similarity index 99% rename from locking/boltdb/boltdb.go rename to server/locking/boltdb/boltdb.go index 4ffd485d8..4389d4438 100644 --- a/locking/boltdb/boltdb.go +++ b/server/locking/boltdb/boltdb.go @@ -12,7 +12,7 @@ import ( "time" "github.com/boltdb/bolt" - "github.com/hootsuite/atlantis/models" + "github.com/hootsuite/atlantis/server/models" "github.com/pkg/errors" ) diff --git a/locking/boltdb/boltdb_test.go b/server/locking/boltdb/boltdb_test.go similarity index 98% rename from locking/boltdb/boltdb_test.go rename to server/locking/boltdb/boltdb_test.go index 3a4bfa23f..cf86249b3 100644 --- a/locking/boltdb/boltdb_test.go +++ b/server/locking/boltdb/boltdb_test.go @@ -12,8 +12,8 @@ import ( "time" - "github.com/hootsuite/atlantis/locking/boltdb" - "github.com/hootsuite/atlantis/models" + "github.com/hootsuite/atlantis/server/models" + "github.com/hootsuite/atlantis/server/locking/boltdb" ) var lockBucket = "bucket" diff --git a/locking/locking.go b/server/locking/locking.go similarity index 98% rename from locking/locking.go rename to server/locking/locking.go index 60c30d47b..e4815343e 100644 --- a/locking/locking.go +++ b/server/locking/locking.go @@ -7,7 +7,7 @@ import ( "regexp" "time" - "github.com/hootsuite/atlantis/models" + "github.com/hootsuite/atlantis/server/models" ) //go:generate pegomock generate --use-experimental-model-gen --package mocks -o mocks/mock_backend.go Backend diff --git a/locking/locking_test.go b/server/locking/locking_test.go similarity index 96% rename from locking/locking_test.go rename to server/locking/locking_test.go index 96f990692..84e4812d8 100644 --- a/locking/locking_test.go +++ b/server/locking/locking_test.go @@ -8,11 +8,11 @@ import ( "reflect" "strings" - "github.com/hootsuite/atlantis/locking" - "github.com/hootsuite/atlantis/locking/mocks" - "github.com/hootsuite/atlantis/models" + "github.com/hootsuite/atlantis/server/locking/mocks" + "github.com/hootsuite/atlantis/server/models" . "github.com/hootsuite/atlantis/testing_util" . "github.com/petergtz/pegomock" + "github.com/hootsuite/atlantis/server/locking" ) var project = models.NewProject("owner/repo", "path") diff --git a/locking/mocks/mock_backend.go b/server/locking/mocks/mock_backend.go similarity index 98% rename from locking/mocks/mock_backend.go rename to server/locking/mocks/mock_backend.go index 519236aa3..7becd2935 100644 --- a/locking/mocks/mock_backend.go +++ b/server/locking/mocks/mock_backend.go @@ -1,10 +1,10 @@ // Automatically generated by pegomock. DO NOT EDIT! -// Source: github.com/hootsuite/atlantis/locking (interfaces: Backend) +// Source: github.com/hootsuite/atlantis/server/locking (interfaces: Backend) package mocks import ( - models "github.com/hootsuite/atlantis/models" + models "github.com/hootsuite/atlantis/server/models" pegomock "github.com/petergtz/pegomock" "reflect" ) diff --git a/locking/mocks/mock_locker.go b/server/locking/mocks/mock_locker.go similarity index 97% rename from locking/mocks/mock_locker.go rename to server/locking/mocks/mock_locker.go index a107b1cb6..91e97305a 100644 --- a/locking/mocks/mock_locker.go +++ b/server/locking/mocks/mock_locker.go @@ -1,11 +1,11 @@ // Automatically generated by pegomock. DO NOT EDIT! -// Source: github.com/hootsuite/atlantis/locking (interfaces: Locker) +// Source: github.com/hootsuite/atlantis/server/locking (interfaces: Locker) package mocks import ( - locking "github.com/hootsuite/atlantis/locking" - models "github.com/hootsuite/atlantis/models" + locking "github.com/hootsuite/atlantis/server/locking" + models "github.com/hootsuite/atlantis/server/models" pegomock "github.com/petergtz/pegomock" "reflect" ) diff --git a/logging/simple_logger.go b/server/logging/simple_logger.go similarity index 100% rename from logging/simple_logger.go rename to server/logging/simple_logger.go diff --git a/server/middleware.go b/server/middleware.go index 0a3ebc874..4cc6ef7c4 100644 --- a/server/middleware.go +++ b/server/middleware.go @@ -5,7 +5,7 @@ import ( "strings" - "github.com/hootsuite/atlantis/logging" + "github.com/hootsuite/atlantis/server/logging" "github.com/urfave/negroni" ) diff --git a/server/mocks/mock_event_parsing.go b/server/mocks/mock_event_parsing.go index 01b9e3ecf..fb897f685 100644 --- a/server/mocks/mock_event_parsing.go +++ b/server/mocks/mock_event_parsing.go @@ -4,8 +4,8 @@ package mocks import ( - models "github.com/hootsuite/atlantis/models" server "github.com/hootsuite/atlantis/server" + models "github.com/hootsuite/atlantis/server/models" github "github.com/google/go-github/github" pegomock "github.com/petergtz/pegomock" "reflect" diff --git a/server/mocks/mock_github_status.go b/server/mocks/mock_github_status.go index f05f0b248..60a5488e2 100644 --- a/server/mocks/mock_github_status.go +++ b/server/mocks/mock_github_status.go @@ -4,8 +4,8 @@ package mocks import ( - models "github.com/hootsuite/atlantis/models" server "github.com/hootsuite/atlantis/server" + models "github.com/hootsuite/atlantis/server/models" pegomock "github.com/petergtz/pegomock" "reflect" ) diff --git a/server/mocks/mock_workspace.go b/server/mocks/mock_workspace.go index 550efbc16..f5011a02d 100644 --- a/server/mocks/mock_workspace.go +++ b/server/mocks/mock_workspace.go @@ -4,8 +4,8 @@ package mocks import ( - models "github.com/hootsuite/atlantis/models" server "github.com/hootsuite/atlantis/server" + models "github.com/hootsuite/atlantis/server/models" pegomock "github.com/petergtz/pegomock" "reflect" ) diff --git a/models/fixtures/fixtures.go b/server/models/fixtures/fixtures.go similarity index 91% rename from models/fixtures/fixtures.go rename to server/models/fixtures/fixtures.go index 7ae7f4059..8f120ac9b 100644 --- a/models/fixtures/fixtures.go +++ b/server/models/fixtures/fixtures.go @@ -1,6 +1,6 @@ package fixtures -import "github.com/hootsuite/atlantis/models" +import "github.com/hootsuite/atlantis/server/models" var Pull = models.PullRequest{ Num: 1, diff --git a/models/models.go b/server/models/models.go similarity index 100% rename from models/models.go rename to server/models/models.go diff --git a/server/plan_executor.go b/server/plan_executor.go index ef81a1f8f..eb4cd653c 100644 --- a/server/plan_executor.go +++ b/server/plan_executor.go @@ -8,11 +8,11 @@ import ( "strings" version "github.com/hashicorp/go-version" - "github.com/hootsuite/atlantis/github" - "github.com/hootsuite/atlantis/locking" - "github.com/hootsuite/atlantis/models" - "github.com/hootsuite/atlantis/run" - "github.com/hootsuite/atlantis/terraform" + "github.com/hootsuite/atlantis/server/github" + "github.com/hootsuite/atlantis/server/locking" + "github.com/hootsuite/atlantis/server/models" + "github.com/hootsuite/atlantis/server/run" + "github.com/hootsuite/atlantis/server/terraform" "github.com/pkg/errors" ) diff --git a/server/pull_closed_executor.go b/server/pull_closed_executor.go index 8bed92d4c..e332d82b0 100644 --- a/server/pull_closed_executor.go +++ b/server/pull_closed_executor.go @@ -6,9 +6,9 @@ import ( "strings" "text/template" - "github.com/hootsuite/atlantis/github" - "github.com/hootsuite/atlantis/locking" - "github.com/hootsuite/atlantis/models" + "github.com/hootsuite/atlantis/server/github" + "github.com/hootsuite/atlantis/server/locking" + "github.com/hootsuite/atlantis/server/models" "github.com/pkg/errors" ) diff --git a/server/pull_closed_executor_test.go b/server/pull_closed_executor_test.go index adc791f79..1ec021357 100644 --- a/server/pull_closed_executor_test.go +++ b/server/pull_closed_executor_test.go @@ -5,10 +5,10 @@ import ( "reflect" "testing" - ghmocks "github.com/hootsuite/atlantis/github/mocks" - lockmocks "github.com/hootsuite/atlantis/locking/mocks" - "github.com/hootsuite/atlantis/models" - "github.com/hootsuite/atlantis/models/fixtures" + ghmocks "github.com/hootsuite/atlantis/server/github/mocks" + lockmocks "github.com/hootsuite/atlantis/server/locking/mocks" + "github.com/hootsuite/atlantis/server/models" + "github.com/hootsuite/atlantis/server/models/fixtures" "github.com/hootsuite/atlantis/server" "github.com/hootsuite/atlantis/server/mocks" . "github.com/hootsuite/atlantis/testing_util" diff --git a/recovery/recovery.go b/server/recovery/recovery.go similarity index 100% rename from recovery/recovery.go rename to server/recovery/recovery.go diff --git a/run/run.go b/server/run/run.go similarity index 97% rename from run/run.go rename to server/run/run.go index fbd3da2b0..76b02cade 100644 --- a/run/run.go +++ b/server/run/run.go @@ -11,7 +11,7 @@ import ( "strings" version "github.com/hashicorp/go-version" - "github.com/hootsuite/atlantis/logging" + "github.com/hootsuite/atlantis/server/logging" "github.com/pkg/errors" ) diff --git a/run/run_test.go b/server/run/run_test.go similarity index 96% rename from run/run_test.go rename to server/run/run_test.go index 443167ad4..171ce52f6 100644 --- a/run/run_test.go +++ b/server/run/run_test.go @@ -4,7 +4,7 @@ import ( "testing" version "github.com/hashicorp/go-version" - "github.com/hootsuite/atlantis/logging" + "github.com/hootsuite/atlantis/server/logging" . "github.com/hootsuite/atlantis/testing_util" ) diff --git a/server/server.go b/server/server.go index 403a931e0..85ed5cc01 100644 --- a/server/server.go +++ b/server/server.go @@ -14,14 +14,14 @@ import ( "github.com/elazarl/go-bindata-assetfs" gh "github.com/google/go-github/github" "github.com/gorilla/mux" - "github.com/hootsuite/atlantis/github" - "github.com/hootsuite/atlantis/locking" - "github.com/hootsuite/atlantis/locking/boltdb" - "github.com/hootsuite/atlantis/logging" - "github.com/hootsuite/atlantis/models" - "github.com/hootsuite/atlantis/run" - "github.com/hootsuite/atlantis/static" - "github.com/hootsuite/atlantis/terraform" + "github.com/hootsuite/atlantis/server/github" + "github.com/hootsuite/atlantis/server/locking" + "github.com/hootsuite/atlantis/server/locking/boltdb" + "github.com/hootsuite/atlantis/server/logging" + "github.com/hootsuite/atlantis/server/models" + "github.com/hootsuite/atlantis/server/run" + "github.com/hootsuite/atlantis/server/static" + "github.com/hootsuite/atlantis/server/terraform" "github.com/mitchellh/go-homedir" "github.com/pkg/errors" "github.com/urfave/cli" diff --git a/static/bindata_assetfs.go b/server/static/bindata_assetfs.go similarity index 99% rename from static/bindata_assetfs.go rename to server/static/bindata_assetfs.go index e8a96d67e..e9663fb69 100644 --- a/static/bindata_assetfs.go +++ b/server/static/bindata_assetfs.go @@ -1,11 +1,11 @@ // Code generated by go-bindata. // sources: -// static/css/custom.css -// static/css/normalize.css -// static/css/skeleton.css -// static/images/atlantis-icon.png -// static/images/atlantis-icon_512.png -// static/js/jquery-3.2.1.min.js +// server/static/css/custom.css +// server/static/css/normalize.css +// server/static/css/skeleton.css +// server/static/images/atlantis-icon.png +// server/static/images/atlantis-icon_512.png +// server/static/js/jquery-3.2.1.min.js // DO NOT EDIT! package static @@ -89,7 +89,7 @@ func staticCssCustomCss() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "static/css/custom.css", size: 6701, mode: os.FileMode(420), modTime: time.Unix(1498689570, 0)} + info := bindataFileInfo{name: "static/css/custom.css", size: 6701, mode: os.FileMode(420), modTime: time.Unix(1499622019, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -109,7 +109,7 @@ func staticCssNormalizeCss() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "static/css/normalize.css", size: 7797, mode: os.FileMode(420), modTime: time.Unix(1495690053, 0)} + info := bindataFileInfo{name: "static/css/normalize.css", size: 7797, mode: os.FileMode(420), modTime: time.Unix(1499622019, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -129,7 +129,7 @@ func staticCssSkeletonCss() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "static/css/skeleton.css", size: 11452, mode: os.FileMode(420), modTime: time.Unix(1495690053, 0)} + info := bindataFileInfo{name: "static/css/skeleton.css", size: 11452, mode: os.FileMode(420), modTime: time.Unix(1499622019, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -149,7 +149,7 @@ func staticImagesAtlantisIconPng() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "static/images/atlantis-icon.png", size: 4238, mode: os.FileMode(420), modTime: time.Unix(1501691854, 0)} + info := bindataFileInfo{name: "static/images/atlantis-icon.png", size: 4238, mode: os.FileMode(420), modTime: time.Unix(1501647554, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -169,7 +169,7 @@ func staticImagesAtlantisIcon_512Png() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "static/images/atlantis-icon_512.png", size: 49782, mode: os.FileMode(420), modTime: time.Unix(1501691854, 0)} + info := bindataFileInfo{name: "static/images/atlantis-icon_512.png", size: 49782, mode: os.FileMode(420), modTime: time.Unix(1501647554, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -189,7 +189,7 @@ func staticJsJquery321MinJs() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "static/js/jquery-3.2.1.min.js", size: 86659, mode: os.FileMode(420), modTime: time.Unix(1498689570, 0)} + info := bindataFileInfo{name: "static/js/jquery-3.2.1.min.js", size: 86659, mode: os.FileMode(420), modTime: time.Unix(1499622019, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -359,8 +359,11 @@ func _filePath(dir, name string) string { func assetFS() *assetfs.AssetFS { + assetInfo := func(path string) (os.FileInfo, error) { + return os.Stat(path) + } for k := range _bintree.Children { - return &assetfs.AssetFS{Asset: Asset, AssetDir: AssetDir, AssetInfo: AssetInfo, Prefix: k} + return &assetfs.AssetFS{Asset: Asset, AssetDir: AssetDir, AssetInfo: assetInfo, Prefix: k} } panic("unreachable") } diff --git a/static/css/custom.css b/server/static/css/custom.css similarity index 100% rename from static/css/custom.css rename to server/static/css/custom.css diff --git a/static/css/normalize.css b/server/static/css/normalize.css similarity index 100% rename from static/css/normalize.css rename to server/static/css/normalize.css diff --git a/static/css/skeleton.css b/server/static/css/skeleton.css similarity index 100% rename from static/css/skeleton.css rename to server/static/css/skeleton.css diff --git a/static/images/atlantis-icon.png b/server/static/images/atlantis-icon.png similarity index 100% rename from static/images/atlantis-icon.png rename to server/static/images/atlantis-icon.png diff --git a/static/images/atlantis-icon_512.png b/server/static/images/atlantis-icon_512.png similarity index 100% rename from static/images/atlantis-icon_512.png rename to server/static/images/atlantis-icon_512.png diff --git a/static/js/jquery-3.2.1.min.js b/server/static/js/jquery-3.2.1.min.js similarity index 100% rename from static/js/jquery-3.2.1.min.js rename to server/static/js/jquery-3.2.1.min.js diff --git a/terraform/terraform_client.go b/server/terraform/terraform_client.go similarity index 98% rename from terraform/terraform_client.go rename to server/terraform/terraform_client.go index d5c40862f..8016c9160 100644 --- a/terraform/terraform_client.go +++ b/server/terraform/terraform_client.go @@ -10,7 +10,7 @@ import ( "strings" version "github.com/hashicorp/go-version" - "github.com/hootsuite/atlantis/logging" + "github.com/hootsuite/atlantis/server/logging" "github.com/pkg/errors" ) diff --git a/server/workspace.go b/server/workspace.go index e86746bfa..3b4a77237 100644 --- a/server/workspace.go +++ b/server/workspace.go @@ -6,7 +6,7 @@ import ( "path/filepath" "strconv" - "github.com/hootsuite/atlantis/models" + "github.com/hootsuite/atlantis/server/models" "github.com/pkg/errors" )