Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[WIP] Atlantis 0.4 #152

Merged
merged 69 commits into from
Jul 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
8ee16a0
By default atlantis plan will run in root dir.
lkysow Mar 22, 2018
6dc0e3c
Implement apply step.
lkysow Mar 22, 2018
692e414
Implement init step.
lkysow Mar 22, 2018
464cd51
Implement plan step.
lkysow Mar 22, 2018
06f68b8
Add TF_WORKSPACE env var when execing terraform
lkysow Mar 22, 2018
a22e237
Improve test helpers.
lkysow Mar 25, 2018
42b6646
Implement config reader and parser
lkysow Mar 25, 2018
75a55dd
Moved into new package
lkysow Mar 25, 2018
7dfab21
Parse config and build execution plan.
lkysow Jun 5, 2018
2175b50
Use new steps in plan/apply
lkysow Jun 5, 2018
aef8a63
Make tests more readable
lkysow Jun 6, 2018
d06f3ca
Implement custom run step
lkysow Jun 6, 2018
69c788e
Rename package repoconfig to yaml
lkysow Jun 7, 2018
b531705
Split out config elements into separate files
lkysow Jun 8, 2018
d6883e8
Move runtime elements to the runtime package
lkysow Jun 8, 2018
437b625
Test execution_planner
lkysow Jun 8, 2018
9839e0d
Move execution planner. Don't plan in deleted dirs
lkysow Jun 11, 2018
3525ab3
WIP
lkysow Jun 12, 2018
f59fe33
Parse YAML without defaults/validation.
lkysow Jun 12, 2018
d70e57e
Yaml parsing and validation.
lkysow Jun 13, 2018
b5e2a73
WIP Add operators and get compiled.
lkysow Jun 15, 2018
8ab4857
Fix all tests
lkysow Jun 15, 2018
e97b98e
Add first e2e test with mocks.
lkysow Jun 15, 2018
a9e9e18
Enable multiple cases for e2e testing
lkysow Jun 16, 2018
a162b36
Remove need for .git in test fixtures.
lkysow Jun 16, 2018
de5c406
Add -var test.
lkysow Jun 18, 2018
d9a4736
Implement when_modified.
lkysow Jun 18, 2018
e7d5bf5
Implement not deleting repo when same sha
lkysow Jun 18, 2018
6b507eb
Add -p flag.
lkysow Jun 19, 2018
45d80fc
Fix gometalint errors.
lkysow Jun 19, 2018
21694c9
Run dep ensure
lkysow Jun 19, 2018
3c9188b
Add unit test image
lkysow Jun 20, 2018
07ff697
Vendor docker
lkysow Jun 20, 2018
1824717
Use correct case for sirupsen.
lkysow Jun 20, 2018
c6b18e3
Fix tests
lkysow Jun 20, 2018
856c0d0
Use atlantisbot
lkysow Jun 20, 2018
c98d104
Update e2e for new version.
lkysow Jun 20, 2018
0c966d5
GitlabRequestParser -> GitlabRequestParserValidator
lkysow Jun 20, 2018
d359131
RepoWhitelist -> RepoWhitelistChecker
lkysow Jun 20, 2018
d3ec832
WIP
lkysow Jun 21, 2018
124a016
WIP
lkysow Jun 21, 2018
17a9c7f
Regen mocks
lkysow Jun 21, 2018
9e1d92b
WIP
lkysow Jun 21, 2018
cf3e654
Start on tests
lkysow Jun 21, 2018
dd12ce1
Create docs with VuePress
lkysow Jun 22, 2018
860cdb8
Delete old website
lkysow Jun 22, 2018
a564c7e
Docs
lkysow Jun 25, 2018
1d2f33a
Docs
lkysow Jun 25, 2018
ba833bf
Move terraform/ under runatlantis.io
lkysow Jun 25, 2018
0e71ccc
Finish docs
lkysow Jun 25, 2018
542a109
Fix locking
lkysow Jun 26, 2018
7c927a4
Update docs with changes from README
lkysow Jun 27, 2018
12f071b
Rename atlantisworkspace to workingdir.
lkysow Jun 27, 2018
6f8401d
Test BuildAutoplanCommands
lkysow Jun 29, 2018
507ce43
Rename Spec -> Config
lkysow Jun 29, 2018
3339dcd
Dir/Path -> RepoRelDir, path (in templates) -> dir
lkysow Jun 29, 2018
9e7509a
Test command runner
lkysow Jun 29, 2018
71716a6
Cleanup unused code.
lkysow Jun 29, 2018
f019158
Add env vars to run step
lkysow Jun 29, 2018
f29dc00
Warn if not using version 2
lkysow Jun 29, 2018
13a70c7
Add new --allow-repo-config flag.
lkysow Jun 30, 2018
6d87664
Test GitHub client.
lkysow Jul 1, 2018
f067818
Test project command runner.
lkysow Jul 1, 2018
502c626
Fix doc todos
lkysow Jul 2, 2018
ef728de
Change testdrive docs for autoplan
lkysow Jul 2, 2018
85a775b
Fix todos. Remove TF_WORKSPACE.
lkysow Jul 2, 2018
8effd01
Test new allow-repo-config flag
lkysow Jul 2, 2018
b2bd90d
Various fixes
lkysow Jul 3, 2018
573491f
Bring README back for now
lkysow Jul 3, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ jobs:
test:
working_directory: /go/src/github.com/runatlantis/atlantis
docker:
- image: circleci/golang:1.10
- image: runatlantis/testing-env
steps:
- checkout
- run: make test-coverage
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ website/src/public
.DS_Store
.cover
.terraform/
node_modules/
**/.vuepress/dist
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
# v0.4.0-alpha

## Features
* Autoplanning - Atlantis will automatically run `plan` on new pull requests and
when new commits are pushed to the pull request.
* New repository `atlantis.yaml` format that supports:
* Arbitrary step ordering
* Single config file for whole repository
* Controlling autoplanning
* Moved docs to standalone website from the README.

## Bugfixes

## Backwards Incompatibilities / Notes:

## Downloads

## Docker


# v0.3.10

## Features
Expand Down
80 changes: 78 additions & 2 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,15 @@
[[constraint]]
branch = "master"
name = "github.com/lkysow/go-gitlab"

[[constraint]]
name = "github.com/go-test/deep"
version = "1.0.1"

[[constraint]]
branch = "master"
name = "github.com/flynn-archive/go-shlex"

[[constraint]]
branch = "master"
name = "github.com/docker/docker"
20 changes: 12 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,17 @@ build-service: ## Build the main Go service
go-generate: ## Run go generate in all packages
go generate $(PKG)

regen-mocks: ## Delete all mocks and then run go generate to regen them
find . -type f | grep mocks/mock | grep -v vendor | xargs rm
@# not using $(PKG) here because that it includes directories that have now
@# been deleted, causing go generate to fail.
go generate $$(go list ./... | grep -v e2e | grep -v vendor | grep -v static)
#regen-mocks: ## Delete all mocks and matchers and then run go generate to regen them. This doesn't work anymore.
#find . -type f | grep mocks/mock_ | grep -v vendor | xargs rm
#find . -type f | grep mocks/matchers | grep -v vendor | xargs rm
#@# not using $(PKG) here because that it includes directories that have now
#@# been deleted, causing go generate to fail.
#echo "this doesn't work anymore: go generate \$\$(go list ./... | grep -v e2e | grep -v vendor | grep -v static)"

test: ## Run tests
@go test -short $(PKG)

test-all: ## Run tests including integration
@go test $(PKG)

test-coverage:
Expand Down Expand Up @@ -78,9 +82,9 @@ end-to-end-tests: ## Run e2e tests
./scripts/e2e.sh

generate-website-html: ## Generate HTML for website
cd website/src && hugo -d ../html
yarn website:build

upload-website-html: ## Upload generated website to s3
aws s3 rm s3://www.runatlantis.io/ --recursive
aws s3 sync website/html/ s3://www.runatlantis.io/
rm -rf website/html/
aws s3 sync runatlantis.io/.vuepress/dist/ s3://www.runatlantis.io/
rm -rf runatlantis.io/.vuepress/dist
33 changes: 21 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,42 +124,42 @@ Atlantis supports several Terraform project structures:
```
.
├── project1
   ├── main.tf
├── main.tf
| └── ...
└── project2
   ├── main.tf
├── main.tf
└── ...
```
- one folder per set of configuration
```
.
├── staging
   ├── main.tf
├── main.tf
| └── ...
└── production
   ├── main.tf
├── main.tf
└── ...
```
- using `env/{env}.tfvars` to define workspace specific variables. This works in both multi-project repos and single-project repos.
```
.
├── env
   ├── production.tfvars
   └── staging.tfvars
├── production.tfvars
└── staging.tfvars
└── main.tf
```
or
```
.
├── project1
   ├── env
   │   ├── production.tfvars
   │   └── staging.tfvars
   └── main.tf
├── env
├── production.tfvars
└── staging.tfvars
└── main.tf
└── project2
├── env
   ├── production.tfvars
   └── staging.tfvars
├── production.tfvars
└── staging.tfvars
└── main.tf
```
With the above project structure you can de-duplicate your Terraform code between workspaces/environments without requiring extensive use of modules. At Hootsuite we found this project format to be very successful and use it in all of our 100+ Terraform repositories.
Expand Down Expand Up @@ -261,6 +261,8 @@ Once a plan is discarded, you'll need to run `plan` again prior to running `appl
If you'd like to require pull/merge requests to be approved prior to a user running `atlantis apply` simply run Atlantis with the `--require-approval` flag.
By default, no approval is required.

Please note that this option is not intended for access control purposes: anyone with even read access to a repository can approve a pull request.

For more information on GitHub pull request reviews and approvals see: https://help.github.com/articles/about-pull-request-reviews/

For more information on GitLab merge request reviews and approvals (only supported on GitLab Enterprise) see: https://docs.gitlab.com/ee/user/project/merge_requests/merge_request_approvals.html.
Expand Down Expand Up @@ -382,6 +384,12 @@ $ atlantis server --atlantis-url $URL --gh-user $USERNAME --gh-token $TOKEN --gh
2049/10/6 00:00:00 [WARN] server: Atlantis started - listening on port 4141
```

If you're using GitHub Enterprise, run:
```
$ atlantis server --atlantis-url $URL --gh-user $USERNAME --gh-token $TOKEN --gh-webhook-secret $SECRET --gh-hostname $GITHUBHOSTNAME
2049/10/6 00:00:00 [WARN] server: Atlantis started - listening on port 4141
```

If you're using GitLab, run:
```
$ atlantis server --atlantis-url $URL --gitlab-user $USERNAME --gitlab-token $TOKEN --gitlab-webhook-secret $SECRET
Expand All @@ -392,6 +400,7 @@ $ atlantis server --atlantis-url $URL --gitlab-user $USERNAME --gitlab-token $TO
- `$USERNAME` is the GitHub/GitLab username you generated the token for
- `$TOKEN` is the access token you created. If you don't want this to be passed in as an argument for security reasons you can specify it in a config file (see [Configuration](#configuration)) or as an environment variable: `ATLANTIS_GH_TOKEN` or `ATLANTIS_GITLAB_TOKEN`
- `$SECRET` is the random key you used for the webhook secret. If you left the secret blank then don't specify this flag. If you don't want this to be passed in as an argument for security reasons you can specify it in a config file (see [Configuration](#configuration)) or as an environment variable: `ATLANTIS_GH_WEBHOOK_SECRET` or `ATLANTIS_GITLAB_WEBHOOK_SECRET`
- `$GITHUBHOSTNAME` is the FQDN of your enterprise Github, for example `github.mycompany.com` (adding protocol before the FQDN is unnecessary, it will always use https). If you want to set it as an environment variable then use `ATLANTIS_GH_HOSTNAME`.

Atlantis is now running!
**We recommend running it under something like Systemd or Supervisord.**
Expand Down
15 changes: 12 additions & 3 deletions cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ import (
// 3. Add your flag's description etc. to the stringFlags, intFlags, or boolFlags slices.
const (
// Flag names.
AtlantisURLFlag = "atlantis-url"
AllowForkPRsFlag = "allow-fork-prs"
AllowRepoConfigFlag = "allow-repo-config"
AtlantisURLFlag = "atlantis-url"
ConfigFlag = "config"
DataDirFlag = "data-dir"
GHHostnameFlag = "gh-hostname"
Expand Down Expand Up @@ -142,6 +143,13 @@ var boolFlags = []boolFlag{
description: "Allow Atlantis to run on pull requests from forks. A security issue for public repos.",
defaultValue: false,
},
{
name: AllowRepoConfigFlag,
description: "Allow repositories to use atlantis.yaml files to customize the commands Atlantis runs." +
" Should only be enabled in a trusted environment since it enables a pull request to run arbitrary commands" +
" on the Atlantis server.",
defaultValue: false,
},
{
name: RequireApprovalFlag,
description: "Require pull requests to be \"Approved\" before allowing the apply command to be run.",
Expand Down Expand Up @@ -298,8 +306,9 @@ func (s *ServerCmd) run() error {

// Config looks good. Start the server.
server, err := s.ServerCreator.NewServer(userConfig, server.Config{
AllowForkPRsFlag: AllowForkPRsFlag,
AtlantisVersion: s.AtlantisVersion,
AllowForkPRsFlag: AllowForkPRsFlag,
AllowRepoConfigFlag: AllowRepoConfigFlag,
AtlantisVersion: s.AtlantisVersion,
})
if err != nil {
return errors.Wrap(err, "initializing server")
Expand Down
Loading