Commit Graph

922 Commits

Author SHA1 Message Date
Luke Kysow
27f54667fc Release v0.4.15 2019-02-11 15:03:21 -06:00
Luke Kysow
f4e1472aef Merge pull request #469 from runatlantis/mergeability
Get mergeable status *before* changing build status
2019-02-11 14:49:40 -06:00
Luke Kysow
4e429581b0 Refactor changes to get mergeability early 2019-02-11 14:46:18 -06:00
Luke Kysow
6b079386c0 Merge pull request #467 from runatlantis/bb-server-automerge
Add header to disable bitbucket xsrf
2019-02-11 11:44:39 -06:00
Luke Kysow
81693d79b3 Add header to disable bitbucket xsrf
Fixes #465 which is caused by XSRF detection on Bitbucket server and
cloud.
2019-02-11 11:38:44 -06:00
Luke Kysow
45a6823eb2 Merge pull request #466 from runatlantis/gh-automerge
GitHub Automerge Types
2019-02-11 11:22:49 -06:00
Luke Kysow
1de40340ea Merge pull request #464 from runatlantis/fix-long-output
Fix issues with terraform execution.
2019-02-11 11:21:57 -06:00
Luke Kysow
def41f6cef Add tests for GH merge-type detection. 2019-02-11 11:12:15 -06:00
Luke Kysow
5002397bda Document check-lint target 2019-02-11 10:21:57 -06:00
Luke Kysow
44f0094b75 Fix issues with terraform execution.
Previously I wrote a bunch of code to deal with terraform panicking.
This code used a pipe as the stdout/err buffer and there was a bug
because I wasn't reading off the pipe and it would get full.

While testing a fix, I realized when Terraform panics, the previous code
using CombinedOutput() just worked. As a result, I'm switching back to
that code.
2019-02-11 10:20:55 -06:00
Pratik Mallya
09782c4b6d Allow "Mergeable" apply requirement to work
Get the Mergeable status of the PR before updating the
Status. This allows for the Status to be a required
Status for merging the PR. This allows us to use the
atlantis status as a Required status, which is the
configuration often used, since most deployments
want to ensure tf plans have all been successfully
applied before merging

Issue: https://github.com/runatlantis/atlantis/issues/453
2019-02-09 03:26:26 -08:00
Brenden Matthews
862b5228d0 [automerge] Use available merge methods.
For repos with certain merge methods disabled (such as 'merge'), simply
hitting the GitHub `/merge` endpoint is not sufficient. Instead, we need
to check which methods are actually available, then use the appropriate
method.

With this change it will:

 1. Default to 'merge' if enabled
 2. Use 'rebase' if 'merge' is disabled and rebase is enabled
 3. Use 'squash' if 'merge' is disabled
2019-02-07 16:18:28 -05:00
Luke Kysow
a08cec9691 Merge pull request #458 from runatlantis/release-0.4.14
Release 0.4.14
v0.4.14
2019-02-07 10:28:58 -06:00
Luke Kysow
f5b2757a83 Release 0.4.14 2019-02-07 10:27:04 -06:00
Luke Kysow
102addcaa4 Merge pull request #457 from runatlantis/automerge
Add automerge capability
2019-02-07 09:33:27 -06:00
Luke Kysow
74e9bbb82b Add automerge feature.
Automerging merges pull requests automatically if all plans have been
successfully applied.

* Save status of PR's to BoltDB so after each apply, we can check if
there are pending plans.
* Add new feature where we delete successful plans *unless* all plans
have succeeded *if* automerge is enabled. This was requested by users
because when automerge is enabled, they want to enforce that a pull
request's changes have been fully applied. They asked that plans not be
allowed to be applied "piecemeal" and instead, all plans must be
generated successfully prior to allowing any plans to be applied.
2019-02-06 16:27:43 -06:00
Luke Kysow
2225da9c61 Switch to golangci-lint from gometalinter.
Hoping that this is more stable.
2019-02-06 16:26:46 -06:00
Luke Kysow
2c6b87d09b Merge pull request #451 from runatlantis/tfe-free-docs
Update docs to point at tfe free link.
2019-02-01 09:56:37 -05:00
Luke Kysow
34e3bfdb85 Update docs to point at tfe free link. 2019-02-01 09:55:04 -05:00
Luke Kysow
84c89ba7ea Merge pull request #442 from runatlantis/slack-token
Add slack-token to flags.
2019-01-22 22:32:21 -05:00
Luke Kysow
7aca997a06 Add missing period to flag docs. 2019-01-22 22:30:30 -05:00
Jacob Foard
2e65e03055 Adding in slack-token to flags
Signed-off-by: Jacob Foard <jacob.foard@formation.ai>
2019-01-22 22:30:30 -05:00
Luke Kysow
5341e7d843 Merge pull request #441 from runatlantis/website-testing
Test website for broken links during build.
2019-01-22 22:25:08 -05:00
Luke Kysow
8cb27aba02 Test website for broken links during build. 2019-01-22 22:21:36 -05:00
Luke Kysow
c0b89d9f1f Merge pull request #440 from runatlantis/gometalint
Update to latest linters. Fix errors.
2019-01-22 13:32:42 -05:00
Luke Kysow
70235d8e8f Update to latest linters. Fix errors. 2019-01-22 13:29:42 -05:00
Luke Kysow
d2c2e8de4f Merge pull request #439 from runatlantis/tfe-docs
Tfe docs
2019-01-22 12:16:08 -05:00
Luke Kysow
505ec77a5c Remove website-link-check build step.
This step doesn't work for forked pull requests so I'm removing it for
now.
2019-01-22 12:03:21 -05:00
Luke Kysow
61269e547b Update TFE free remote state mgmt docs 2019-01-22 12:02:31 -05:00
Luke Kysow
56b09b6d14 Merge pull request #433 from runatlantis/checkout-strategy
Document checkout strategy
2019-01-17 10:13:32 -05:00
Luke Kysow
108ffd8eea Document checkout strategy 2019-01-17 10:10:12 -05:00
Luke Kysow
a9d5feac84 Merge pull request #427 from runatlantis/checkout-strategy
Add new --checkout-strategy flag
2019-01-17 10:09:51 -05:00
Luke Kysow
16a4946bea Test new checkout logic. 2019-01-16 18:32:02 -05:00
Luke Kysow
3b7542b392 Merge pull request #430 from runatlantis/skipped-test
Fix skipped test
2019-01-16 17:52:40 -05:00
Luke Kysow
054d3bc5f6 Fix skipped test 2019-01-16 12:13:37 -05:00
Luke Kysow
501db6b66e Fix gometalinter errors
Also disable test linters since we already run tests.
2019-01-15 15:45:01 -05:00
Luke Kysow
8b77b95a16 Add checkout-strategy flag.
This flag can be set to either branch (default) or merge. If set to
branch, we will check out the head branch of the pull request (the
source). If set to merge, we will check out the base branch of the pull
request (the destination) and then attempt to perform a git merge of the
pull request branch. This simulates what will happen if the pull request
is merged.

This allows us to perform terraform commands on what the state of the
repo will be *after* the pull request is merged. This is useful if users
are often opening up pull requests from branches that aren't up to date
with master. With the branch strategy, the terraform plan might be
deleting resources that have been created in the master branch but with
the merge strategy, we merge the branch's changes into the master branch
and so don't have this problem.
2019-01-15 15:45:01 -05:00
Luke Kysow
d2abdb569a Provide base branch name in pull request model
This is needed in order to support the ability to check out the repo as
it would appear after the pull request is merged into the base branch.
2019-01-15 13:45:35 -05:00
Luke Kysow
164c6c222d Merge pull request #422 from runatlantis/plan-step-document
Document need to manually select workspace
2019-01-11 13:18:43 -05:00
Luke Kysow
3c975f37f1 Document need to manually select workspace
If users are overriding the default plan command then they need to
select the workspace themselves.

Fixes #405
2019-01-11 13:09:06 -05:00
Luke Kysow
173fdde739 Merge pull request #421 from runatlantis/handle-panics
Fix bug where Atlantis hangs on terraform crash.
2019-01-10 19:52:29 -05:00
Luke Kysow
1d7bb42955 Fix tests 2019-01-10 19:46:29 -05:00
Luke Kysow
3f1a5596c1 Vendor go-linereader 2019-01-10 17:42:30 -05:00
Luke Kysow
b1e32643f5 Fix bug where Atlantis hangs on terraform crash.
Because of some weirdness with how terraform executes (it forks itself
and assigns the parent's stderr and stdout file descriptors to the
child) when terraform panics, Go's exec.CombinedOutput() blocks
indefinitely even though the terraform process has exited.

To handle this, we switch to using os.Pipe for the cmd's stderr/out
which for some reason allows Go to know when the process has exited.
Unfortunately, this brings up a new problem when reading the output from
that pipe. For some reason, after a terraform crash, we never get an EOF
on the pipe and so as we again get in a situation where we're blocking
indefinitely. To handle this, I've added an edge case where we look at
the log lines and if its the end of a terraform panic, we break out of
the loop.

Thanks Terraform 0.12-alpha for discovering this bug!
2019-01-10 17:42:30 -05:00
Luke Kysow
acf46ba89d Merge pull request #419 from runatlantis/tfe-token
Add optional tfe-token flag. Get working with 0.12.
2019-01-10 17:26:20 -05:00
Luke Kysow
e0dcb5ab13 Don't add extra -var flags when using TF >= 0.12
In Terraform 0.12 and above, you aren't allowed to set -var foo=bar
flags unless the foo variable is actually defined in code. Previously,
we were setting the following variables:
- atlantis_user
- atlantis_repo
- atlantis_repo_owner
- atlantis_repo_name
- atlantis_pull_num

Users could then use these variables if they wanted to, in their code.
The main use case was to name the assume role session in AWS:

provider "aws" {
  assume_role {
    role_arn     = "arn:aws:iam::ACCOUNT_ID:role/ROLE_NAME"
    session_name = "${var.atlantis_user}-${var.atlantis_repo_owner}-${var.atlantis_repo_name}-${var.atlantis_pull_num}"
  }
}

This is longer possible in 0.12.
2019-01-10 15:16:21 -05:00
Luke Kysow
fb86e89df0 Add new --tfe-token flag for TFE backend.
The new flag takes in a Terraform Enterprise API token and attempts to
write a config file for that token to ~/.terraformrc on startup.
If the file already exists and its contents would change as a result of
us writing it, we error out.
This flag is useful if you're using the TFE backend for any of your
projects as that requires a .terraformrc file with a token for
authentication.
2019-01-09 15:11:01 -05:00
Luke Kysow
7caa043fe6 Organize fields alphabetically 2019-01-09 14:49:56 -05:00
Luke Kysow
6d2fd4314d Merge pull request #417 from runatlantis/tfe-state-docs
Add docs about using tfe remote state.
2019-01-09 09:51:01 -05:00
Luke Kysow
255a5b7fc1 Add docs about using tfe remote state. 2019-01-08 16:00:49 -05:00