diff --git a/.gitignore b/.gitignore index 14349d26b5..dee87eee64 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,7 @@ output .terraform/ node_modules/ **/.vuepress/dist -helm/test-values.yaml \ No newline at end of file +helm/test-values.yaml +dist/ +build-harness +.build-harness diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000000..2cba21743b --- /dev/null +++ b/.travis.yml @@ -0,0 +1,39 @@ +sudo: required +language: go +go: +- 1.11.x +addons: + apt: + packages: + - git + - make + - curl + +env: +- DOCKER_IMAGE_NAME=cloudposse/atlantis + +services: +- docker + +install: +- make init +- make travis/docker-login +- make go/deps-dev + +script: +- make go/build/local +- gox -osarch="windows/386 windows/amd64 freebsd/arm netbsd/386 netbsd/amd64 netbsd/arm linux/s390x linux/arm darwin/386 darwin/amd64 linux/386 linux/amd64 freebsd/amd64 freebsd/386 openbsd/386 openbsd/amd64" -output "release/atlantis_{{.OS}}_{{.Arch}}" +- ls -l release/ +- make docker/build + +after_success: +- make travis/docker-tag-and-push + +deploy: +- provider: releases + api_key: "$GITHUB_API_KEY" + file_glob: true + file: "release/*" + skip_cleanup: true + on: + tags: true diff --git a/Dockerfile b/Dockerfile index 05580a4215..9e56142f59 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,11 +20,10 @@ RUN AVAILABLE_TERRAFORM_VERSIONS="0.8.8 0.9.11 0.10.8 ${DEFAULT_TERRAFORM_VERSIO ln -s /usr/local/bin/tf/versions/${DEFAULT_TERRAFORM_VERSION}/terraform /usr/local/bin/terraform # copy binary -COPY atlantis /usr/local/bin/atlantis +COPY dist/bin/atlantis /usr/local/bin/atlantis # copy docker entrypoint COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh ENTRYPOINT ["docker-entrypoint.sh"] CMD ["server"] - diff --git a/Gopkg.lock b/Gopkg.lock index 8ac5c6de06..9ba751e07e 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -2,148 +2,195 @@ [[projects]] + digest = "1:b856d8248663c39265a764561c1a1a149783f6cc815feb54a1f3a591b91f6eca" name = "github.com/Masterminds/semver" packages = ["."] + pruneopts = "" revision = "c7af12943936e8c39859482e61f0574c2fd7fc75" version = "v1.4.2" [[projects]] + digest = "1:d10482a602e3facc4fb1115a862153759339b825503f8420fcfc9738fd547730" name = "github.com/Masterminds/sprig" packages = ["."] + pruneopts = "" revision = "6b2a58267f6a8b1dc8e2eb5519b984008fa85e8c" version = "v2.15.0" [[projects]] + digest = "1:24cff84fefa06791f78f9bc6e05c2a3a90710c81ae6b76225280daf33b267d36" name = "github.com/aokoli/goutils" packages = ["."] + pruneopts = "" revision = "3391d3790d23d03408670993e957e8f408993c34" version = "v1.0.1" [[projects]] + digest = "1:ed112122ed4a920d944cc99b9d00b0441c11685939c28462c719488d36fe29aa" name = "github.com/boltdb/bolt" packages = ["."] + pruneopts = "" revision = "2f1ce7a837dcb8da3ec595b1dac9d0632f0f99e8" version = "v1.3.1" [[projects]] + digest = "1:3fc9b0f7d3cf0fd57264f4f092c6e6b443bf9a5d9ce1d9deb4849ab02ffe1878" name = "github.com/briandowns/spinner" packages = ["."] + pruneopts = "" revision = "48dbb65d7bd5c74ab50d53d04c949f20e3d14944" version = "1.0" [[projects]] + digest = "1:56c130d885a4aacae1dd9c7b71cfe39912c7ebc1ff7d2b46083c8812996dc43b" name = "github.com/davecgh/go-spew" packages = ["spew"] + pruneopts = "" revision = "346938d642f2ec3594ed81d874461961cd0faa76" version = "v1.1.0" [[projects]] branch = "master" + digest = "1:0fa341ce14006a4302303713264c9f27dfc55aa01bd95281ae9540f11d88064d" name = "github.com/docker/docker" packages = ["pkg/fileutils"] + pruneopts = "" revision = "e2593239d949eee454935daea7a5fe025477322f" [[projects]] branch = "master" + digest = "1:044b2f1eea2f5cfb0d3678baf60892734f59d5c2ea3932cb6ed894a97ccba15c" name = "github.com/elazarl/go-bindata-assetfs" packages = ["."] + pruneopts = "" revision = "30f82fa23fd844bd5bb1e5f216db87fd77b5eb43" [[projects]] + digest = "1:c9bebdae4ac52d0c3bbe5876de3d72f3bb05b4986865cdb3f15e305e1dc4fbca" name = "github.com/fatih/color" packages = ["."] + pruneopts = "" revision = "570b54cabe6b8eb0bc2dfce68d964677d63b5260" version = "v1.5.0" [[projects]] branch = "master" + digest = "1:93a4238f875be092b3bc5c68424a91d8f948d5f0cda99b44bc6de4849047d883" name = "github.com/flynn-archive/go-shlex" packages = ["."] + pruneopts = "" revision = "3f9db97f856818214da2e1057f8ad84803971cff" [[projects]] + digest = "1:9f1e571696860f2b4f8a241b43ce91c6085e7aaed849ccca53f590a4dc7b95bd" name = "github.com/fsnotify/fsnotify" packages = ["."] + pruneopts = "" revision = "629574ca2a5df945712d3079857300b5e4da0236" version = "v1.4.2" [[projects]] + digest = "1:cb589c43cf1a44b8583a1ffa01eb16cdd7346a396797049f86a6d3c93c73003a" name = "github.com/go-ozzo/ozzo-validation" packages = ["."] + pruneopts = "" revision = "85dcd8368eba387e65a03488b003e233994e87e9" version = "v3.3" [[projects]] + digest = "1:709292c015123a3bc69ea970dc9abd6667170e7fbf5cdeb10c6d14b250d3385f" name = "github.com/go-playground/locales" packages = [ ".", - "currency" + "currency", ] + pruneopts = "" revision = "f63010822830b6fe52288ee52d5a1151088ce039" version = "v0.12.1" [[projects]] + digest = "1:7ca0f6f2a364f603e843763d35c979b595d71159982791de27f9ec40d532876b" name = "github.com/go-playground/universal-translator" packages = ["."] + pruneopts = "" revision = "b32fa301c9fe55953584134cb6853a13c87ec0a1" version = "v0.16.0" [[projects]] + digest = "1:fb6b4ea21671a4a8037cccc0a582caada51b4ac550219f42b9e8ce4671bc568b" name = "github.com/go-test/deep" packages = ["."] + pruneopts = "" revision = "6592d9cc0a499ad2d5f574fde80a2b5c5cc3b4f5" version = "v1.0.1" [[projects]] branch = "master" + digest = "1:2179e0f76ac0c9132d0fb2ee03ce9f8116e72e7f55a251757ca92ebee9ba28a9" name = "github.com/google/go-github" packages = ["github"] + pruneopts = "" revision = "c004bf0c02fcab9d87a7f2e2f002fd008bf0784c" [[projects]] branch = "master" + digest = "1:9abc49f39e3e23e262594bb4fb70abf74c0c99e94f99153f43b143805e850719" name = "github.com/google/go-querystring" packages = ["query"] + pruneopts = "" revision = "53e6ce116135b80d037921a7fdd5138cf32d7a8a" [[projects]] + digest = "1:c1d7e883c50a26ea34019320d8ae40fad86c9e5d56e63a1ba2cb618cef43e986" name = "github.com/google/uuid" packages = ["."] + pruneopts = "" revision = "064e2069ce9c359c118179501254f67d7d37ba24" version = "0.2" [[projects]] + digest = "1:20ed7daa9b3b38b6d1d39b48ab3fd31122be5419461470d0c28de3e121c93ecf" name = "github.com/gorilla/context" packages = ["."] + pruneopts = "" revision = "1ea25387ff6f684839d82767c1733ff4d4d15d0a" version = "v1.1" [[projects]] + digest = "1:c2c8666b4836c81a1d247bdf21c6a6fc1ab586538ab56f74437c2e0df5c375e1" name = "github.com/gorilla/mux" packages = ["."] + pruneopts = "" revision = "e3702bed27f0d39777b0b37b664b6280e8ef8fbf" version = "v1.6.2" [[projects]] branch = "master" + digest = "1:304c322b62533a48ac052ffee80f67087fce1bc07186cd4e610a1b0e77765836" name = "github.com/hashicorp/errwrap" packages = ["."] + pruneopts = "" revision = "7554cd9344cec97297fa6649b055a8c98c2a1e55" [[projects]] branch = "master" + digest = "1:7660b6ee3fd92bcb9b19f5d359d3fbc8e853257d8a3d49e0424d00b6faa69cfd" name = "github.com/hashicorp/go-multierror" packages = ["."] + pruneopts = "" revision = "83588e72410abfbe4df460eeb6f30841ae47d4c4" [[projects]] branch = "master" + digest = "1:2aa07a6931b73e70f07a5bd30ef30a73cd103aa06291213c4e46e3fe52822dea" name = "github.com/hashicorp/go-version" packages = ["."] + pruneopts = "" revision = "fc61389e27c71d120f87031ca8c88a3428f372dd" [[projects]] branch = "master" + digest = "1:c12ac8c5b99dca211fcad8c7de30379cf83377f10a28125e8bdde556ab32896a" name = "github.com/hashicorp/hcl" packages = [ ".", @@ -154,199 +201,287 @@ "hcl/token", "json/parser", "json/scanner", - "json/token" + "json/token", ] + pruneopts = "" revision = "68e816d1c783414e79bc65b3994d9ab6b0a722ab" [[projects]] + digest = "1:a480764e28eb23a164526435877e08a26b0fcc7bade83b21a1fb307ed5ecde5a" name = "github.com/huandu/xstrings" packages = ["."] + pruneopts = "" revision = "2bf18b218c51864a87384c06996e40ff9dcff8e1" version = "v1.0.0" [[projects]] + digest = "1:302c6eb8e669c997bec516a138b8fc496018faa1ece4c13e445a2749fbe079bb" name = "github.com/imdario/mergo" packages = ["."] + pruneopts = "" revision = "9316a62528ac99aaecb4e47eadd6dc8aa6533d58" version = "v0.3.5" [[projects]] + digest = "1:870d441fe217b8e689d7949fef6e43efbc787e50f200cb1e70dbca9204a1d6be" name = "github.com/inconshreveable/mousetrap" packages = ["."] + pruneopts = "" revision = "76626ae9c91c4f2a10f34cad8ce83ea42c93bb75" version = "v1.0" [[projects]] branch = "master" + digest = "1:ecf8d2c7a243668631919f8bc88b0dce210d2350dc357fcba81d02a75ecb4a27" name = "github.com/lkysow/go-gitlab" packages = ["."] + pruneopts = "" revision = "fcd13266e57eb071cbedfe8efc7969a7bc4c8f22" [[projects]] + digest = "1:1ce378ab2352c756c6d7a0172c22ecbd387659d32712a4ce3bc474273309a5dc" name = "github.com/magiconair/properties" packages = ["."] + pruneopts = "" revision = "be5ece7dd465ab0765a9682137865547526d1dfb" version = "v1.7.3" [[projects]] + digest = "1:9ea83adf8e96d6304f394d40436f2eb44c1dc3250d223b74088cc253a6cd0a1c" name = "github.com/mattn/go-colorable" packages = ["."] + pruneopts = "" revision = "167de6bfdfba052fa6b2d3664c8f5272e23c9072" version = "v0.0.9" [[projects]] + digest = "1:420bb8eabfa6dff0cb5c8e786489a420e7e9d93a8b1d83882cce70c5a5b9bc3e" name = "github.com/mattn/go-isatty" packages = ["."] + pruneopts = "" revision = "fc9e8d8ef48496124e79ae0df75490096eccf6fe" version = "v0.0.2" [[projects]] branch = "master" + digest = "1:d1a560b8320893b5b92c25c94a66de450023a0632cde885e9ab123798a1dba0f" name = "github.com/mitchellh/colorstring" packages = ["."] + pruneopts = "" revision = "8631ce90f28644f54aeedcb3e389a85174e067d1" [[projects]] branch = "master" + digest = "1:59d11e81d6fdd12a771321696bb22abdd9a94d26ac864787e98c9b419e428734" name = "github.com/mitchellh/go-homedir" packages = ["."] + pruneopts = "" revision = "b8bc1bf767474819792c23f32d8286a45736f1c6" [[projects]] branch = "master" + digest = "1:c9ede10a9ded782d25d1f0be87c680e11409c23554828f19a19d691a95e76130" name = "github.com/mitchellh/mapstructure" packages = ["."] + pruneopts = "" revision = "d0303fe809921458f417bcf828397a65db30a7e4" [[projects]] branch = "master" + digest = "1:5875913107a4d3788be6cbe379c03fab558962dd2b9b961a3d86949507bac574" name = "github.com/mohae/deepcopy" packages = ["."] + pruneopts = "" revision = "491d3605edfb866af34a48075bd4355ac1bf46ca" [[projects]] + digest = "1:53f0ca8536bff15e4974b90def20012f61ef4fdb40b8b2712fa09c2820e53974" name = "github.com/nlopes/slack" packages = ["."] + pruneopts = "" revision = "c86337c0ef2486a15edd804355d9c73d2f2caed1" version = "v0.1.0" [[projects]] + digest = "1:a4e59d0b2821c983b58c317f141cd77df20570979632da8a7a352e5d12698de7" name = "github.com/onsi/gomega" packages = ["format"] + pruneopts = "" revision = "c893efa28eb45626cdaa76c9f653b62488858837" version = "v1.2.0" [[projects]] + digest = "1:049b5bee78dfdc9628ee0e557219c41f683e5b06c5a5f20eaba0105ccc586689" name = "github.com/pelletier/go-buffruneio" packages = ["."] + pruneopts = "" revision = "c37440a7cf42ac63b919c752ca73a85067e05992" version = "v0.2.0" [[projects]] + digest = "1:6d5a9728ae27e477a07bb69f02ea0bade74eb8b0c7346d046337904bbf7af065" name = "github.com/pelletier/go-toml" packages = ["."] + pruneopts = "" revision = "5ccdfb18c776b740aecaf085c4d9a2779199c279" version = "v1.0.0" [[projects]] branch = "master" + digest = "1:831c84fa78983f569db42021e6ab69e052bcf7c8b14509bffb739d715257ce78" name = "github.com/petergtz/pegomock" packages = [ ".", - "internal/verify" + "internal/verify", ] + pruneopts = "" revision = "e34a58f05f9a8ea0cd71912e02a4b08e1128aa81" [[projects]] + digest = "1:7365acd48986e205ccb8652cc746f09c8b7876030d53710ea6ef7d0bd0dcd7ca" name = "github.com/pkg/errors" packages = ["."] + pruneopts = "" revision = "645ef00459ed84a119197bfb8d8205042c6df63d" version = "v0.8.0" [[projects]] + digest = "1:3b9fb0706ab697ed8ff7a01dc93cd502110fc3b4e2deeada70f9e869fccef5eb" + name = "github.com/runatlantis/atlantis" + packages = [ + "cmd", + "server", + "server/events", + "server/events/locking", + "server/events/locking/boltdb", + "server/events/models", + "server/events/runtime", + "server/events/terraform", + "server/events/vcs", + "server/events/vcs/bitbucketcloud", + "server/events/vcs/bitbucketserver", + "server/events/webhooks", + "server/events/yaml", + "server/events/yaml/raw", + "server/events/yaml/valid", + "server/logging", + "server/recovery", + "server/static", + "testdrive", + ] + pruneopts = "" + revision = "0c7fa9dc8b5dbdacd936cf051dfb2297dd70bd3c" + version = "v0.4.10" + +[[projects]] + digest = "1:8cf46b6c18a91068d446e26b67512cf16f1540b45d90b28b9533706a127f0ca6" name = "github.com/sirupsen/logrus" packages = ["."] + pruneopts = "" revision = "c155da19408a8799da419ed3eeb0cb5db0ad5dbc" version = "v1.0.5" [[projects]] branch = "master" + digest = "1:c189f11a84aa8b868a4b7cd4605653160424ab299cf7cfb1c5bd2740b949928f" name = "github.com/spf13/afero" packages = [ ".", - "mem" + "mem", ] + pruneopts = "" revision = "ee1bd8ee15a1306d1f9201acc41ef39cd9f99a1b" [[projects]] + digest = "1:6ff9b74bfea2625f805edec59395dc37e4a06458dd3c14e3372337e3d35a2ed6" name = "github.com/spf13/cast" packages = ["."] + pruneopts = "" revision = "acbeb36b902d72a7a4c18e8f3241075e7ab763e4" version = "v1.1.0" [[projects]] branch = "master" + digest = "1:146327ce93be37e68bd3ff8541090d96da8cb3adc9e35d57570e9170a29f6bf6" name = "github.com/spf13/cobra" packages = ["."] + pruneopts = "" revision = "b78744579491c1ceeaaa3b40205e56b0591b93a3" [[projects]] branch = "master" + digest = "1:5cb42b990db5dc48b8bc23b6ee77b260713ba3244ca495cd1ed89533dc482a49" name = "github.com/spf13/jwalterweatherman" packages = ["."] + pruneopts = "" revision = "12bd96e66386c1960ab0f74ced1362f66f552f7b" [[projects]] + digest = "1:261bc565833ef4f02121450d74eb88d5ae4bd74bfe5d0e862cddb8550ec35000" name = "github.com/spf13/pflag" packages = ["."] + pruneopts = "" revision = "e57e3eeb33f795204c1ca35f56c44f83227c6e66" version = "v1.0.0" [[projects]] + digest = "1:59354ad53dfe6ed1b941844cb029cd37c0377598eec3a0d49c03aee2375ef9c4" name = "github.com/spf13/viper" packages = ["."] + pruneopts = "" revision = "25b30aa063fc18e48662b86996252eabdcf2f0c7" version = "v1.0.0" [[projects]] + digest = "1:e85837cb04b78f61688c6eba93ea9d14f60d611e2aaf8319999b1a60d2dafbfa" name = "github.com/urfave/cli" packages = ["."] + pruneopts = "" revision = "cfb38830724cc34fedffe9a2a29fb54fa9169cd1" version = "v1.20.0" [[projects]] + digest = "1:80cf22cc45eb6fdfce2515a2401b04bffa2be83261577761ab788688dad699a1" name = "github.com/urfave/negroni" packages = ["."] + pruneopts = "" revision = "fde5e16d32adc7ad637e9cd9ad21d4ebc6192535" version = "v0.2.0" [[projects]] branch = "master" + digest = "1:e10c88bfaf62d55e2f19df1de09c322531079fb17d105d3dcb4bd6153e30139a" name = "golang.org/x/crypto" packages = [ "pbkdf2", "scrypt", - "ssh/terminal" + "ssh/terminal", ] + pruneopts = "" revision = "7d9177d70076375b9a59c8fde23d52d9c4a7ecd5" [[projects]] branch = "master" + digest = "1:130b1bec86c62e121967ee0c69d9c263dc2d3ffe6c7c9a82aca4071c4d068861" name = "golang.org/x/net" packages = ["websocket"] + pruneopts = "" revision = "9dfe39835686865bff950a07b394c12a98ddc811" [[projects]] branch = "master" + digest = "1:cc11c1cd2fbbd5a2e883bb581b74c0a61857239fa9cd5cf96e274eb447689354" name = "golang.org/x/sys" packages = [ "unix", - "windows" + "windows", ] + pruneopts = "" revision = "062cd7e4e68206d8bab9b18396626e855c992658" [[projects]] branch = "master" + digest = "1:6ffd50f330d82d5a92f109253f3831900ccb99f973fb7d614e54ceaf6a41dcec" name = "golang.org/x/text" packages = [ "internal/gen", @@ -354,25 +489,60 @@ "internal/ucd", "transform", "unicode/cldr", - "unicode/norm" + "unicode/norm", ] + pruneopts = "" revision = "1cbadb444a806fd9430d14ad08967ed91da4fa0a" [[projects]] + digest = "1:9d556ac00a9410814ee329851fded1a38f08db35e20e832778c96241de558fb7" name = "gopkg.in/go-playground/validator.v9" packages = ["."] + pruneopts = "" revision = "ab2a8a99087e827c9af87ed6777ba897348fb178" version = "v9.20.2" [[projects]] branch = "v2" + digest = "1:81314a486195626940617e43740b4fa073f265b0715c9f54ce2027fee1cb5f61" name = "gopkg.in/yaml.v2" packages = ["."] + pruneopts = "" revision = "eb3733d160e74a9c7e442f435eb3bea458e1d19f" [solve-meta] analyzer-name = "dep" analyzer-version = 1 - inputs-digest = "a2ddeb1120c832afff8bb9cf48ae85656c0e97f125f0a5d3742152bfb41c04e1" + input-imports = [ + "github.com/Masterminds/sprig", + "github.com/boltdb/bolt", + "github.com/briandowns/spinner", + "github.com/davecgh/go-spew/spew", + "github.com/docker/docker/pkg/fileutils", + "github.com/elazarl/go-bindata-assetfs", + "github.com/flynn-archive/go-shlex", + "github.com/go-ozzo/ozzo-validation", + "github.com/go-test/deep", + "github.com/google/go-github/github", + "github.com/gorilla/mux", + "github.com/hashicorp/go-multierror", + "github.com/hashicorp/go-version", + "github.com/lkysow/go-gitlab", + "github.com/mitchellh/colorstring", + "github.com/mitchellh/go-homedir", + "github.com/mohae/deepcopy", + "github.com/nlopes/slack", + "github.com/petergtz/pegomock", + "github.com/pkg/errors", + "github.com/runatlantis/atlantis/cmd", + "github.com/spf13/cobra", + "github.com/spf13/pflag", + "github.com/spf13/viper", + "github.com/urfave/cli", + "github.com/urfave/negroni", + "golang.org/x/crypto/ssh/terminal", + "gopkg.in/go-playground/validator.v9", + "gopkg.in/yaml.v2", + ] solver-name = "gps-cdcl" solver-version = 1 diff --git a/Makefile b/Makefile index 5884cfe355..173334ceff 100644 --- a/Makefile +++ b/Makefile @@ -4,6 +4,17 @@ PKG := $(shell go list ./... | grep -v e2e | grep -v vendor | grep -v static | g PKG_COMMAS := $(shell go list ./... | grep -v e2e | grep -v vendor | grep -v static | grep -v mocks | grep -v testing | tr '\n' ',') IMAGE_NAME := runatlantis/atlantis +SHELL = /bin/bash +PATH:=$(PATH):$(GOPATH)/bin + +export DOCKER_ORG ?= cloudposse +export DOCKER_IMAGE ?= cloudposse/atlantis +export DOCKER_TAG ?= latest +export DOCKER_IMAGE_NAME ?= $(DOCKER_IMAGE):$(DOCKER_TAG) +export DOCKER_BUILD_FLAGS = + +-include $(shell curl -sSL -o .build-harness "https://git.io/build-harness"; echo .build-harness) + .PHONY: test .DEFAULT_GOAL := help @@ -86,3 +97,9 @@ end-to-end-tests: ## Run e2e tests website-dev: yarn website:dev + +go/get/local: + go get + +go/build/local: + CGO_ENABLED=0 go build -v -o "./dist/bin/atlantis" . diff --git a/cmd/bootstrap.go b/cmd/bootstrap.go index ffda6e0b62..fc3a1a0078 100644 --- a/cmd/bootstrap.go +++ b/cmd/bootstrap.go @@ -17,7 +17,7 @@ import ( "fmt" "os" - "github.com/runatlantis/atlantis/testdrive" + "github.com/cloudposse/atlantis/testdrive" "github.com/spf13/cobra" ) diff --git a/cmd/server.go b/cmd/server.go index e983d5de2e..c58d4a2b05 100644 --- a/cmd/server.go +++ b/cmd/server.go @@ -20,10 +20,10 @@ import ( "path/filepath" "strings" + "github.com/cloudposse/atlantis/server" + "github.com/cloudposse/atlantis/server/events/vcs/bitbucketcloud" "github.com/mitchellh/go-homedir" "github.com/pkg/errors" - "github.com/runatlantis/atlantis/server" - "github.com/runatlantis/atlantis/server/events/vcs/bitbucketcloud" "github.com/spf13/cobra" "github.com/spf13/viper" ) @@ -44,6 +44,7 @@ const ( ConfigFlag = "config" DataDirFlag = "data-dir" GHHostnameFlag = "gh-hostname" + GHTeamWhitelistFlag = "gh-team-whitelist" GHTokenFlag = "gh-token" GHUserFlag = "gh-user" GHWebhookSecretFlag = "gh-webhook-secret" // nolint: gosec @@ -62,6 +63,7 @@ const ( DefaultBitbucketBaseURL = bitbucketcloud.BaseURL DefaultDataDir = "~/.atlantis" DefaultGHHostname = "github.com" + DefaultGHTeamWhitelist = "*:*" DefaultGitlabHostname = "gitlab.com" DefaultLogLevel = "info" DefaultPort = 4141 @@ -111,6 +113,15 @@ var stringFlags = []stringFlag{ description: "Hostname of your Github Enterprise installation. If using github.com, no need to set.", defaultValue: DefaultGHHostname, }, + { + name: GHTeamWhitelistFlag, + description: "Comma separated list of key-value pairs representing the GitHub teams and the operations that the members of a particular team are allowed to perform. " + + "The format is {team}:{command},{team}:{command}, ex. dev:plan,ops:apply,devops:*. " + + "This example means to give the users from the 'dev' GitHub team the permissions to execute the 'plan' command, give the 'ops' team the permissions to execute the 'apply' command, " + + "and allow the 'devops' team to perform any operation. If this argument is not provided, the default value (*:*) will be used and the default behavior will be to not check permissions " + + "and to allow users from any team to perform any operation.", + defaultValue: DefaultGHTeamWhitelist, + }, { name: GHUserFlag, description: "GitHub username of API user.", @@ -365,6 +376,9 @@ func (s *ServerCmd) setDefaults(c *server.UserConfig) { if c.Port == 0 { c.Port = DefaultPort } + if c.GithubTeamWhitelist == "" { + c.GithubTeamWhitelist = DefaultGHTeamWhitelist + } } func (s *ServerCmd) validate(userConfig server.UserConfig) error { diff --git a/cmd/server_test.go b/cmd/server_test.go index 428ea34591..8fc146f92e 100644 --- a/cmd/server_test.go +++ b/cmd/server_test.go @@ -20,10 +20,10 @@ import ( "strings" "testing" + "github.com/cloudposse/atlantis/cmd" + "github.com/cloudposse/atlantis/server" + . "github.com/cloudposse/atlantis/testing" "github.com/mitchellh/go-homedir" - "github.com/runatlantis/atlantis/cmd" - "github.com/runatlantis/atlantis/server" - . "github.com/runatlantis/atlantis/testing" "github.com/spf13/cobra" "github.com/spf13/viper" ) diff --git a/helm/atlantis/Chart.yaml b/helm/atlantis/Chart.yaml index 18c94fdd2a..c3427f3843 100644 --- a/helm/atlantis/Chart.yaml +++ b/helm/atlantis/Chart.yaml @@ -1,5 +1,5 @@ apiVersion: v1 -appVersion: "v0.4.5" +appVersion: "v0.5.0" description: A Helm chart for Atlantis https://www.runatlantis.io name: atlantis version: 0.1.0 diff --git a/main.go b/main.go index 07458c10b1..6c6cb1b1ec 100644 --- a/main.go +++ b/main.go @@ -15,11 +15,11 @@ package main import ( - "github.com/runatlantis/atlantis/cmd" + "github.com/cloudposse/atlantis/cmd" "github.com/spf13/viper" ) -const atlantisVersion = "0.4.10" +const atlantisVersion = "0.5.0" func main() { v := viper.New() diff --git a/server/events/command_context.go b/server/events/command_context.go index 497adcd504..543aef9e39 100644 --- a/server/events/command_context.go +++ b/server/events/command_context.go @@ -14,8 +14,8 @@ package events import ( - "github.com/runatlantis/atlantis/server/events/models" - "github.com/runatlantis/atlantis/server/logging" + "github.com/cloudposse/atlantis/server/events/models" + "github.com/cloudposse/atlantis/server/logging" ) // CommandContext represents the context of a command that should be executed diff --git a/server/events/command_runner.go b/server/events/command_runner.go index 2465b7ee09..41262253fe 100644 --- a/server/events/command_runner.go +++ b/server/events/command_runner.go @@ -16,13 +16,13 @@ package events import ( "fmt" + "github.com/cloudposse/atlantis/server/events/models" + "github.com/cloudposse/atlantis/server/events/vcs" + "github.com/cloudposse/atlantis/server/logging" + "github.com/cloudposse/atlantis/server/recovery" "github.com/google/go-github/github" "github.com/lkysow/go-gitlab" "github.com/pkg/errors" - "github.com/runatlantis/atlantis/server/events/models" - "github.com/runatlantis/atlantis/server/events/vcs" - "github.com/runatlantis/atlantis/server/logging" - "github.com/runatlantis/atlantis/server/recovery" ) //go:generate pegomock generate -m --use-experimental-model-gen --package mocks -o mocks/mock_command_runner.go CommandRunner diff --git a/server/events/command_runner_test.go b/server/events/command_runner_test.go index 37c54f1a80..bcc9937ecd 100644 --- a/server/events/command_runner_test.go +++ b/server/events/command_runner_test.go @@ -20,16 +20,16 @@ import ( "strings" "testing" + "github.com/cloudposse/atlantis/server/events" + "github.com/cloudposse/atlantis/server/events/mocks" + "github.com/cloudposse/atlantis/server/events/mocks/matchers" + "github.com/cloudposse/atlantis/server/events/models" + "github.com/cloudposse/atlantis/server/events/models/fixtures" + vcsmocks "github.com/cloudposse/atlantis/server/events/vcs/mocks" + logmocks "github.com/cloudposse/atlantis/server/logging/mocks" + . "github.com/cloudposse/atlantis/testing" "github.com/google/go-github/github" . "github.com/petergtz/pegomock" - "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/models" - "github.com/runatlantis/atlantis/server/events/models/fixtures" - vcsmocks "github.com/runatlantis/atlantis/server/events/vcs/mocks" - logmocks "github.com/runatlantis/atlantis/server/logging/mocks" - . "github.com/runatlantis/atlantis/testing" ) var projectCommandBuilder *mocks.MockProjectCommandBuilder diff --git a/server/events/comment_parser.go b/server/events/comment_parser.go index c4c5743ae0..92b7310edd 100644 --- a/server/events/comment_parser.go +++ b/server/events/comment_parser.go @@ -21,8 +21,8 @@ import ( "regexp" "strings" - "github.com/runatlantis/atlantis/server/events/models" - "github.com/runatlantis/atlantis/server/events/yaml" + "github.com/cloudposse/atlantis/server/events/models" + "github.com/cloudposse/atlantis/server/events/yaml" "github.com/spf13/pflag" ) diff --git a/server/events/comment_parser_test.go b/server/events/comment_parser_test.go index ff6250b7f4..b788455292 100644 --- a/server/events/comment_parser_test.go +++ b/server/events/comment_parser_test.go @@ -18,9 +18,9 @@ import ( "strings" "testing" - "github.com/runatlantis/atlantis/server/events" - "github.com/runatlantis/atlantis/server/events/models" - . "github.com/runatlantis/atlantis/testing" + "github.com/cloudposse/atlantis/server/events" + "github.com/cloudposse/atlantis/server/events/models" + . "github.com/cloudposse/atlantis/testing" ) var commentParser = events.CommentParser{ diff --git a/server/events/commit_status_updater.go b/server/events/commit_status_updater.go index 0198bbf12e..6bd312e1d4 100644 --- a/server/events/commit_status_updater.go +++ b/server/events/commit_status_updater.go @@ -17,8 +17,8 @@ import ( "fmt" "strings" - "github.com/runatlantis/atlantis/server/events/models" - "github.com/runatlantis/atlantis/server/events/vcs" + "github.com/cloudposse/atlantis/server/events/models" + "github.com/cloudposse/atlantis/server/events/vcs" ) //go:generate pegomock generate -m --use-experimental-model-gen --package mocks -o mocks/mock_commit_status_updater.go CommitStatusUpdater diff --git a/server/events/commit_status_updater_test.go b/server/events/commit_status_updater_test.go index 209b3f5493..a146c1cc71 100644 --- a/server/events/commit_status_updater_test.go +++ b/server/events/commit_status_updater_test.go @@ -18,11 +18,11 @@ import ( "strings" "testing" + "github.com/cloudposse/atlantis/server/events" + "github.com/cloudposse/atlantis/server/events/models" + "github.com/cloudposse/atlantis/server/events/vcs/mocks" + . "github.com/cloudposse/atlantis/testing" . "github.com/petergtz/pegomock" - "github.com/runatlantis/atlantis/server/events" - "github.com/runatlantis/atlantis/server/events/models" - "github.com/runatlantis/atlantis/server/events/vcs/mocks" - . "github.com/runatlantis/atlantis/testing" ) var repoModel = models.Repo{} diff --git a/server/events/event_parser.go b/server/events/event_parser.go index 52c430a864..e844091457 100644 --- a/server/events/event_parser.go +++ b/server/events/event_parser.go @@ -19,12 +19,12 @@ import ( "path" "strings" + "github.com/cloudposse/atlantis/server/events/models" + "github.com/cloudposse/atlantis/server/events/vcs/bitbucketcloud" + "github.com/cloudposse/atlantis/server/events/vcs/bitbucketserver" "github.com/google/go-github/github" "github.com/lkysow/go-gitlab" "github.com/pkg/errors" - "github.com/runatlantis/atlantis/server/events/models" - "github.com/runatlantis/atlantis/server/events/vcs/bitbucketcloud" - "github.com/runatlantis/atlantis/server/events/vcs/bitbucketserver" "gopkg.in/go-playground/validator.v9" ) diff --git a/server/events/event_parser_test.go b/server/events/event_parser_test.go index 885293792d..ea62a6d4bc 100644 --- a/server/events/event_parser_test.go +++ b/server/events/event_parser_test.go @@ -21,13 +21,13 @@ import ( "strings" "testing" + "github.com/cloudposse/atlantis/server/events" + "github.com/cloudposse/atlantis/server/events/models" + . "github.com/cloudposse/atlantis/server/events/vcs/fixtures" + . "github.com/cloudposse/atlantis/testing" "github.com/google/go-github/github" "github.com/lkysow/go-gitlab" "github.com/mohae/deepcopy" - "github.com/runatlantis/atlantis/server/events" - "github.com/runatlantis/atlantis/server/events/models" - . "github.com/runatlantis/atlantis/server/events/vcs/fixtures" - . "github.com/runatlantis/atlantis/testing" ) var parser = events.EventParser{ diff --git a/server/events/locking/boltdb/boltdb.go b/server/events/locking/boltdb/boltdb.go index 5e34a3c633..db7f3e4954 100644 --- a/server/events/locking/boltdb/boltdb.go +++ b/server/events/locking/boltdb/boltdb.go @@ -25,8 +25,8 @@ import ( "time" "github.com/boltdb/bolt" + "github.com/cloudposse/atlantis/server/events/models" "github.com/pkg/errors" - "github.com/runatlantis/atlantis/server/events/models" ) // BoltLocker is a locking backend using BoltDB diff --git a/server/events/locking/boltdb/boltdb_test.go b/server/events/locking/boltdb/boltdb_test.go index 62acb63457..3086e3e31b 100644 --- a/server/events/locking/boltdb/boltdb_test.go +++ b/server/events/locking/boltdb/boltdb_test.go @@ -20,10 +20,10 @@ import ( "time" "github.com/boltdb/bolt" + "github.com/cloudposse/atlantis/server/events/locking/boltdb" + "github.com/cloudposse/atlantis/server/events/models" + . "github.com/cloudposse/atlantis/testing" "github.com/pkg/errors" - "github.com/runatlantis/atlantis/server/events/locking/boltdb" - "github.com/runatlantis/atlantis/server/events/models" - . "github.com/runatlantis/atlantis/testing" ) var lockBucket = "bucket" diff --git a/server/events/locking/locking.go b/server/events/locking/locking.go index 2f556d7721..d0d2008ed7 100644 --- a/server/events/locking/locking.go +++ b/server/events/locking/locking.go @@ -20,7 +20,7 @@ import ( "regexp" "time" - "github.com/runatlantis/atlantis/server/events/models" + "github.com/cloudposse/atlantis/server/events/models" ) //go:generate pegomock generate -m --use-experimental-model-gen --package mocks -o mocks/mock_backend.go Backend diff --git a/server/events/locking/locking_test.go b/server/events/locking/locking_test.go index f492c62d80..cce58c230a 100644 --- a/server/events/locking/locking_test.go +++ b/server/events/locking/locking_test.go @@ -20,12 +20,12 @@ import ( "strings" + "github.com/cloudposse/atlantis/server/events/locking" + "github.com/cloudposse/atlantis/server/events/locking/mocks" + "github.com/cloudposse/atlantis/server/events/locking/mocks/matchers" + "github.com/cloudposse/atlantis/server/events/models" + . "github.com/cloudposse/atlantis/testing" . "github.com/petergtz/pegomock" - "github.com/runatlantis/atlantis/server/events/locking" - "github.com/runatlantis/atlantis/server/events/locking/mocks" - "github.com/runatlantis/atlantis/server/events/locking/mocks/matchers" - "github.com/runatlantis/atlantis/server/events/models" - . "github.com/runatlantis/atlantis/testing" ) var project = models.NewProject("owner/repo", "path") diff --git a/server/events/locking/mocks/matchers/locking_trylockresponse.go b/server/events/locking/mocks/matchers/locking_trylockresponse.go index b6f7c76f70..9ba935850b 100644 --- a/server/events/locking/mocks/matchers/locking_trylockresponse.go +++ b/server/events/locking/mocks/matchers/locking_trylockresponse.go @@ -3,8 +3,8 @@ package matchers import ( "reflect" + locking "github.com/cloudposse/atlantis/server/events/locking" "github.com/petergtz/pegomock" - locking "github.com/runatlantis/atlantis/server/events/locking" ) func AnyLockingTryLockResponse() locking.TryLockResponse { diff --git a/server/events/locking/mocks/matchers/map_of_string_to_models_projectlock.go b/server/events/locking/mocks/matchers/map_of_string_to_models_projectlock.go index 732eb220ba..aa0e2d5521 100644 --- a/server/events/locking/mocks/matchers/map_of_string_to_models_projectlock.go +++ b/server/events/locking/mocks/matchers/map_of_string_to_models_projectlock.go @@ -5,7 +5,7 @@ import ( "github.com/petergtz/pegomock" - models "github.com/runatlantis/atlantis/server/events/models" + models "github.com/cloudposse/atlantis/server/events/models" ) func AnyMapOfStringToModelsProjectLock() map[string]models.ProjectLock { diff --git a/server/events/locking/mocks/matchers/models_project.go b/server/events/locking/mocks/matchers/models_project.go index 4fffc3faa2..011db4f56f 100644 --- a/server/events/locking/mocks/matchers/models_project.go +++ b/server/events/locking/mocks/matchers/models_project.go @@ -3,8 +3,8 @@ package matchers import ( "reflect" + models "github.com/cloudposse/atlantis/server/events/models" "github.com/petergtz/pegomock" - models "github.com/runatlantis/atlantis/server/events/models" ) func AnyModelsProject() models.Project { diff --git a/server/events/locking/mocks/matchers/models_projectlock.go b/server/events/locking/mocks/matchers/models_projectlock.go index 61d0500bb2..b74616555f 100644 --- a/server/events/locking/mocks/matchers/models_projectlock.go +++ b/server/events/locking/mocks/matchers/models_projectlock.go @@ -3,8 +3,8 @@ package matchers import ( "reflect" + models "github.com/cloudposse/atlantis/server/events/models" "github.com/petergtz/pegomock" - models "github.com/runatlantis/atlantis/server/events/models" ) func AnyModelsProjectLock() models.ProjectLock { diff --git a/server/events/locking/mocks/matchers/models_pullrequest.go b/server/events/locking/mocks/matchers/models_pullrequest.go index d8b146baa4..3b0b7b3178 100644 --- a/server/events/locking/mocks/matchers/models_pullrequest.go +++ b/server/events/locking/mocks/matchers/models_pullrequest.go @@ -3,8 +3,8 @@ package matchers import ( "reflect" + models "github.com/cloudposse/atlantis/server/events/models" "github.com/petergtz/pegomock" - models "github.com/runatlantis/atlantis/server/events/models" ) func AnyModelsPullRequest() models.PullRequest { diff --git a/server/events/locking/mocks/matchers/models_user.go b/server/events/locking/mocks/matchers/models_user.go index 3f2b4d8c6d..484f36432f 100644 --- a/server/events/locking/mocks/matchers/models_user.go +++ b/server/events/locking/mocks/matchers/models_user.go @@ -3,8 +3,8 @@ package matchers import ( "reflect" + models "github.com/cloudposse/atlantis/server/events/models" "github.com/petergtz/pegomock" - models "github.com/runatlantis/atlantis/server/events/models" ) func AnyModelsUser() models.User { diff --git a/server/events/locking/mocks/matchers/ptr_to_models_projectlock.go b/server/events/locking/mocks/matchers/ptr_to_models_projectlock.go index 62d2cd4f6c..c6c29c5a8d 100644 --- a/server/events/locking/mocks/matchers/ptr_to_models_projectlock.go +++ b/server/events/locking/mocks/matchers/ptr_to_models_projectlock.go @@ -3,8 +3,8 @@ package matchers import ( "reflect" + models "github.com/cloudposse/atlantis/server/events/models" "github.com/petergtz/pegomock" - models "github.com/runatlantis/atlantis/server/events/models" ) func AnyPtrToModelsProjectLock() *models.ProjectLock { diff --git a/server/events/locking/mocks/matchers/slice_of_models_projectlock.go b/server/events/locking/mocks/matchers/slice_of_models_projectlock.go index f6ce82e953..1efc17001d 100644 --- a/server/events/locking/mocks/matchers/slice_of_models_projectlock.go +++ b/server/events/locking/mocks/matchers/slice_of_models_projectlock.go @@ -3,8 +3,8 @@ package matchers import ( "reflect" + models "github.com/cloudposse/atlantis/server/events/models" "github.com/petergtz/pegomock" - models "github.com/runatlantis/atlantis/server/events/models" ) func AnySliceOfModelsProjectLock() []models.ProjectLock { diff --git a/server/events/locking/mocks/mock_backend.go b/server/events/locking/mocks/mock_backend.go index fd1f1211bf..1532682378 100644 --- a/server/events/locking/mocks/mock_backend.go +++ b/server/events/locking/mocks/mock_backend.go @@ -6,8 +6,8 @@ package mocks import ( "reflect" + models "github.com/cloudposse/atlantis/server/events/models" pegomock "github.com/petergtz/pegomock" - models "github.com/runatlantis/atlantis/server/events/models" ) type MockBackend struct { diff --git a/server/events/locking/mocks/mock_locker.go b/server/events/locking/mocks/mock_locker.go index fe6fcf1f5b..5219e69c43 100644 --- a/server/events/locking/mocks/mock_locker.go +++ b/server/events/locking/mocks/mock_locker.go @@ -6,9 +6,9 @@ package mocks import ( "reflect" + locking "github.com/cloudposse/atlantis/server/events/locking" + models "github.com/cloudposse/atlantis/server/events/models" pegomock "github.com/petergtz/pegomock" - locking "github.com/runatlantis/atlantis/server/events/locking" - models "github.com/runatlantis/atlantis/server/events/models" ) type MockLocker struct { diff --git a/server/events/markdown_renderer.go b/server/events/markdown_renderer.go index 18a38cc3c3..68a397d2dd 100644 --- a/server/events/markdown_renderer.go +++ b/server/events/markdown_renderer.go @@ -21,7 +21,7 @@ import ( "text/template" "github.com/Masterminds/sprig" - "github.com/runatlantis/atlantis/server/events/models" + "github.com/cloudposse/atlantis/server/events/models" ) const ( diff --git a/server/events/markdown_renderer_test.go b/server/events/markdown_renderer_test.go index db98850a65..152bbca2e0 100644 --- a/server/events/markdown_renderer_test.go +++ b/server/events/markdown_renderer_test.go @@ -19,9 +19,9 @@ import ( "strings" "testing" - "github.com/runatlantis/atlantis/server/events" - "github.com/runatlantis/atlantis/server/events/models" - . "github.com/runatlantis/atlantis/testing" + "github.com/cloudposse/atlantis/server/events" + "github.com/cloudposse/atlantis/server/events/models" + . "github.com/cloudposse/atlantis/testing" ) func TestRenderErr(t *testing.T) { diff --git a/server/events/mocks/matchers/events_commandname.go b/server/events/mocks/matchers/events_commandname.go index 448c937abc..bafb9e9a38 100644 --- a/server/events/mocks/matchers/events_commandname.go +++ b/server/events/mocks/matchers/events_commandname.go @@ -3,8 +3,8 @@ package matchers import ( "reflect" + events "github.com/cloudposse/atlantis/server/events" "github.com/petergtz/pegomock" - events "github.com/runatlantis/atlantis/server/events" ) func AnyEventsCommandName() events.CommandName { diff --git a/server/events/mocks/matchers/events_commandresult.go b/server/events/mocks/matchers/events_commandresult.go index 54269ef123..af8e332461 100644 --- a/server/events/mocks/matchers/events_commandresult.go +++ b/server/events/mocks/matchers/events_commandresult.go @@ -3,8 +3,8 @@ package matchers import ( "reflect" + events "github.com/cloudposse/atlantis/server/events" "github.com/petergtz/pegomock" - events "github.com/runatlantis/atlantis/server/events" ) func AnyEventsCommandResult() events.CommandResult { diff --git a/server/events/mocks/matchers/events_commentparseresult.go b/server/events/mocks/matchers/events_commentparseresult.go index 5409329944..697c1cee9c 100644 --- a/server/events/mocks/matchers/events_commentparseresult.go +++ b/server/events/mocks/matchers/events_commentparseresult.go @@ -3,8 +3,8 @@ package matchers import ( "reflect" + events "github.com/cloudposse/atlantis/server/events" "github.com/petergtz/pegomock" - events "github.com/runatlantis/atlantis/server/events" ) func AnyEventsCommentParseResult() events.CommentParseResult { diff --git a/server/events/mocks/matchers/events_projectresult.go b/server/events/mocks/matchers/events_projectresult.go index 2006d2242c..583ac125ca 100644 --- a/server/events/mocks/matchers/events_projectresult.go +++ b/server/events/mocks/matchers/events_projectresult.go @@ -3,8 +3,8 @@ package matchers import ( "reflect" + events "github.com/cloudposse/atlantis/server/events" "github.com/petergtz/pegomock" - events "github.com/runatlantis/atlantis/server/events" ) func AnyEventsProjectResult() events.ProjectResult { diff --git a/server/events/mocks/matchers/models_project.go b/server/events/mocks/matchers/models_project.go index 4fffc3faa2..011db4f56f 100644 --- a/server/events/mocks/matchers/models_project.go +++ b/server/events/mocks/matchers/models_project.go @@ -3,8 +3,8 @@ package matchers import ( "reflect" + models "github.com/cloudposse/atlantis/server/events/models" "github.com/petergtz/pegomock" - models "github.com/runatlantis/atlantis/server/events/models" ) func AnyModelsProject() models.Project { diff --git a/server/events/mocks/matchers/models_projectcommandcontext.go b/server/events/mocks/matchers/models_projectcommandcontext.go index 3f76b9a225..c8bc54aa1a 100644 --- a/server/events/mocks/matchers/models_projectcommandcontext.go +++ b/server/events/mocks/matchers/models_projectcommandcontext.go @@ -3,8 +3,8 @@ package matchers import ( "reflect" + models "github.com/cloudposse/atlantis/server/events/models" "github.com/petergtz/pegomock" - models "github.com/runatlantis/atlantis/server/events/models" ) func AnyModelsProjectCommandContext() models.ProjectCommandContext { diff --git a/server/events/mocks/matchers/models_pullrequest.go b/server/events/mocks/matchers/models_pullrequest.go index d8b146baa4..3b0b7b3178 100644 --- a/server/events/mocks/matchers/models_pullrequest.go +++ b/server/events/mocks/matchers/models_pullrequest.go @@ -3,8 +3,8 @@ package matchers import ( "reflect" + models "github.com/cloudposse/atlantis/server/events/models" "github.com/petergtz/pegomock" - models "github.com/runatlantis/atlantis/server/events/models" ) func AnyModelsPullRequest() models.PullRequest { diff --git a/server/events/mocks/matchers/models_pullrequesteventtype.go b/server/events/mocks/matchers/models_pullrequesteventtype.go index d9fa4462cd..6c5bf942b6 100644 --- a/server/events/mocks/matchers/models_pullrequesteventtype.go +++ b/server/events/mocks/matchers/models_pullrequesteventtype.go @@ -3,8 +3,8 @@ package matchers import ( "reflect" + models "github.com/cloudposse/atlantis/server/events/models" "github.com/petergtz/pegomock" - models "github.com/runatlantis/atlantis/server/events/models" ) func AnyModelsPullRequestEventType() models.PullRequestEventType { diff --git a/server/events/mocks/matchers/models_repo.go b/server/events/mocks/matchers/models_repo.go index 3f8e699ebe..a813489d6e 100644 --- a/server/events/mocks/matchers/models_repo.go +++ b/server/events/mocks/matchers/models_repo.go @@ -3,8 +3,8 @@ package matchers import ( "reflect" + models "github.com/cloudposse/atlantis/server/events/models" "github.com/petergtz/pegomock" - models "github.com/runatlantis/atlantis/server/events/models" ) func AnyModelsRepo() models.Repo { diff --git a/server/events/mocks/matchers/models_user.go b/server/events/mocks/matchers/models_user.go index 3f2b4d8c6d..484f36432f 100644 --- a/server/events/mocks/matchers/models_user.go +++ b/server/events/mocks/matchers/models_user.go @@ -3,8 +3,8 @@ package matchers import ( "reflect" + models "github.com/cloudposse/atlantis/server/events/models" "github.com/petergtz/pegomock" - models "github.com/runatlantis/atlantis/server/events/models" ) func AnyModelsUser() models.User { diff --git a/server/events/mocks/matchers/models_vcshosttype.go b/server/events/mocks/matchers/models_vcshosttype.go index e38331b62c..54f405e897 100644 --- a/server/events/mocks/matchers/models_vcshosttype.go +++ b/server/events/mocks/matchers/models_vcshosttype.go @@ -3,8 +3,8 @@ package matchers import ( "reflect" + models "github.com/cloudposse/atlantis/server/events/models" "github.com/petergtz/pegomock" - models "github.com/runatlantis/atlantis/server/events/models" ) func AnyModelsVCSHostType() models.VCSHostType { diff --git a/server/events/mocks/matchers/ptr_to_events_commandcontext.go b/server/events/mocks/matchers/ptr_to_events_commandcontext.go index 1b1134a343..c45da6832f 100644 --- a/server/events/mocks/matchers/ptr_to_events_commandcontext.go +++ b/server/events/mocks/matchers/ptr_to_events_commandcontext.go @@ -3,8 +3,8 @@ package matchers import ( "reflect" + events "github.com/cloudposse/atlantis/server/events" "github.com/petergtz/pegomock" - events "github.com/runatlantis/atlantis/server/events" ) func AnyPtrToEventsCommandContext() *events.CommandContext { diff --git a/server/events/mocks/matchers/ptr_to_events_commentcommand.go b/server/events/mocks/matchers/ptr_to_events_commentcommand.go index fbbbfcc15c..d86ed64f44 100644 --- a/server/events/mocks/matchers/ptr_to_events_commentcommand.go +++ b/server/events/mocks/matchers/ptr_to_events_commentcommand.go @@ -3,8 +3,8 @@ package matchers import ( "reflect" + events "github.com/cloudposse/atlantis/server/events" "github.com/petergtz/pegomock" - events "github.com/runatlantis/atlantis/server/events" ) func AnyPtrToEventsCommentCommand() *events.CommentCommand { diff --git a/server/events/mocks/matchers/ptr_to_events_trylockresponse.go b/server/events/mocks/matchers/ptr_to_events_trylockresponse.go index 14d747bb4a..668033ef74 100644 --- a/server/events/mocks/matchers/ptr_to_events_trylockresponse.go +++ b/server/events/mocks/matchers/ptr_to_events_trylockresponse.go @@ -3,8 +3,8 @@ package matchers import ( "reflect" + events "github.com/cloudposse/atlantis/server/events" "github.com/petergtz/pegomock" - events "github.com/runatlantis/atlantis/server/events" ) func AnyPtrToEventsTryLockResponse() *events.TryLockResponse { diff --git a/server/events/mocks/matchers/ptr_to_logging_simplelogger.go b/server/events/mocks/matchers/ptr_to_logging_simplelogger.go index 0889f65d58..027fa9663a 100644 --- a/server/events/mocks/matchers/ptr_to_logging_simplelogger.go +++ b/server/events/mocks/matchers/ptr_to_logging_simplelogger.go @@ -3,8 +3,8 @@ package matchers import ( "reflect" + logging "github.com/cloudposse/atlantis/server/logging" "github.com/petergtz/pegomock" - logging "github.com/runatlantis/atlantis/server/logging" ) func AnyPtrToLoggingSimpleLogger() *logging.SimpleLogger { diff --git a/server/events/mocks/matchers/ptr_to_models_pullrequest.go b/server/events/mocks/matchers/ptr_to_models_pullrequest.go index 6f31fdbd9c..f7d10d6874 100644 --- a/server/events/mocks/matchers/ptr_to_models_pullrequest.go +++ b/server/events/mocks/matchers/ptr_to_models_pullrequest.go @@ -3,8 +3,8 @@ package matchers import ( "reflect" + models "github.com/cloudposse/atlantis/server/events/models" "github.com/petergtz/pegomock" - models "github.com/runatlantis/atlantis/server/events/models" ) func AnyPtrToModelsPullRequest() *models.PullRequest { diff --git a/server/events/mocks/matchers/ptr_to_models_repo.go b/server/events/mocks/matchers/ptr_to_models_repo.go index 05ba1aef35..4ae849df88 100644 --- a/server/events/mocks/matchers/ptr_to_models_repo.go +++ b/server/events/mocks/matchers/ptr_to_models_repo.go @@ -3,8 +3,8 @@ package matchers import ( "reflect" + models "github.com/cloudposse/atlantis/server/events/models" "github.com/petergtz/pegomock" - models "github.com/runatlantis/atlantis/server/events/models" ) func AnyPtrToModelsRepo() *models.Repo { diff --git a/server/events/mocks/matchers/slice_of_models_project.go b/server/events/mocks/matchers/slice_of_models_project.go index 8a9d9c6200..b7284ff829 100644 --- a/server/events/mocks/matchers/slice_of_models_project.go +++ b/server/events/mocks/matchers/slice_of_models_project.go @@ -3,8 +3,8 @@ package matchers import ( "reflect" + models "github.com/cloudposse/atlantis/server/events/models" "github.com/petergtz/pegomock" - models "github.com/runatlantis/atlantis/server/events/models" ) func AnySliceOfModelsProject() []models.Project { diff --git a/server/events/mocks/matchers/slice_of_models_projectcommandcontext.go b/server/events/mocks/matchers/slice_of_models_projectcommandcontext.go index 08974c59cd..cb2e03ce57 100644 --- a/server/events/mocks/matchers/slice_of_models_projectcommandcontext.go +++ b/server/events/mocks/matchers/slice_of_models_projectcommandcontext.go @@ -3,8 +3,8 @@ package matchers import ( "reflect" + models "github.com/cloudposse/atlantis/server/events/models" "github.com/petergtz/pegomock" - models "github.com/runatlantis/atlantis/server/events/models" ) func AnySliceOfModelsProjectCommandContext() []models.ProjectCommandContext { diff --git a/server/events/mocks/matchers/vcs_commitstatus.go b/server/events/mocks/matchers/vcs_commitstatus.go index 9d253c6091..6c349876ca 100644 --- a/server/events/mocks/matchers/vcs_commitstatus.go +++ b/server/events/mocks/matchers/vcs_commitstatus.go @@ -3,8 +3,8 @@ package matchers import ( "reflect" + models "github.com/cloudposse/atlantis/server/events/models" "github.com/petergtz/pegomock" - models "github.com/runatlantis/atlantis/server/events/models" ) func AnyVcsCommitStatus() models.CommitStatus { diff --git a/server/events/mocks/matchers/webhooks_applyresult.go b/server/events/mocks/matchers/webhooks_applyresult.go index 2a643f6034..fc5f39e654 100644 --- a/server/events/mocks/matchers/webhooks_applyresult.go +++ b/server/events/mocks/matchers/webhooks_applyresult.go @@ -3,8 +3,8 @@ package matchers import ( "reflect" + webhooks "github.com/cloudposse/atlantis/server/events/webhooks" "github.com/petergtz/pegomock" - webhooks "github.com/runatlantis/atlantis/server/events/webhooks" ) func AnyWebhooksApplyResult() webhooks.ApplyResult { diff --git a/server/events/mocks/mock_command_runner.go b/server/events/mocks/mock_command_runner.go index 9c736abd96..25d7b3660b 100644 --- a/server/events/mocks/mock_command_runner.go +++ b/server/events/mocks/mock_command_runner.go @@ -6,9 +6,9 @@ package mocks import ( "reflect" + events "github.com/cloudposse/atlantis/server/events" + models "github.com/cloudposse/atlantis/server/events/models" pegomock "github.com/petergtz/pegomock" - events "github.com/runatlantis/atlantis/server/events" - models "github.com/runatlantis/atlantis/server/events/models" ) type MockCommandRunner struct { diff --git a/server/events/mocks/mock_comment_parsing.go b/server/events/mocks/mock_comment_parsing.go index fed14dc14a..61ad569d4a 100644 --- a/server/events/mocks/mock_comment_parsing.go +++ b/server/events/mocks/mock_comment_parsing.go @@ -6,9 +6,9 @@ package mocks import ( "reflect" + events "github.com/cloudposse/atlantis/server/events" + models "github.com/cloudposse/atlantis/server/events/models" pegomock "github.com/petergtz/pegomock" - events "github.com/runatlantis/atlantis/server/events" - models "github.com/runatlantis/atlantis/server/events/models" ) type MockCommentParsing struct { diff --git a/server/events/mocks/mock_commit_status_updater.go b/server/events/mocks/mock_commit_status_updater.go index 7997734b23..a1faa42169 100644 --- a/server/events/mocks/mock_commit_status_updater.go +++ b/server/events/mocks/mock_commit_status_updater.go @@ -6,9 +6,9 @@ package mocks import ( "reflect" + events "github.com/cloudposse/atlantis/server/events" + models "github.com/cloudposse/atlantis/server/events/models" pegomock "github.com/petergtz/pegomock" - events "github.com/runatlantis/atlantis/server/events" - models "github.com/runatlantis/atlantis/server/events/models" ) type MockCommitStatusUpdater struct { diff --git a/server/events/mocks/mock_event_parsing.go b/server/events/mocks/mock_event_parsing.go index e74e5707b4..af562b8299 100644 --- a/server/events/mocks/mock_event_parsing.go +++ b/server/events/mocks/mock_event_parsing.go @@ -6,10 +6,10 @@ package mocks import ( "reflect" + models "github.com/cloudposse/atlantis/server/events/models" github "github.com/google/go-github/github" go_gitlab "github.com/lkysow/go-gitlab" pegomock "github.com/petergtz/pegomock" - models "github.com/runatlantis/atlantis/server/events/models" ) type MockEventParsing struct { diff --git a/server/events/mocks/mock_github_pull_getter.go b/server/events/mocks/mock_github_pull_getter.go index 282bab182d..4062ea09e8 100644 --- a/server/events/mocks/mock_github_pull_getter.go +++ b/server/events/mocks/mock_github_pull_getter.go @@ -6,9 +6,9 @@ package mocks import ( "reflect" + models "github.com/cloudposse/atlantis/server/events/models" github "github.com/google/go-github/github" pegomock "github.com/petergtz/pegomock" - models "github.com/runatlantis/atlantis/server/events/models" ) type MockGithubPullGetter struct { diff --git a/server/events/mocks/mock_project_command_builder.go b/server/events/mocks/mock_project_command_builder.go index 236743e81f..46883894b2 100644 --- a/server/events/mocks/mock_project_command_builder.go +++ b/server/events/mocks/mock_project_command_builder.go @@ -6,9 +6,9 @@ package mocks import ( "reflect" + events "github.com/cloudposse/atlantis/server/events" + models "github.com/cloudposse/atlantis/server/events/models" pegomock "github.com/petergtz/pegomock" - events "github.com/runatlantis/atlantis/server/events" - models "github.com/runatlantis/atlantis/server/events/models" ) type MockProjectCommandBuilder struct { diff --git a/server/events/mocks/mock_project_command_runner.go b/server/events/mocks/mock_project_command_runner.go index 3f15b35fb4..c80f966afb 100644 --- a/server/events/mocks/mock_project_command_runner.go +++ b/server/events/mocks/mock_project_command_runner.go @@ -6,9 +6,9 @@ package mocks import ( "reflect" + events "github.com/cloudposse/atlantis/server/events" + models "github.com/cloudposse/atlantis/server/events/models" pegomock "github.com/petergtz/pegomock" - events "github.com/runatlantis/atlantis/server/events" - models "github.com/runatlantis/atlantis/server/events/models" ) type MockProjectCommandRunner struct { diff --git a/server/events/mocks/mock_project_lock.go b/server/events/mocks/mock_project_lock.go index b28b6d2206..c1e1baa633 100644 --- a/server/events/mocks/mock_project_lock.go +++ b/server/events/mocks/mock_project_lock.go @@ -6,10 +6,10 @@ package mocks import ( "reflect" + events "github.com/cloudposse/atlantis/server/events" + models "github.com/cloudposse/atlantis/server/events/models" + logging "github.com/cloudposse/atlantis/server/logging" pegomock "github.com/petergtz/pegomock" - events "github.com/runatlantis/atlantis/server/events" - models "github.com/runatlantis/atlantis/server/events/models" - logging "github.com/runatlantis/atlantis/server/logging" ) type MockProjectLocker struct { diff --git a/server/events/mocks/mock_pull_cleaner.go b/server/events/mocks/mock_pull_cleaner.go index c7930238e4..7c35746352 100644 --- a/server/events/mocks/mock_pull_cleaner.go +++ b/server/events/mocks/mock_pull_cleaner.go @@ -6,8 +6,8 @@ package mocks import ( "reflect" + models "github.com/cloudposse/atlantis/server/events/models" pegomock "github.com/petergtz/pegomock" - models "github.com/runatlantis/atlantis/server/events/models" ) type MockPullCleaner struct { diff --git a/server/events/mocks/mock_step_runner.go b/server/events/mocks/mock_step_runner.go index 5668e90ffd..dce8f6f95a 100644 --- a/server/events/mocks/mock_step_runner.go +++ b/server/events/mocks/mock_step_runner.go @@ -6,8 +6,8 @@ package mocks import ( "reflect" + models "github.com/cloudposse/atlantis/server/events/models" pegomock "github.com/petergtz/pegomock" - models "github.com/runatlantis/atlantis/server/events/models" ) type MockStepRunner struct { diff --git a/server/events/mocks/mock_webhooks_sender.go b/server/events/mocks/mock_webhooks_sender.go index dfd588807a..a9966e1bda 100644 --- a/server/events/mocks/mock_webhooks_sender.go +++ b/server/events/mocks/mock_webhooks_sender.go @@ -6,9 +6,9 @@ package mocks import ( "reflect" + webhooks "github.com/cloudposse/atlantis/server/events/webhooks" + logging "github.com/cloudposse/atlantis/server/logging" pegomock "github.com/petergtz/pegomock" - webhooks "github.com/runatlantis/atlantis/server/events/webhooks" - logging "github.com/runatlantis/atlantis/server/logging" ) type MockWebhooksSender struct { diff --git a/server/events/mocks/mock_working_dir.go b/server/events/mocks/mock_working_dir.go index 3f7b8f0e99..e86074a7e6 100644 --- a/server/events/mocks/mock_working_dir.go +++ b/server/events/mocks/mock_working_dir.go @@ -6,9 +6,9 @@ package mocks import ( "reflect" + models "github.com/cloudposse/atlantis/server/events/models" + logging "github.com/cloudposse/atlantis/server/logging" pegomock "github.com/petergtz/pegomock" - models "github.com/runatlantis/atlantis/server/events/models" - logging "github.com/runatlantis/atlantis/server/logging" ) type MockWorkingDir struct { diff --git a/server/events/models/commit_status_test.go b/server/events/models/commit_status_test.go index bd360db0c9..df4545727a 100644 --- a/server/events/models/commit_status_test.go +++ b/server/events/models/commit_status_test.go @@ -3,8 +3,8 @@ package models_test import ( "testing" - "github.com/runatlantis/atlantis/server/events/models" - . "github.com/runatlantis/atlantis/testing" + "github.com/cloudposse/atlantis/server/events/models" + . "github.com/cloudposse/atlantis/testing" ) func TestStatus_String(t *testing.T) { diff --git a/server/events/models/fixtures/fixtures.go b/server/events/models/fixtures/fixtures.go index 5c06663a98..159af4876a 100644 --- a/server/events/models/fixtures/fixtures.go +++ b/server/events/models/fixtures/fixtures.go @@ -13,7 +13,7 @@ package fixtures -import "github.com/runatlantis/atlantis/server/events/models" +import "github.com/cloudposse/atlantis/server/events/models" var Pull = models.PullRequest{ Num: 1, diff --git a/server/events/models/models.go b/server/events/models/models.go index b95172e0e1..49edacd466 100644 --- a/server/events/models/models.go +++ b/server/events/models/models.go @@ -23,9 +23,9 @@ import ( "strings" "time" + "github.com/cloudposse/atlantis/server/events/yaml/valid" + "github.com/cloudposse/atlantis/server/logging" "github.com/pkg/errors" - "github.com/runatlantis/atlantis/server/events/yaml/valid" - "github.com/runatlantis/atlantis/server/logging" ) // Repo is a VCS repository. diff --git a/server/events/models/models_test.go b/server/events/models/models_test.go index 054d1a3145..38c8127bd1 100644 --- a/server/events/models/models_test.go +++ b/server/events/models/models_test.go @@ -17,8 +17,8 @@ import ( "fmt" "testing" - "github.com/runatlantis/atlantis/server/events/models" - . "github.com/runatlantis/atlantis/testing" + "github.com/cloudposse/atlantis/server/events/models" + . "github.com/cloudposse/atlantis/testing" ) func TestNewRepo_EmptyRepoFullName(t *testing.T) { diff --git a/server/events/pending_plan_finder_test.go b/server/events/pending_plan_finder_test.go index b513f64c01..13968673de 100644 --- a/server/events/pending_plan_finder_test.go +++ b/server/events/pending_plan_finder_test.go @@ -6,8 +6,8 @@ import ( "strings" "testing" - "github.com/runatlantis/atlantis/server/events" - . "github.com/runatlantis/atlantis/testing" + "github.com/cloudposse/atlantis/server/events" + . "github.com/cloudposse/atlantis/testing" ) // If the dir doesn't exist should get an error. diff --git a/server/events/project_command_builder.go b/server/events/project_command_builder.go index 9160588ea8..4fcd4bec5e 100644 --- a/server/events/project_command_builder.go +++ b/server/events/project_command_builder.go @@ -3,13 +3,13 @@ package events import ( "fmt" + "github.com/cloudposse/atlantis/server/events/models" + "github.com/cloudposse/atlantis/server/events/vcs" + "github.com/cloudposse/atlantis/server/events/yaml" + "github.com/cloudposse/atlantis/server/events/yaml/valid" + "github.com/cloudposse/atlantis/server/logging" "github.com/hashicorp/go-version" "github.com/pkg/errors" - "github.com/runatlantis/atlantis/server/events/models" - "github.com/runatlantis/atlantis/server/events/vcs" - "github.com/runatlantis/atlantis/server/events/yaml" - "github.com/runatlantis/atlantis/server/events/yaml/valid" - "github.com/runatlantis/atlantis/server/logging" ) const ( diff --git a/server/events/project_command_builder_test.go b/server/events/project_command_builder_test.go index a73b6692cb..dafc052ba4 100644 --- a/server/events/project_command_builder_test.go +++ b/server/events/project_command_builder_test.go @@ -5,16 +5,16 @@ import ( "path/filepath" "testing" + "github.com/cloudposse/atlantis/server/events" + "github.com/cloudposse/atlantis/server/events/mocks" + "github.com/cloudposse/atlantis/server/events/mocks/matchers" + "github.com/cloudposse/atlantis/server/events/models" + vcsmocks "github.com/cloudposse/atlantis/server/events/vcs/mocks" + "github.com/cloudposse/atlantis/server/events/yaml" + "github.com/cloudposse/atlantis/server/events/yaml/valid" + "github.com/cloudposse/atlantis/server/logging" + . "github.com/cloudposse/atlantis/testing" . "github.com/petergtz/pegomock" - "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/models" - vcsmocks "github.com/runatlantis/atlantis/server/events/vcs/mocks" - "github.com/runatlantis/atlantis/server/events/yaml" - "github.com/runatlantis/atlantis/server/events/yaml/valid" - "github.com/runatlantis/atlantis/server/logging" - . "github.com/runatlantis/atlantis/testing" ) func TestDefaultProjectCommandBuilder_BuildAutoplanCommands(t *testing.T) { diff --git a/server/events/project_command_runner.go b/server/events/project_command_runner.go index 04f07c0cce..d8858e7772 100644 --- a/server/events/project_command_runner.go +++ b/server/events/project_command_runner.go @@ -19,13 +19,13 @@ import ( "path/filepath" "strings" + "github.com/cloudposse/atlantis/server/events/models" + "github.com/cloudposse/atlantis/server/events/runtime" + "github.com/cloudposse/atlantis/server/events/webhooks" + "github.com/cloudposse/atlantis/server/events/yaml/raw" + "github.com/cloudposse/atlantis/server/events/yaml/valid" + "github.com/cloudposse/atlantis/server/logging" "github.com/pkg/errors" - "github.com/runatlantis/atlantis/server/events/models" - "github.com/runatlantis/atlantis/server/events/runtime" - "github.com/runatlantis/atlantis/server/events/webhooks" - "github.com/runatlantis/atlantis/server/events/yaml/raw" - "github.com/runatlantis/atlantis/server/events/yaml/valid" - "github.com/runatlantis/atlantis/server/logging" ) //go:generate pegomock generate -m --use-experimental-model-gen --package mocks -o mocks/mock_lock_url_generator.go LockURLGenerator diff --git a/server/events/project_command_runner_test.go b/server/events/project_command_runner_test.go index d2d02bfdf6..bb69a251b1 100644 --- a/server/events/project_command_runner_test.go +++ b/server/events/project_command_runner_test.go @@ -18,15 +18,15 @@ import ( "strings" "testing" + "github.com/cloudposse/atlantis/server/events" + "github.com/cloudposse/atlantis/server/events/mocks" + "github.com/cloudposse/atlantis/server/events/mocks/matchers" + "github.com/cloudposse/atlantis/server/events/models" + mocks2 "github.com/cloudposse/atlantis/server/events/runtime/mocks" + "github.com/cloudposse/atlantis/server/events/yaml/valid" + "github.com/cloudposse/atlantis/server/logging" + . "github.com/cloudposse/atlantis/testing" . "github.com/petergtz/pegomock" - "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/models" - mocks2 "github.com/runatlantis/atlantis/server/events/runtime/mocks" - "github.com/runatlantis/atlantis/server/events/yaml/valid" - "github.com/runatlantis/atlantis/server/logging" - . "github.com/runatlantis/atlantis/testing" ) func TestDefaultProjectCommandRunner_Plan(t *testing.T) { diff --git a/server/events/project_finder.go b/server/events/project_finder.go index f9605612ed..1b45f90a34 100644 --- a/server/events/project_finder.go +++ b/server/events/project_finder.go @@ -19,11 +19,11 @@ import ( "path/filepath" "strings" + "github.com/cloudposse/atlantis/server/events/models" + "github.com/cloudposse/atlantis/server/events/yaml/valid" + "github.com/cloudposse/atlantis/server/logging" "github.com/docker/docker/pkg/fileutils" "github.com/pkg/errors" - "github.com/runatlantis/atlantis/server/events/models" - "github.com/runatlantis/atlantis/server/events/yaml/valid" - "github.com/runatlantis/atlantis/server/logging" ) // ProjectFinder determines what are the terraform project(s) within a repo. diff --git a/server/events/project_finder_test.go b/server/events/project_finder_test.go index 034701f669..2a19bc1df3 100644 --- a/server/events/project_finder_test.go +++ b/server/events/project_finder_test.go @@ -19,10 +19,10 @@ import ( "path/filepath" "testing" - "github.com/runatlantis/atlantis/server/events" - "github.com/runatlantis/atlantis/server/events/yaml/valid" - "github.com/runatlantis/atlantis/server/logging" - . "github.com/runatlantis/atlantis/testing" + "github.com/cloudposse/atlantis/server/events" + "github.com/cloudposse/atlantis/server/events/yaml/valid" + "github.com/cloudposse/atlantis/server/logging" + . "github.com/cloudposse/atlantis/testing" ) var noopLogger = logging.NewNoopLogger() diff --git a/server/events/project_locker.go b/server/events/project_locker.go index d3fe6735fe..8a93afa350 100644 --- a/server/events/project_locker.go +++ b/server/events/project_locker.go @@ -16,9 +16,9 @@ package events import ( "fmt" - "github.com/runatlantis/atlantis/server/events/locking" - "github.com/runatlantis/atlantis/server/events/models" - "github.com/runatlantis/atlantis/server/logging" + "github.com/cloudposse/atlantis/server/events/locking" + "github.com/cloudposse/atlantis/server/events/models" + "github.com/cloudposse/atlantis/server/logging" ) //go:generate pegomock generate -m --use-experimental-model-gen --package mocks -o mocks/mock_project_lock.go ProjectLocker diff --git a/server/events/project_locker_test.go b/server/events/project_locker_test.go index 3dc0db9375..0ad8375ca9 100644 --- a/server/events/project_locker_test.go +++ b/server/events/project_locker_test.go @@ -16,13 +16,13 @@ package events_test import ( "testing" + "github.com/cloudposse/atlantis/server/events" + "github.com/cloudposse/atlantis/server/events/locking" + "github.com/cloudposse/atlantis/server/events/locking/mocks" + "github.com/cloudposse/atlantis/server/events/models" + "github.com/cloudposse/atlantis/server/logging" + . "github.com/cloudposse/atlantis/testing" . "github.com/petergtz/pegomock" - "github.com/runatlantis/atlantis/server/events" - "github.com/runatlantis/atlantis/server/events/locking" - "github.com/runatlantis/atlantis/server/events/locking/mocks" - "github.com/runatlantis/atlantis/server/events/models" - "github.com/runatlantis/atlantis/server/logging" - . "github.com/runatlantis/atlantis/testing" ) func TestDefaultProjectLocker_TryLockWhenLocked(t *testing.T) { diff --git a/server/events/project_result.go b/server/events/project_result.go index 5efc429997..b6f554b3c2 100644 --- a/server/events/project_result.go +++ b/server/events/project_result.go @@ -14,7 +14,7 @@ package events import ( - "github.com/runatlantis/atlantis/server/events/models" + "github.com/cloudposse/atlantis/server/events/models" ) // ProjectResult is the result of executing a plan/apply for a specific project. diff --git a/server/events/pull_closed_executor.go b/server/events/pull_closed_executor.go index 8792face08..bc0a21b3c9 100644 --- a/server/events/pull_closed_executor.go +++ b/server/events/pull_closed_executor.go @@ -20,10 +20,10 @@ import ( "strings" "text/template" + "github.com/cloudposse/atlantis/server/events/locking" + "github.com/cloudposse/atlantis/server/events/models" + "github.com/cloudposse/atlantis/server/events/vcs" "github.com/pkg/errors" - "github.com/runatlantis/atlantis/server/events/locking" - "github.com/runatlantis/atlantis/server/events/models" - "github.com/runatlantis/atlantis/server/events/vcs" ) //go:generate pegomock generate -m --use-experimental-model-gen --package mocks -o mocks/mock_pull_cleaner.go PullCleaner diff --git a/server/events/pull_closed_executor_test.go b/server/events/pull_closed_executor_test.go index c1c353b0b1..8225966d49 100644 --- a/server/events/pull_closed_executor_test.go +++ b/server/events/pull_closed_executor_test.go @@ -17,15 +17,15 @@ import ( "errors" "testing" + "github.com/cloudposse/atlantis/server/events" + lockmocks "github.com/cloudposse/atlantis/server/events/locking/mocks" + "github.com/cloudposse/atlantis/server/events/mocks" + "github.com/cloudposse/atlantis/server/events/mocks/matchers" + "github.com/cloudposse/atlantis/server/events/models" + "github.com/cloudposse/atlantis/server/events/models/fixtures" + vcsmocks "github.com/cloudposse/atlantis/server/events/vcs/mocks" + . "github.com/cloudposse/atlantis/testing" . "github.com/petergtz/pegomock" - "github.com/runatlantis/atlantis/server/events" - lockmocks "github.com/runatlantis/atlantis/server/events/locking/mocks" - "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/models/fixtures" - vcsmocks "github.com/runatlantis/atlantis/server/events/vcs/mocks" - . "github.com/runatlantis/atlantis/testing" ) func TestCleanUpPullWorkspaceErr(t *testing.T) { diff --git a/server/events/repo_whitelist_checker_test.go b/server/events/repo_whitelist_checker_test.go index 4df1e12feb..ac6e5fa842 100644 --- a/server/events/repo_whitelist_checker_test.go +++ b/server/events/repo_whitelist_checker_test.go @@ -16,8 +16,8 @@ package events_test import ( "testing" - "github.com/runatlantis/atlantis/server/events" - . "github.com/runatlantis/atlantis/testing" + "github.com/cloudposse/atlantis/server/events" + . "github.com/cloudposse/atlantis/testing" ) func TestRepoWhitelistChecker_IsWhitelisted(t *testing.T) { diff --git a/server/events/runtime/apply_step_runner.go b/server/events/runtime/apply_step_runner.go index 509aa68fcd..0b1a39450f 100644 --- a/server/events/runtime/apply_step_runner.go +++ b/server/events/runtime/apply_step_runner.go @@ -5,8 +5,8 @@ import ( "os" "path/filepath" + "github.com/cloudposse/atlantis/server/events/models" "github.com/hashicorp/go-version" - "github.com/runatlantis/atlantis/server/events/models" ) // ApplyStepRunner runs `terraform apply`. diff --git a/server/events/runtime/apply_step_runner_test.go b/server/events/runtime/apply_step_runner_test.go index f699f4ff3a..9f61aba1ef 100644 --- a/server/events/runtime/apply_step_runner_test.go +++ b/server/events/runtime/apply_step_runner_test.go @@ -7,15 +7,15 @@ import ( "path/filepath" "testing" + "github.com/cloudposse/atlantis/server/events/mocks/matchers" + "github.com/cloudposse/atlantis/server/events/models" + "github.com/cloudposse/atlantis/server/events/runtime" + "github.com/cloudposse/atlantis/server/events/terraform/mocks" + matchers2 "github.com/cloudposse/atlantis/server/events/terraform/mocks/matchers" + "github.com/cloudposse/atlantis/server/events/yaml/valid" + . "github.com/cloudposse/atlantis/testing" "github.com/hashicorp/go-version" . "github.com/petergtz/pegomock" - "github.com/runatlantis/atlantis/server/events/mocks/matchers" - "github.com/runatlantis/atlantis/server/events/models" - "github.com/runatlantis/atlantis/server/events/runtime" - "github.com/runatlantis/atlantis/server/events/terraform/mocks" - matchers2 "github.com/runatlantis/atlantis/server/events/terraform/mocks/matchers" - "github.com/runatlantis/atlantis/server/events/yaml/valid" - . "github.com/runatlantis/atlantis/testing" ) func TestRun_NoDir(t *testing.T) { diff --git a/server/events/runtime/init_step_runner.go b/server/events/runtime/init_step_runner.go index b15e9de17a..f78d1bcd28 100644 --- a/server/events/runtime/init_step_runner.go +++ b/server/events/runtime/init_step_runner.go @@ -1,8 +1,8 @@ package runtime import ( + "github.com/cloudposse/atlantis/server/events/models" "github.com/hashicorp/go-version" - "github.com/runatlantis/atlantis/server/events/models" ) // InitStep runs `terraform init`. diff --git a/server/events/runtime/init_step_runner_test.go b/server/events/runtime/init_step_runner_test.go index 88538bcace..49949385e5 100644 --- a/server/events/runtime/init_step_runner_test.go +++ b/server/events/runtime/init_step_runner_test.go @@ -3,15 +3,15 @@ package runtime_test import ( "testing" + "github.com/cloudposse/atlantis/server/events/mocks/matchers" + "github.com/cloudposse/atlantis/server/events/models" + "github.com/cloudposse/atlantis/server/events/runtime" + "github.com/cloudposse/atlantis/server/events/terraform/mocks" + matchers2 "github.com/cloudposse/atlantis/server/events/terraform/mocks/matchers" + . "github.com/cloudposse/atlantis/testing" version "github.com/hashicorp/go-version" . "github.com/petergtz/pegomock" "github.com/pkg/errors" - "github.com/runatlantis/atlantis/server/events/mocks/matchers" - "github.com/runatlantis/atlantis/server/events/models" - "github.com/runatlantis/atlantis/server/events/runtime" - "github.com/runatlantis/atlantis/server/events/terraform/mocks" - matchers2 "github.com/runatlantis/atlantis/server/events/terraform/mocks/matchers" - . "github.com/runatlantis/atlantis/testing" ) func TestRun_UsesGetOrInitForRightVersion(t *testing.T) { diff --git a/server/events/runtime/mocks/matchers/models_pullrequest.go b/server/events/runtime/mocks/matchers/models_pullrequest.go index d8b146baa4..3b0b7b3178 100644 --- a/server/events/runtime/mocks/matchers/models_pullrequest.go +++ b/server/events/runtime/mocks/matchers/models_pullrequest.go @@ -3,8 +3,8 @@ package matchers import ( "reflect" + models "github.com/cloudposse/atlantis/server/events/models" "github.com/petergtz/pegomock" - models "github.com/runatlantis/atlantis/server/events/models" ) func AnyModelsPullRequest() models.PullRequest { diff --git a/server/events/runtime/mocks/matchers/models_repo.go b/server/events/runtime/mocks/matchers/models_repo.go index 3f8e699ebe..a813489d6e 100644 --- a/server/events/runtime/mocks/matchers/models_repo.go +++ b/server/events/runtime/mocks/matchers/models_repo.go @@ -3,8 +3,8 @@ package matchers import ( "reflect" + models "github.com/cloudposse/atlantis/server/events/models" "github.com/petergtz/pegomock" - models "github.com/runatlantis/atlantis/server/events/models" ) func AnyModelsRepo() models.Repo { diff --git a/server/events/runtime/mocks/mock_pull_approved_checker.go b/server/events/runtime/mocks/mock_pull_approved_checker.go index 69f1e4a502..623d5a9f12 100644 --- a/server/events/runtime/mocks/mock_pull_approved_checker.go +++ b/server/events/runtime/mocks/mock_pull_approved_checker.go @@ -6,8 +6,8 @@ package mocks import ( "reflect" + models "github.com/cloudposse/atlantis/server/events/models" pegomock "github.com/petergtz/pegomock" - models "github.com/runatlantis/atlantis/server/events/models" ) type MockPullApprovedChecker struct { diff --git a/server/events/runtime/plan_step_runner.go b/server/events/runtime/plan_step_runner.go index 90215af824..6e5634bb60 100644 --- a/server/events/runtime/plan_step_runner.go +++ b/server/events/runtime/plan_step_runner.go @@ -6,8 +6,8 @@ import ( "path/filepath" "strings" + "github.com/cloudposse/atlantis/server/events/models" "github.com/hashicorp/go-version" - "github.com/runatlantis/atlantis/server/events/models" ) const defaultWorkspace = "default" diff --git a/server/events/runtime/plan_step_runner_test.go b/server/events/runtime/plan_step_runner_test.go index a91e075481..d42833eb65 100644 --- a/server/events/runtime/plan_step_runner_test.go +++ b/server/events/runtime/plan_step_runner_test.go @@ -7,17 +7,17 @@ import ( "path/filepath" "testing" + "github.com/cloudposse/atlantis/server/events/mocks/matchers" + "github.com/cloudposse/atlantis/server/events/models" + "github.com/cloudposse/atlantis/server/events/runtime" + "github.com/cloudposse/atlantis/server/events/terraform/mocks" + matchers2 "github.com/cloudposse/atlantis/server/events/terraform/mocks/matchers" + "github.com/cloudposse/atlantis/server/events/yaml/valid" + "github.com/cloudposse/atlantis/server/logging" + . "github.com/cloudposse/atlantis/testing" "github.com/hashicorp/go-version" . "github.com/petergtz/pegomock" "github.com/pkg/errors" - "github.com/runatlantis/atlantis/server/events/mocks/matchers" - "github.com/runatlantis/atlantis/server/events/models" - "github.com/runatlantis/atlantis/server/events/runtime" - "github.com/runatlantis/atlantis/server/events/terraform/mocks" - matchers2 "github.com/runatlantis/atlantis/server/events/terraform/mocks/matchers" - "github.com/runatlantis/atlantis/server/events/yaml/valid" - "github.com/runatlantis/atlantis/server/logging" - . "github.com/runatlantis/atlantis/testing" ) func TestRun_NoWorkspaceIn08(t *testing.T) { diff --git a/server/events/runtime/pull_approved_checker.go b/server/events/runtime/pull_approved_checker.go index e77aa2acb1..129d01c3b7 100644 --- a/server/events/runtime/pull_approved_checker.go +++ b/server/events/runtime/pull_approved_checker.go @@ -1,7 +1,7 @@ package runtime import ( - "github.com/runatlantis/atlantis/server/events/models" + "github.com/cloudposse/atlantis/server/events/models" ) //go:generate pegomock generate -m --use-experimental-model-gen --package mocks -o mocks/mock_pull_approved_checker.go PullApprovedChecker diff --git a/server/events/runtime/run_step_runner.go b/server/events/runtime/run_step_runner.go index c8b88d7c1f..88382018f5 100644 --- a/server/events/runtime/run_step_runner.go +++ b/server/events/runtime/run_step_runner.go @@ -7,9 +7,9 @@ import ( "path/filepath" "strings" + "github.com/cloudposse/atlantis/server/events/models" "github.com/hashicorp/go-version" "github.com/pkg/errors" - "github.com/runatlantis/atlantis/server/events/models" ) // RunStepRunner runs custom commands. diff --git a/server/events/runtime/run_step_runner_test.go b/server/events/runtime/run_step_runner_test.go index bf41847e8b..dd65d9aad6 100644 --- a/server/events/runtime/run_step_runner_test.go +++ b/server/events/runtime/run_step_runner_test.go @@ -4,12 +4,12 @@ import ( "strings" "testing" + "github.com/cloudposse/atlantis/server/events/models" + "github.com/cloudposse/atlantis/server/events/runtime" + "github.com/cloudposse/atlantis/server/events/yaml/valid" + "github.com/cloudposse/atlantis/server/logging" + . "github.com/cloudposse/atlantis/testing" "github.com/hashicorp/go-version" - "github.com/runatlantis/atlantis/server/events/models" - "github.com/runatlantis/atlantis/server/events/runtime" - "github.com/runatlantis/atlantis/server/events/yaml/valid" - "github.com/runatlantis/atlantis/server/logging" - . "github.com/runatlantis/atlantis/testing" ) func TestRunStepRunner_Run(t *testing.T) { diff --git a/server/events/runtime/runtime.go b/server/events/runtime/runtime.go index 1e00a46a30..1e911a1579 100644 --- a/server/events/runtime/runtime.go +++ b/server/events/runtime/runtime.go @@ -5,9 +5,9 @@ package runtime import ( "fmt" + "github.com/cloudposse/atlantis/server/events/yaml/valid" + "github.com/cloudposse/atlantis/server/logging" "github.com/hashicorp/go-version" - "github.com/runatlantis/atlantis/server/events/yaml/valid" - "github.com/runatlantis/atlantis/server/logging" ) type TerraformExec interface { diff --git a/server/events/runtime/runtime_test.go b/server/events/runtime/runtime_test.go index 7925c8fa2c..c7befe0b9a 100644 --- a/server/events/runtime/runtime_test.go +++ b/server/events/runtime/runtime_test.go @@ -4,9 +4,9 @@ import ( "fmt" "testing" - "github.com/runatlantis/atlantis/server/events/runtime" - "github.com/runatlantis/atlantis/server/events/yaml/valid" - . "github.com/runatlantis/atlantis/testing" + "github.com/cloudposse/atlantis/server/events/runtime" + "github.com/cloudposse/atlantis/server/events/yaml/valid" + . "github.com/cloudposse/atlantis/testing" ) func TestGetPlanFilename(t *testing.T) { diff --git a/server/events/team_whitelist_checker.go b/server/events/team_whitelist_checker.go new file mode 100644 index 0000000000..9ac9880465 --- /dev/null +++ b/server/events/team_whitelist_checker.go @@ -0,0 +1,70 @@ +package events + +import ( + "strings" +) + +// Wildcard matches all teams and all commands +const wildcard = "*" + +// mapOfStrings is an alias for map[string]string +type mapOfStrings map[string]string + +// TeamWhitelistChecker implements checking the teams and the operations that the members +// of a particular team are allowed to perform +type TeamWhitelistChecker struct { + rules []mapOfStrings +} + +// NewTeamWhitelistChecker constructs a new checker +func NewTeamWhitelistChecker(whitelist string) (*TeamWhitelistChecker, error) { + var rules []mapOfStrings + pairs := strings.Split(whitelist, ",") + for _, pair := range pairs { + values := strings.Split(pair, ":") + team := strings.TrimSpace(values[0]) + command := strings.TrimSpace(values[1]) + m := mapOfStrings{team: command} + rules = append(rules, m) + } + return &TeamWhitelistChecker{ + rules: rules, + }, nil +} + +// IsCommandAllowedForTeam returns true if the team is allowed to execute the command +// and false otherwise. +func (checker *TeamWhitelistChecker) IsCommandAllowedForTeam(team string, command string) bool { + t := strings.TrimSpace(team) + c := strings.TrimSpace(command) + for _, rule := range checker.rules { + for key, value := range rule { + if (key == wildcard || strings.EqualFold(key, t)) && (value == wildcard || strings.EqualFold(value, c)) { + return true + } + } + } + return false +} + +// IsCommandAllowedForAnyTeam returns true if any of the teams is allowed to execute the command +// and false otherwise. +func (checker *TeamWhitelistChecker) IsCommandAllowedForAnyTeam(teams []string, command string) bool { + c := strings.TrimSpace(command) + if teams == nil || len(teams) == 0 { + for _, rule := range checker.rules { + for key, value := range rule { + if (key == wildcard) && (value == wildcard || strings.EqualFold(value, c)) { + return true + } + } + } + } else { + for _, t := range teams { + if checker.IsCommandAllowedForTeam(t, command) { + return true + } + } + } + return false +} diff --git a/server/events/terraform/mocks/matchers/ptr_to_logging_simplelogger.go b/server/events/terraform/mocks/matchers/ptr_to_logging_simplelogger.go index 0889f65d58..027fa9663a 100644 --- a/server/events/terraform/mocks/matchers/ptr_to_logging_simplelogger.go +++ b/server/events/terraform/mocks/matchers/ptr_to_logging_simplelogger.go @@ -3,8 +3,8 @@ package matchers import ( "reflect" + logging "github.com/cloudposse/atlantis/server/logging" "github.com/petergtz/pegomock" - logging "github.com/runatlantis/atlantis/server/logging" ) func AnyPtrToLoggingSimpleLogger() *logging.SimpleLogger { diff --git a/server/events/terraform/mocks/mock_terraform_client.go b/server/events/terraform/mocks/mock_terraform_client.go index f7e47cf06a..ec6259bfd4 100644 --- a/server/events/terraform/mocks/mock_terraform_client.go +++ b/server/events/terraform/mocks/mock_terraform_client.go @@ -6,9 +6,9 @@ package mocks import ( "reflect" + logging "github.com/cloudposse/atlantis/server/logging" go_version "github.com/hashicorp/go-version" pegomock "github.com/petergtz/pegomock" - logging "github.com/runatlantis/atlantis/server/logging" ) type MockClient struct { diff --git a/server/events/terraform/terraform_client.go b/server/events/terraform/terraform_client.go index cab3baaefb..3bd3c78f71 100644 --- a/server/events/terraform/terraform_client.go +++ b/server/events/terraform/terraform_client.go @@ -22,9 +22,9 @@ import ( "regexp" "strings" + "github.com/cloudposse/atlantis/server/logging" "github.com/hashicorp/go-version" "github.com/pkg/errors" - "github.com/runatlantis/atlantis/server/logging" ) //go:generate pegomock generate -m --use-experimental-model-gen --package mocks -o mocks/mock_terraform_client.go Client diff --git a/server/events/terraform/terraform_client_test.go b/server/events/terraform/terraform_client_test.go index 00126ad493..c569932f4c 100644 --- a/server/events/terraform/terraform_client_test.go +++ b/server/events/terraform/terraform_client_test.go @@ -16,9 +16,9 @@ package terraform_test import ( "testing" + "github.com/cloudposse/atlantis/server/events/terraform" + . "github.com/cloudposse/atlantis/testing" "github.com/hashicorp/go-version" - "github.com/runatlantis/atlantis/server/events/terraform" - . "github.com/runatlantis/atlantis/testing" ) func TestMustConstraint_PancisOnBadConstraint(t *testing.T) { diff --git a/server/events/vcs/bitbucketcloud/client.go b/server/events/vcs/bitbucketcloud/client.go index 81272f1f11..2d770103e6 100644 --- a/server/events/vcs/bitbucketcloud/client.go +++ b/server/events/vcs/bitbucketcloud/client.go @@ -8,8 +8,8 @@ import ( "io/ioutil" "net/http" + "github.com/cloudposse/atlantis/server/events/models" "github.com/pkg/errors" - "github.com/runatlantis/atlantis/server/events/models" "gopkg.in/go-playground/validator.v9" ) @@ -181,3 +181,8 @@ func (b *Client) makeRequest(method string, path string, reqBody io.Reader) ([]b } return respBody, nil } + +// GetTeamNamesForUser returns the names of the teams or groups that the user belongs to (in the organization the repository belongs to). +func (g *Client) GetTeamNamesForUser(repo models.Repo, user models.User) ([]string, error) { + return nil, nil +} diff --git a/server/events/vcs/bitbucketcloud/client_test.go b/server/events/vcs/bitbucketcloud/client_test.go index f05ef9bf76..adb21b0d73 100644 --- a/server/events/vcs/bitbucketcloud/client_test.go +++ b/server/events/vcs/bitbucketcloud/client_test.go @@ -8,9 +8,9 @@ import ( "path/filepath" "testing" - "github.com/runatlantis/atlantis/server/events/models" - "github.com/runatlantis/atlantis/server/events/vcs/bitbucketcloud" - . "github.com/runatlantis/atlantis/testing" + "github.com/cloudposse/atlantis/server/events/models" + "github.com/cloudposse/atlantis/server/events/vcs/bitbucketcloud" + . "github.com/cloudposse/atlantis/testing" ) // Should follow pagination properly. diff --git a/server/events/vcs/bitbucketserver/client.go b/server/events/vcs/bitbucketserver/client.go index d9a3668f01..9e78794fd4 100644 --- a/server/events/vcs/bitbucketserver/client.go +++ b/server/events/vcs/bitbucketserver/client.go @@ -11,8 +11,8 @@ import ( "regexp" "strings" + "github.com/cloudposse/atlantis/server/events/models" "github.com/pkg/errors" - "github.com/runatlantis/atlantis/server/events/models" "gopkg.in/go-playground/validator.v9" ) @@ -220,3 +220,8 @@ func (b *Client) makeRequest(method string, path string, reqBody io.Reader) ([]b } return respBody, nil } + +// GetTeamNamesForUser returns the names of the teams or groups that the user belongs to (in the organization the repository belongs to). +func (g *Client) GetTeamNamesForUser(repo models.Repo, user models.User) ([]string, error) { + return nil, nil +} diff --git a/server/events/vcs/bitbucketserver/client_test.go b/server/events/vcs/bitbucketserver/client_test.go index 810017854a..e3faeb3bbb 100644 --- a/server/events/vcs/bitbucketserver/client_test.go +++ b/server/events/vcs/bitbucketserver/client_test.go @@ -7,10 +7,10 @@ import ( "strings" "testing" - "github.com/runatlantis/atlantis/server/events/models" - "github.com/runatlantis/atlantis/server/events/vcs/bitbucketcloud" - "github.com/runatlantis/atlantis/server/events/vcs/bitbucketserver" - . "github.com/runatlantis/atlantis/testing" + "github.com/cloudposse/atlantis/server/events/models" + "github.com/cloudposse/atlantis/server/events/vcs/bitbucketcloud" + "github.com/cloudposse/atlantis/server/events/vcs/bitbucketserver" + . "github.com/cloudposse/atlantis/testing" ) // Should follow pagination properly. diff --git a/server/events/vcs/bitbucketserver/request_validation_test.go b/server/events/vcs/bitbucketserver/request_validation_test.go index 9b9d5228a4..9dc44fcd56 100644 --- a/server/events/vcs/bitbucketserver/request_validation_test.go +++ b/server/events/vcs/bitbucketserver/request_validation_test.go @@ -3,8 +3,8 @@ package bitbucketserver_test import ( "testing" - "github.com/runatlantis/atlantis/server/events/vcs/bitbucketserver" - . "github.com/runatlantis/atlantis/testing" + "github.com/cloudposse/atlantis/server/events/vcs/bitbucketserver" + . "github.com/cloudposse/atlantis/testing" ) func TestValidateSignature(t *testing.T) { diff --git a/server/events/vcs/client.go b/server/events/vcs/client.go index 583206bb95..f4c3fd6854 100644 --- a/server/events/vcs/client.go +++ b/server/events/vcs/client.go @@ -14,7 +14,7 @@ package vcs import ( - "github.com/runatlantis/atlantis/server/events/models" + "github.com/cloudposse/atlantis/server/events/models" ) //go:generate pegomock generate -m --use-experimental-model-gen --package mocks -o mocks/mock_client.go Client @@ -25,4 +25,5 @@ type Client interface { CreateComment(repo models.Repo, pullNum int, comment string) error PullIsApproved(repo models.Repo, pull models.PullRequest) (bool, error) UpdateStatus(repo models.Repo, pull models.PullRequest, state models.CommitStatus, description string) error + GetTeamNamesForUser(repo models.Repo, user models.User) ([]string, error) } diff --git a/server/events/vcs/github_client.go b/server/events/vcs/github_client.go index 3e1e6a82c8..45b3c33abe 100644 --- a/server/events/vcs/github_client.go +++ b/server/events/vcs/github_client.go @@ -20,9 +20,9 @@ import ( "net/url" "strings" + "github.com/cloudposse/atlantis/server/events/models" "github.com/google/go-github/github" "github.com/pkg/errors" - "github.com/runatlantis/atlantis/server/events/models" ) // maxCommentBodySize is derived from the error message when you go over @@ -178,3 +178,30 @@ func (g *GithubClient) min(a, b int) int { } return b } + +// GetTeamNamesForUser returns the names of the teams or groups that the user belongs to (in the organization the repository belongs to). +func (g *GithubClient) GetTeamNamesForUser(repo models.Repo, user models.User) ([]string, error) { + var teamNames []string + opts := &github.ListOptions{} + org := repo.Owner + for { + teams, resp, err := g.client.Organizations.ListTeams(g.ctx, org, opts) + if err != nil { + return nil, err + } + for _, t := range teams { + ok, _, err := g.client.Organizations.IsTeamMember(g.ctx, t.GetID(), user.Username) + if err != nil { + return nil, err + } + if ok { + teamNames = append(teamNames, t.GetName()) + } + } + if resp.NextPage == 0 { + break + } + opts.Page = resp.NextPage + } + return teamNames, nil +} diff --git a/server/events/vcs/github_client_internal_test.go b/server/events/vcs/github_client_internal_test.go index 9d3205fc89..c6a2018ba2 100644 --- a/server/events/vcs/github_client_internal_test.go +++ b/server/events/vcs/github_client_internal_test.go @@ -16,7 +16,7 @@ package vcs import ( "testing" - . "github.com/runatlantis/atlantis/testing" + . "github.com/cloudposse/atlantis/testing" ) func TestSplitAtMaxChars(t *testing.T) { diff --git a/server/events/vcs/github_client_test.go b/server/events/vcs/github_client_test.go index 7fc7ecd19e..c5332e219a 100644 --- a/server/events/vcs/github_client_test.go +++ b/server/events/vcs/github_client_test.go @@ -9,9 +9,9 @@ import ( "net/url" "testing" - "github.com/runatlantis/atlantis/server/events/models" - "github.com/runatlantis/atlantis/server/events/vcs" - . "github.com/runatlantis/atlantis/testing" + "github.com/cloudposse/atlantis/server/events/models" + "github.com/cloudposse/atlantis/server/events/vcs" + . "github.com/cloudposse/atlantis/testing" ) // GetModifiedFiles should make multiple requests if more than one page diff --git a/server/events/vcs/gitlab_client.go b/server/events/vcs/gitlab_client.go index 6563bd4b21..58976b45f5 100644 --- a/server/events/vcs/gitlab_client.go +++ b/server/events/vcs/gitlab_client.go @@ -17,8 +17,8 @@ import ( "fmt" "net/url" + "github.com/cloudposse/atlantis/server/events/models" "github.com/lkysow/go-gitlab" - "github.com/runatlantis/atlantis/server/events/models" ) type GitlabClient struct { @@ -103,3 +103,8 @@ func (g *GitlabClient) GetMergeRequest(repoFullName string, pullNum int) (*gitla mr, _, err := g.Client.MergeRequests.GetMergeRequest(repoFullName, pullNum) return mr, err } + +// GetTeamNamesForUser returns the names of the teams or groups that the user belongs to (in the organization the repository belongs to). +func (g *GitlabClient) GetTeamNamesForUser(repo models.Repo, user models.User) ([]string, error) { + return nil, nil +} diff --git a/server/events/vcs/mocks/matchers/models_pullrequest.go b/server/events/vcs/mocks/matchers/models_pullrequest.go index d8b146baa4..3b0b7b3178 100644 --- a/server/events/vcs/mocks/matchers/models_pullrequest.go +++ b/server/events/vcs/mocks/matchers/models_pullrequest.go @@ -3,8 +3,8 @@ package matchers import ( "reflect" + models "github.com/cloudposse/atlantis/server/events/models" "github.com/petergtz/pegomock" - models "github.com/runatlantis/atlantis/server/events/models" ) func AnyModelsPullRequest() models.PullRequest { diff --git a/server/events/vcs/mocks/matchers/models_repo.go b/server/events/vcs/mocks/matchers/models_repo.go index 3f8e699ebe..a813489d6e 100644 --- a/server/events/vcs/mocks/matchers/models_repo.go +++ b/server/events/vcs/mocks/matchers/models_repo.go @@ -3,8 +3,8 @@ package matchers import ( "reflect" + models "github.com/cloudposse/atlantis/server/events/models" "github.com/petergtz/pegomock" - models "github.com/runatlantis/atlantis/server/events/models" ) func AnyModelsRepo() models.Repo { diff --git a/server/events/vcs/mocks/matchers/vcs_commitstatus.go b/server/events/vcs/mocks/matchers/vcs_commitstatus.go index 9d253c6091..6c349876ca 100644 --- a/server/events/vcs/mocks/matchers/vcs_commitstatus.go +++ b/server/events/vcs/mocks/matchers/vcs_commitstatus.go @@ -3,8 +3,8 @@ package matchers import ( "reflect" + models "github.com/cloudposse/atlantis/server/events/models" "github.com/petergtz/pegomock" - models "github.com/runatlantis/atlantis/server/events/models" ) func AnyVcsCommitStatus() models.CommitStatus { diff --git a/server/events/vcs/mocks/mock_client.go b/server/events/vcs/mocks/mock_client.go index 0836a52f5e..89b3efe6a2 100644 --- a/server/events/vcs/mocks/mock_client.go +++ b/server/events/vcs/mocks/mock_client.go @@ -6,8 +6,8 @@ package mocks import ( "reflect" + models "github.com/cloudposse/atlantis/server/events/models" pegomock "github.com/petergtz/pegomock" - models "github.com/runatlantis/atlantis/server/events/models" ) type MockClient struct { diff --git a/server/events/vcs/mocks/mock_proxy.go b/server/events/vcs/mocks/mock_proxy.go index 764ee32c2a..58a417b2d5 100644 --- a/server/events/vcs/mocks/mock_proxy.go +++ b/server/events/vcs/mocks/mock_proxy.go @@ -6,8 +6,8 @@ package mocks import ( "reflect" + models "github.com/cloudposse/atlantis/server/events/models" pegomock "github.com/petergtz/pegomock" - models "github.com/runatlantis/atlantis/server/events/models" ) type MockClientProxy struct { diff --git a/server/events/vcs/not_configured_vcs_client.go b/server/events/vcs/not_configured_vcs_client.go index a2381de263..d226205c43 100644 --- a/server/events/vcs/not_configured_vcs_client.go +++ b/server/events/vcs/not_configured_vcs_client.go @@ -16,7 +16,7 @@ package vcs import ( "fmt" - "github.com/runatlantis/atlantis/server/events/models" + "github.com/cloudposse/atlantis/server/events/models" ) // NotConfiguredVCSClient is used as a placeholder when Atlantis isn't configured @@ -38,6 +38,9 @@ func (a *NotConfiguredVCSClient) PullIsApproved(repo models.Repo, pull models.Pu func (a *NotConfiguredVCSClient) UpdateStatus(repo models.Repo, pull models.PullRequest, state models.CommitStatus, description string) error { return a.err() } +func (a *NotConfiguredVCSClient) GetTeamNamesForUser(repo models.Repo, user models.User) ([]string, error) { + return nil, a.err() +} func (a *NotConfiguredVCSClient) err() error { //noinspection GoErrorStringFormat return fmt.Errorf("Atlantis was not configured to support repos from %s", a.Host.String()) diff --git a/server/events/vcs/proxy.go b/server/events/vcs/proxy.go index e981ee2a4e..0692c20e1e 100644 --- a/server/events/vcs/proxy.go +++ b/server/events/vcs/proxy.go @@ -14,7 +14,7 @@ package vcs import ( - "github.com/runatlantis/atlantis/server/events/models" + "github.com/cloudposse/atlantis/server/events/models" ) //go:generate pegomock generate -m --use-experimental-model-gen --package mocks -o mocks/mock_proxy.go ClientProxy @@ -26,6 +26,7 @@ type ClientProxy interface { CreateComment(repo models.Repo, pullNum int, comment string) error PullIsApproved(repo models.Repo, pull models.PullRequest) (bool, error) UpdateStatus(repo models.Repo, pull models.PullRequest, state models.CommitStatus, description string) error + GetTeamNamesForUser(repo models.Repo, user models.User) ([]string, error) } // DefaultClientProxy proxies calls to the correct VCS client depending on which @@ -74,3 +75,7 @@ func (d *DefaultClientProxy) PullIsApproved(repo models.Repo, pull models.PullRe func (d *DefaultClientProxy) UpdateStatus(repo models.Repo, pull models.PullRequest, state models.CommitStatus, description string) error { return d.clients[repo.VCSHost.Type].UpdateStatus(repo, pull, state, description) } + +func (d *DefaultClientProxy) GetTeamNamesForUser(repo models.Repo, user models.User) ([]string, error) { + return d.clients[repo.VCSHost.Type].GetTeamNamesForUser(repo, user) +} diff --git a/server/events/webhooks/mocks/matchers/ptr_to_logging_simplelogger.go b/server/events/webhooks/mocks/matchers/ptr_to_logging_simplelogger.go index 0889f65d58..027fa9663a 100644 --- a/server/events/webhooks/mocks/matchers/ptr_to_logging_simplelogger.go +++ b/server/events/webhooks/mocks/matchers/ptr_to_logging_simplelogger.go @@ -3,8 +3,8 @@ package matchers import ( "reflect" + logging "github.com/cloudposse/atlantis/server/logging" "github.com/petergtz/pegomock" - logging "github.com/runatlantis/atlantis/server/logging" ) func AnyPtrToLoggingSimpleLogger() *logging.SimpleLogger { diff --git a/server/events/webhooks/mocks/matchers/webhooks_applyresult.go b/server/events/webhooks/mocks/matchers/webhooks_applyresult.go index 2a643f6034..fc5f39e654 100644 --- a/server/events/webhooks/mocks/matchers/webhooks_applyresult.go +++ b/server/events/webhooks/mocks/matchers/webhooks_applyresult.go @@ -3,8 +3,8 @@ package matchers import ( "reflect" + webhooks "github.com/cloudposse/atlantis/server/events/webhooks" "github.com/petergtz/pegomock" - webhooks "github.com/runatlantis/atlantis/server/events/webhooks" ) func AnyWebhooksApplyResult() webhooks.ApplyResult { diff --git a/server/events/webhooks/mocks/mock_sender.go b/server/events/webhooks/mocks/mock_sender.go index 3fb89620c7..de4c034e6d 100644 --- a/server/events/webhooks/mocks/mock_sender.go +++ b/server/events/webhooks/mocks/mock_sender.go @@ -6,9 +6,9 @@ package mocks import ( "reflect" + webhooks "github.com/cloudposse/atlantis/server/events/webhooks" + logging "github.com/cloudposse/atlantis/server/logging" pegomock "github.com/petergtz/pegomock" - webhooks "github.com/runatlantis/atlantis/server/events/webhooks" - logging "github.com/runatlantis/atlantis/server/logging" ) type MockSender struct { diff --git a/server/events/webhooks/mocks/mock_slack_client.go b/server/events/webhooks/mocks/mock_slack_client.go index 7737dbd1bd..735d1b58bc 100644 --- a/server/events/webhooks/mocks/mock_slack_client.go +++ b/server/events/webhooks/mocks/mock_slack_client.go @@ -6,8 +6,8 @@ package mocks import ( "reflect" + webhooks "github.com/cloudposse/atlantis/server/events/webhooks" pegomock "github.com/petergtz/pegomock" - webhooks "github.com/runatlantis/atlantis/server/events/webhooks" ) type MockSlackClient struct { diff --git a/server/events/webhooks/slack.go b/server/events/webhooks/slack.go index 7e943c1ef0..b8e3a6e45f 100644 --- a/server/events/webhooks/slack.go +++ b/server/events/webhooks/slack.go @@ -18,8 +18,8 @@ import ( "fmt" + "github.com/cloudposse/atlantis/server/logging" "github.com/pkg/errors" - "github.com/runatlantis/atlantis/server/logging" ) // SlackWebhook sends webhooks to Slack. diff --git a/server/events/webhooks/slack_client_test.go b/server/events/webhooks/slack_client_test.go index 8f4bf12bf7..986456db70 100644 --- a/server/events/webhooks/slack_client_test.go +++ b/server/events/webhooks/slack_client_test.go @@ -18,13 +18,13 @@ import ( "errors" "testing" + "github.com/cloudposse/atlantis/server/events/models" + "github.com/cloudposse/atlantis/server/events/webhooks" + "github.com/cloudposse/atlantis/server/events/webhooks/mocks" "github.com/nlopes/slack" - "github.com/runatlantis/atlantis/server/events/models" - "github.com/runatlantis/atlantis/server/events/webhooks" - "github.com/runatlantis/atlantis/server/events/webhooks/mocks" + . "github.com/cloudposse/atlantis/testing" . "github.com/petergtz/pegomock" - . "github.com/runatlantis/atlantis/testing" ) var underlying *mocks.MockUnderlyingSlackClient diff --git a/server/events/webhooks/slack_test.go b/server/events/webhooks/slack_test.go index fbb89f9317..9df2d7c02c 100644 --- a/server/events/webhooks/slack_test.go +++ b/server/events/webhooks/slack_test.go @@ -17,11 +17,11 @@ import ( "regexp" "testing" + "github.com/cloudposse/atlantis/server/events/webhooks" + "github.com/cloudposse/atlantis/server/events/webhooks/mocks" + "github.com/cloudposse/atlantis/server/logging" + . "github.com/cloudposse/atlantis/testing" . "github.com/petergtz/pegomock" - "github.com/runatlantis/atlantis/server/events/webhooks" - "github.com/runatlantis/atlantis/server/events/webhooks/mocks" - "github.com/runatlantis/atlantis/server/logging" - . "github.com/runatlantis/atlantis/testing" ) func TestSend_PostMessage(t *testing.T) { diff --git a/server/events/webhooks/webhooks.go b/server/events/webhooks/webhooks.go index f9f1cf9b80..d47d4fbd99 100644 --- a/server/events/webhooks/webhooks.go +++ b/server/events/webhooks/webhooks.go @@ -19,8 +19,8 @@ import ( "errors" - "github.com/runatlantis/atlantis/server/events/models" - "github.com/runatlantis/atlantis/server/logging" + "github.com/cloudposse/atlantis/server/events/models" + "github.com/cloudposse/atlantis/server/logging" ) const SlackKind = "slack" diff --git a/server/events/webhooks/webhooks_test.go b/server/events/webhooks/webhooks_test.go index 138a27869c..ebd7a27506 100644 --- a/server/events/webhooks/webhooks_test.go +++ b/server/events/webhooks/webhooks_test.go @@ -17,11 +17,11 @@ import ( "strings" "testing" + "github.com/cloudposse/atlantis/server/events/webhooks" + "github.com/cloudposse/atlantis/server/events/webhooks/mocks" + "github.com/cloudposse/atlantis/server/logging" + . "github.com/cloudposse/atlantis/testing" . "github.com/petergtz/pegomock" - "github.com/runatlantis/atlantis/server/events/webhooks" - "github.com/runatlantis/atlantis/server/events/webhooks/mocks" - "github.com/runatlantis/atlantis/server/logging" - . "github.com/runatlantis/atlantis/testing" ) const ( diff --git a/server/events/working_dir.go b/server/events/working_dir.go index b00ab31af3..9d68020381 100644 --- a/server/events/working_dir.go +++ b/server/events/working_dir.go @@ -20,9 +20,9 @@ import ( "strconv" "strings" + "github.com/cloudposse/atlantis/server/events/models" + "github.com/cloudposse/atlantis/server/logging" "github.com/pkg/errors" - "github.com/runatlantis/atlantis/server/events/models" - "github.com/runatlantis/atlantis/server/logging" ) const workingDirPrefix = "repos" diff --git a/server/events/working_dir_locker_test.go b/server/events/working_dir_locker_test.go index eee4c0f196..9ddd37570e 100644 --- a/server/events/working_dir_locker_test.go +++ b/server/events/working_dir_locker_test.go @@ -16,8 +16,8 @@ package events_test import ( "testing" - "github.com/runatlantis/atlantis/server/events" - . "github.com/runatlantis/atlantis/testing" + "github.com/cloudposse/atlantis/server/events" + . "github.com/cloudposse/atlantis/testing" ) var repo = "repo/owner" diff --git a/server/events/yaml/mocks/matchers/valid_spec.go b/server/events/yaml/mocks/matchers/valid_spec.go index 9c60066733..9e7d6be7db 100644 --- a/server/events/yaml/mocks/matchers/valid_spec.go +++ b/server/events/yaml/mocks/matchers/valid_spec.go @@ -3,8 +3,8 @@ package matchers import ( "reflect" + valid "github.com/cloudposse/atlantis/server/events/yaml/valid" "github.com/petergtz/pegomock" - valid "github.com/runatlantis/atlantis/server/events/yaml/valid" ) func AnyValidConfig() valid.Config { diff --git a/server/events/yaml/mocks/mock_parser_validator.go b/server/events/yaml/mocks/mock_parser_validator.go index 24655f8715..7a96ebd4a4 100644 --- a/server/events/yaml/mocks/mock_parser_validator.go +++ b/server/events/yaml/mocks/mock_parser_validator.go @@ -6,8 +6,8 @@ package mocks import ( "reflect" + valid "github.com/cloudposse/atlantis/server/events/yaml/valid" pegomock "github.com/petergtz/pegomock" - valid "github.com/runatlantis/atlantis/server/events/yaml/valid" ) type MockParserValidator struct { diff --git a/server/events/yaml/parser_validator.go b/server/events/yaml/parser_validator.go index 14917753af..42fc51dea9 100644 --- a/server/events/yaml/parser_validator.go +++ b/server/events/yaml/parser_validator.go @@ -6,10 +6,10 @@ import ( "os" "path/filepath" + "github.com/cloudposse/atlantis/server/events/yaml/raw" + "github.com/cloudposse/atlantis/server/events/yaml/valid" "github.com/go-ozzo/ozzo-validation" "github.com/pkg/errors" - "github.com/runatlantis/atlantis/server/events/yaml/raw" - "github.com/runatlantis/atlantis/server/events/yaml/valid" "gopkg.in/yaml.v2" ) diff --git a/server/events/yaml/parser_validator_test.go b/server/events/yaml/parser_validator_test.go index a47db640b5..0e13bcadf1 100644 --- a/server/events/yaml/parser_validator_test.go +++ b/server/events/yaml/parser_validator_test.go @@ -6,10 +6,10 @@ import ( "path/filepath" "testing" + "github.com/cloudposse/atlantis/server/events/yaml" + "github.com/cloudposse/atlantis/server/events/yaml/valid" + . "github.com/cloudposse/atlantis/testing" "github.com/hashicorp/go-version" - "github.com/runatlantis/atlantis/server/events/yaml" - "github.com/runatlantis/atlantis/server/events/yaml/valid" - . "github.com/runatlantis/atlantis/testing" ) func TestReadConfig_DirDoesNotExist(t *testing.T) { diff --git a/server/events/yaml/raw/autoplan.go b/server/events/yaml/raw/autoplan.go index 00ce47fd63..37c259e349 100644 --- a/server/events/yaml/raw/autoplan.go +++ b/server/events/yaml/raw/autoplan.go @@ -1,6 +1,6 @@ package raw -import "github.com/runatlantis/atlantis/server/events/yaml/valid" +import "github.com/cloudposse/atlantis/server/events/yaml/valid" const DefaultAutoPlanWhenModified = "**/*.tf*" const DefaultAutoPlanEnabled = true diff --git a/server/events/yaml/raw/autoplan_test.go b/server/events/yaml/raw/autoplan_test.go index 224ca959b4..47b62df207 100644 --- a/server/events/yaml/raw/autoplan_test.go +++ b/server/events/yaml/raw/autoplan_test.go @@ -3,9 +3,9 @@ package raw_test import ( "testing" - "github.com/runatlantis/atlantis/server/events/yaml/raw" - "github.com/runatlantis/atlantis/server/events/yaml/valid" - . "github.com/runatlantis/atlantis/testing" + "github.com/cloudposse/atlantis/server/events/yaml/raw" + "github.com/cloudposse/atlantis/server/events/yaml/valid" + . "github.com/cloudposse/atlantis/testing" "gopkg.in/yaml.v2" ) diff --git a/server/events/yaml/raw/config.go b/server/events/yaml/raw/config.go index 218e02e608..ad71509acb 100644 --- a/server/events/yaml/raw/config.go +++ b/server/events/yaml/raw/config.go @@ -3,8 +3,8 @@ package raw import ( "errors" + "github.com/cloudposse/atlantis/server/events/yaml/valid" "github.com/go-ozzo/ozzo-validation" - "github.com/runatlantis/atlantis/server/events/yaml/valid" ) // Config is the representation for the whole config file at the top level. diff --git a/server/events/yaml/raw/config_test.go b/server/events/yaml/raw/config_test.go index 73d6eaf543..84d6248290 100644 --- a/server/events/yaml/raw/config_test.go +++ b/server/events/yaml/raw/config_test.go @@ -3,10 +3,10 @@ package raw_test import ( "testing" + "github.com/cloudposse/atlantis/server/events/yaml/raw" + "github.com/cloudposse/atlantis/server/events/yaml/valid" + . "github.com/cloudposse/atlantis/testing" "github.com/go-ozzo/ozzo-validation" - "github.com/runatlantis/atlantis/server/events/yaml/raw" - "github.com/runatlantis/atlantis/server/events/yaml/valid" - . "github.com/runatlantis/atlantis/testing" "gopkg.in/yaml.v2" ) diff --git a/server/events/yaml/raw/project.go b/server/events/yaml/raw/project.go index 863995238d..fc8bb24e78 100644 --- a/server/events/yaml/raw/project.go +++ b/server/events/yaml/raw/project.go @@ -5,10 +5,10 @@ import ( "path/filepath" "strings" + "github.com/cloudposse/atlantis/server/events/yaml/valid" "github.com/go-ozzo/ozzo-validation" "github.com/hashicorp/go-version" "github.com/pkg/errors" - "github.com/runatlantis/atlantis/server/events/yaml/valid" ) const ( diff --git a/server/events/yaml/raw/project_test.go b/server/events/yaml/raw/project_test.go index b2ac198f90..e84a8f524f 100644 --- a/server/events/yaml/raw/project_test.go +++ b/server/events/yaml/raw/project_test.go @@ -3,11 +3,11 @@ package raw_test import ( "testing" + "github.com/cloudposse/atlantis/server/events/yaml/raw" + "github.com/cloudposse/atlantis/server/events/yaml/valid" + . "github.com/cloudposse/atlantis/testing" "github.com/go-ozzo/ozzo-validation" "github.com/hashicorp/go-version" - "github.com/runatlantis/atlantis/server/events/yaml/raw" - "github.com/runatlantis/atlantis/server/events/yaml/valid" - . "github.com/runatlantis/atlantis/testing" "gopkg.in/yaml.v2" ) diff --git a/server/events/yaml/raw/stage.go b/server/events/yaml/raw/stage.go index 67eef1d3be..a84eeac191 100644 --- a/server/events/yaml/raw/stage.go +++ b/server/events/yaml/raw/stage.go @@ -1,8 +1,8 @@ package raw import ( + "github.com/cloudposse/atlantis/server/events/yaml/valid" "github.com/go-ozzo/ozzo-validation" - "github.com/runatlantis/atlantis/server/events/yaml/valid" ) type Stage struct { diff --git a/server/events/yaml/raw/stage_test.go b/server/events/yaml/raw/stage_test.go index 245ed2c4f3..17e6247038 100644 --- a/server/events/yaml/raw/stage_test.go +++ b/server/events/yaml/raw/stage_test.go @@ -3,10 +3,10 @@ package raw_test import ( "testing" + "github.com/cloudposse/atlantis/server/events/yaml/raw" + "github.com/cloudposse/atlantis/server/events/yaml/valid" + . "github.com/cloudposse/atlantis/testing" "github.com/go-ozzo/ozzo-validation" - "github.com/runatlantis/atlantis/server/events/yaml/raw" - "github.com/runatlantis/atlantis/server/events/yaml/valid" - . "github.com/runatlantis/atlantis/testing" "gopkg.in/yaml.v2" ) diff --git a/server/events/yaml/raw/step.go b/server/events/yaml/raw/step.go index b095f60087..7007f48ded 100644 --- a/server/events/yaml/raw/step.go +++ b/server/events/yaml/raw/step.go @@ -6,9 +6,9 @@ import ( "sort" "strings" + "github.com/cloudposse/atlantis/server/events/yaml/valid" "github.com/flynn-archive/go-shlex" "github.com/go-ozzo/ozzo-validation" - "github.com/runatlantis/atlantis/server/events/yaml/valid" ) const ( diff --git a/server/events/yaml/raw/step_test.go b/server/events/yaml/raw/step_test.go index ec8a5d4934..6c5575c1c4 100644 --- a/server/events/yaml/raw/step_test.go +++ b/server/events/yaml/raw/step_test.go @@ -3,9 +3,9 @@ package raw_test import ( "testing" - "github.com/runatlantis/atlantis/server/events/yaml/raw" - "github.com/runatlantis/atlantis/server/events/yaml/valid" - . "github.com/runatlantis/atlantis/testing" + "github.com/cloudposse/atlantis/server/events/yaml/raw" + "github.com/cloudposse/atlantis/server/events/yaml/valid" + . "github.com/cloudposse/atlantis/testing" "gopkg.in/yaml.v2" ) diff --git a/server/events/yaml/raw/workflow.go b/server/events/yaml/raw/workflow.go index 1a6dc73245..a00af68d4d 100644 --- a/server/events/yaml/raw/workflow.go +++ b/server/events/yaml/raw/workflow.go @@ -1,8 +1,8 @@ package raw import ( + "github.com/cloudposse/atlantis/server/events/yaml/valid" "github.com/go-ozzo/ozzo-validation" - "github.com/runatlantis/atlantis/server/events/yaml/valid" ) type Workflow struct { diff --git a/server/events/yaml/raw/workflow_test.go b/server/events/yaml/raw/workflow_test.go index 85320cfaad..40956925f1 100644 --- a/server/events/yaml/raw/workflow_test.go +++ b/server/events/yaml/raw/workflow_test.go @@ -3,10 +3,10 @@ package raw_test import ( "testing" + "github.com/cloudposse/atlantis/server/events/yaml/raw" + "github.com/cloudposse/atlantis/server/events/yaml/valid" + . "github.com/cloudposse/atlantis/testing" "github.com/go-ozzo/ozzo-validation" - "github.com/runatlantis/atlantis/server/events/yaml/raw" - "github.com/runatlantis/atlantis/server/events/yaml/valid" - . "github.com/runatlantis/atlantis/testing" "gopkg.in/yaml.v2" ) diff --git a/server/events_controller.go b/server/events_controller.go index 14643a7ebf..6c1f870b68 100644 --- a/server/events_controller.go +++ b/server/events_controller.go @@ -18,15 +18,15 @@ import ( "io/ioutil" "net/http" + "github.com/cloudposse/atlantis/server/events" + "github.com/cloudposse/atlantis/server/events/models" + "github.com/cloudposse/atlantis/server/events/vcs" + "github.com/cloudposse/atlantis/server/events/vcs/bitbucketcloud" + "github.com/cloudposse/atlantis/server/events/vcs/bitbucketserver" + "github.com/cloudposse/atlantis/server/logging" "github.com/google/go-github/github" "github.com/lkysow/go-gitlab" "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" ) const githubHeader = "X-Github-Event" @@ -57,6 +57,7 @@ type EventsController struct { // request validation is done. GitlabWebhookSecret []byte RepoWhitelistChecker *events.RepoWhitelistChecker + TeamWhitelistChecker *events.TeamWhitelistChecker // SupportedVCSHosts is which VCS hosts Atlantis was configured upon // startup to support. SupportedVCSHosts []models.VCSHostType @@ -372,6 +373,18 @@ func (e *EventsController) handleCommentEvent(w http.ResponseWriter, baseRepo mo return } + // Check if the user who commented has the permissions to execute the 'plan' or 'apply' commands + ok, err := e.checkUserPermissions(baseRepo, user, parseResult.Command) + if err != nil { + e.Logger.Err("unable to comment on pull request: %s", err) + return + } + if !ok { + e.commentUserDoesNotHavePermissions(baseRepo, pullNum, user, parseResult.Command) + e.respond(w, logging.Warn, http.StatusForbidden, "User @%s does not have permissions to execute '%s' command", user.Username, parseResult.Command.Name.String()) + return + } + e.Logger.Debug("executing command") fmt.Fprintln(w, "Processing...") if !e.TestingMode { @@ -423,3 +436,27 @@ func (e *EventsController) commentNotWhitelisted(baseRepo models.Repo, pullNum i e.Logger.Err("unable to comment on pull request: %s", err) } } + +// commentUserDoesNotHavePermissions comments on the pull request that the user +// is not allowed to execute the command. +func (e *EventsController) commentUserDoesNotHavePermissions(baseRepo models.Repo, pullNum int, user models.User, cmd *events.CommentCommand) { + errMsg := fmt.Sprintf("```\nError: User @%s does not have permissions to execute '%s' command.\n```", user.Username, cmd.Name) + if err := e.VCSClient.CreateComment(baseRepo, pullNum, errMsg); err != nil { + e.Logger.Err("unable to comment on pull request: %s", err) + } +} + +// checkUserPermissions checks if the user has permissions to execute the command +func (e *EventsController) checkUserPermissions(repo models.Repo, user models.User, cmd *events.CommentCommand) (bool, error) { + if cmd.Name == events.ApplyCommand || cmd.Name == events.PlanCommand { + teams, err := e.VCSClient.GetTeamNamesForUser(repo, user) + if err != nil { + return false, err + } + ok := e.TeamWhitelistChecker.IsCommandAllowedForAnyTeam(teams, cmd.Name.String()) + if !ok { + return false, nil + } + } + return true, nil +} diff --git a/server/events_controller_e2e_test.go b/server/events_controller_e2e_test.go index c5c899699c..b22ad1ace4 100644 --- a/server/events_controller_e2e_test.go +++ b/server/events_controller_e2e_test.go @@ -13,22 +13,22 @@ import ( "strings" "testing" + "github.com/cloudposse/atlantis/server" + "github.com/cloudposse/atlantis/server/events" + "github.com/cloudposse/atlantis/server/events/locking" + "github.com/cloudposse/atlantis/server/events/locking/boltdb" + "github.com/cloudposse/atlantis/server/events/mocks" + "github.com/cloudposse/atlantis/server/events/mocks/matchers" + "github.com/cloudposse/atlantis/server/events/models" + "github.com/cloudposse/atlantis/server/events/runtime" + "github.com/cloudposse/atlantis/server/events/terraform" + vcsmocks "github.com/cloudposse/atlantis/server/events/vcs/mocks" + "github.com/cloudposse/atlantis/server/events/webhooks" + "github.com/cloudposse/atlantis/server/events/yaml" + "github.com/cloudposse/atlantis/server/logging" + . "github.com/cloudposse/atlantis/testing" "github.com/google/go-github/github" . "github.com/petergtz/pegomock" - "github.com/runatlantis/atlantis/server" - "github.com/runatlantis/atlantis/server/events" - "github.com/runatlantis/atlantis/server/events/locking" - "github.com/runatlantis/atlantis/server/events/locking/boltdb" - "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/runtime" - "github.com/runatlantis/atlantis/server/events/terraform" - vcsmocks "github.com/runatlantis/atlantis/server/events/vcs/mocks" - "github.com/runatlantis/atlantis/server/events/webhooks" - "github.com/runatlantis/atlantis/server/events/yaml" - "github.com/runatlantis/atlantis/server/logging" - . "github.com/runatlantis/atlantis/testing" ) func TestGitHubWorkflow(t *testing.T) { diff --git a/server/events_controller_test.go b/server/events_controller_test.go index 9adce2518f..b13a0dbc10 100644 --- a/server/events_controller_test.go +++ b/server/events_controller_test.go @@ -25,17 +25,17 @@ import ( "testing" "time" + "github.com/cloudposse/atlantis/server" + "github.com/cloudposse/atlantis/server/events" + emocks "github.com/cloudposse/atlantis/server/events/mocks" + "github.com/cloudposse/atlantis/server/events/mocks/matchers" + "github.com/cloudposse/atlantis/server/events/models" + vcsmocks "github.com/cloudposse/atlantis/server/events/vcs/mocks" + "github.com/cloudposse/atlantis/server/logging" + "github.com/cloudposse/atlantis/server/mocks" + . "github.com/cloudposse/atlantis/testing" "github.com/lkysow/go-gitlab" . "github.com/petergtz/pegomock" - "github.com/runatlantis/atlantis/server" - "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" ) const githubHeader = "X-Github-Event" diff --git a/server/github_request_validator_test.go b/server/github_request_validator_test.go index 0f2338810c..02ed4fa8bb 100644 --- a/server/github_request_validator_test.go +++ b/server/github_request_validator_test.go @@ -19,9 +19,9 @@ import ( "net/url" "testing" + "github.com/cloudposse/atlantis/server" + . "github.com/cloudposse/atlantis/testing" . "github.com/petergtz/pegomock" - "github.com/runatlantis/atlantis/server" - . "github.com/runatlantis/atlantis/testing" ) func TestValidate_WithSecretErr(t *testing.T) { diff --git a/server/gitlab_request_parser_validator_test.go b/server/gitlab_request_parser_validator_test.go index f1d63fe4af..adb5b1cb22 100644 --- a/server/gitlab_request_parser_validator_test.go +++ b/server/gitlab_request_parser_validator_test.go @@ -18,10 +18,10 @@ import ( "net/http" "testing" + "github.com/cloudposse/atlantis/server" + . "github.com/cloudposse/atlantis/testing" "github.com/lkysow/go-gitlab" . "github.com/petergtz/pegomock" - "github.com/runatlantis/atlantis/server" - . "github.com/runatlantis/atlantis/testing" ) var parser = server.DefaultGitlabRequestParserValidator{} diff --git a/server/locks_controller.go b/server/locks_controller.go index 8000e9984e..1f0b185917 100644 --- a/server/locks_controller.go +++ b/server/locks_controller.go @@ -5,12 +5,12 @@ import ( "net/http" "net/url" + "github.com/cloudposse/atlantis/server/events" + "github.com/cloudposse/atlantis/server/events/locking" + "github.com/cloudposse/atlantis/server/events/models" + "github.com/cloudposse/atlantis/server/events/vcs" + "github.com/cloudposse/atlantis/server/logging" "github.com/gorilla/mux" - "github.com/runatlantis/atlantis/server/events" - "github.com/runatlantis/atlantis/server/events/locking" - "github.com/runatlantis/atlantis/server/events/models" - "github.com/runatlantis/atlantis/server/events/vcs" - "github.com/runatlantis/atlantis/server/logging" ) // LocksController handles all requests relating to Atlantis locks. diff --git a/server/locks_controller_test.go b/server/locks_controller_test.go index ce6929e49e..83b01b75c1 100644 --- a/server/locks_controller_test.go +++ b/server/locks_controller_test.go @@ -8,16 +8,16 @@ import ( "reflect" "testing" + "github.com/cloudposse/atlantis/server" + "github.com/cloudposse/atlantis/server/events" + "github.com/cloudposse/atlantis/server/events/locking/mocks" + mocks2 "github.com/cloudposse/atlantis/server/events/mocks" + "github.com/cloudposse/atlantis/server/events/models" + vcsmocks "github.com/cloudposse/atlantis/server/events/vcs/mocks" + "github.com/cloudposse/atlantis/server/logging" + sMocks "github.com/cloudposse/atlantis/server/mocks" "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" - mocks2 "github.com/runatlantis/atlantis/server/events/mocks" - "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" ) func AnyRepo() models.Repo { diff --git a/server/logging/mocks/matchers/logging_loglevel.go b/server/logging/mocks/matchers/logging_loglevel.go index b68e39881c..a80692da44 100644 --- a/server/logging/mocks/matchers/logging_loglevel.go +++ b/server/logging/mocks/matchers/logging_loglevel.go @@ -3,8 +3,8 @@ package matchers import ( "reflect" + logging "github.com/cloudposse/atlantis/server/logging" "github.com/petergtz/pegomock" - logging "github.com/runatlantis/atlantis/server/logging" ) func AnyLoggingLogLevel() logging.LogLevel { diff --git a/server/logging/mocks/mock_simple_logging.go b/server/logging/mocks/mock_simple_logging.go index 262b01dc58..6b407e88fa 100644 --- a/server/logging/mocks/mock_simple_logging.go +++ b/server/logging/mocks/mock_simple_logging.go @@ -7,8 +7,8 @@ import ( log "log" "reflect" + logging "github.com/cloudposse/atlantis/server/logging" pegomock "github.com/petergtz/pegomock" - logging "github.com/runatlantis/atlantis/server/logging" ) type MockSimpleLogging struct { diff --git a/server/middleware.go b/server/middleware.go index d75a62c1b3..bb7b41c995 100644 --- a/server/middleware.go +++ b/server/middleware.go @@ -17,7 +17,7 @@ import ( "net/http" "strings" - "github.com/runatlantis/atlantis/server/logging" + "github.com/cloudposse/atlantis/server/logging" "github.com/urfave/negroni" ) diff --git a/server/router_test.go b/server/router_test.go index 91bf9f3fc9..c1e3677180 100644 --- a/server/router_test.go +++ b/server/router_test.go @@ -4,9 +4,9 @@ import ( "net/http" "testing" + "github.com/cloudposse/atlantis/server" + . "github.com/cloudposse/atlantis/testing" "github.com/gorilla/mux" - "github.com/runatlantis/atlantis/server" - . "github.com/runatlantis/atlantis/testing" ) func TestRouter_GenerateLockURL(t *testing.T) { diff --git a/server/server.go b/server/server.go index 947af013e9..c46ce3f0ca 100644 --- a/server/server.go +++ b/server/server.go @@ -29,23 +29,23 @@ import ( "syscall" "time" + "github.com/cloudposse/atlantis/server/events" + "github.com/cloudposse/atlantis/server/events/locking" + "github.com/cloudposse/atlantis/server/events/locking/boltdb" + "github.com/cloudposse/atlantis/server/events/models" + "github.com/cloudposse/atlantis/server/events/runtime" + "github.com/cloudposse/atlantis/server/events/terraform" + "github.com/cloudposse/atlantis/server/events/vcs" + "github.com/cloudposse/atlantis/server/events/vcs/bitbucketcloud" + "github.com/cloudposse/atlantis/server/events/vcs/bitbucketserver" + "github.com/cloudposse/atlantis/server/events/webhooks" + "github.com/cloudposse/atlantis/server/events/yaml" + "github.com/cloudposse/atlantis/server/logging" + "github.com/cloudposse/atlantis/server/static" "github.com/elazarl/go-bindata-assetfs" "github.com/gorilla/mux" "github.com/lkysow/go-gitlab" "github.com/pkg/errors" - "github.com/runatlantis/atlantis/server/events" - "github.com/runatlantis/atlantis/server/events/locking" - "github.com/runatlantis/atlantis/server/events/locking/boltdb" - "github.com/runatlantis/atlantis/server/events/models" - "github.com/runatlantis/atlantis/server/events/runtime" - "github.com/runatlantis/atlantis/server/events/terraform" - "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/events/webhooks" - "github.com/runatlantis/atlantis/server/events/yaml" - "github.com/runatlantis/atlantis/server/logging" - "github.com/runatlantis/atlantis/server/static" "github.com/urfave/cli" "github.com/urfave/negroni" ) @@ -90,6 +90,7 @@ type UserConfig struct { BitbucketWebhookSecret string `mapstructure:"bitbucket-webhook-secret"` DataDir string `mapstructure:"data-dir"` GithubHostname string `mapstructure:"gh-hostname"` + GithubTeamWhitelist string `mapstructure:"gh-team-whitelist"` GithubToken string `mapstructure:"gh-token"` GithubUser string `mapstructure:"gh-user"` GithubWebhookSecret string `mapstructure:"gh-webhook-secret"` @@ -306,6 +307,10 @@ func NewServer(userConfig UserConfig, config Config) (*Server, error) { if err != nil { return nil, err } + githubTeamWhitelistChecker, err := events.NewTeamWhitelistChecker(userConfig.GithubTeamWhitelist) + if err != nil { + return nil, err + } locksController := &LocksController{ AtlantisVersion: config.AtlantisVersion, Locker: lockingClient, @@ -323,6 +328,7 @@ func NewServer(userConfig UserConfig, config Config) (*Server, error) { Logger: logger, GithubWebhookSecret: []byte(userConfig.GithubWebhookSecret), GithubRequestValidator: &DefaultGithubRequestValidator{}, + TeamWhitelistChecker: githubTeamWhitelistChecker, GitlabRequestParserValidator: &DefaultGitlabRequestParserValidator{}, GitlabWebhookSecret: []byte(userConfig.GitlabWebhookSecret), RepoWhitelistChecker: repoWhitelist, diff --git a/server/server_test.go b/server/server_test.go index 5e6e408e6c..5fd3777e58 100644 --- a/server/server_test.go +++ b/server/server_test.go @@ -23,13 +23,13 @@ import ( "testing" "time" + "github.com/cloudposse/atlantis/server" + "github.com/cloudposse/atlantis/server/events/locking/mocks" + "github.com/cloudposse/atlantis/server/events/models" + sMocks "github.com/cloudposse/atlantis/server/mocks" + . "github.com/cloudposse/atlantis/testing" "github.com/gorilla/mux" . "github.com/petergtz/pegomock" - "github.com/runatlantis/atlantis/server" - "github.com/runatlantis/atlantis/server/events/locking/mocks" - "github.com/runatlantis/atlantis/server/events/models" - sMocks "github.com/runatlantis/atlantis/server/mocks" - . "github.com/runatlantis/atlantis/testing" ) func TestNewServer(t *testing.T) {