Commit Graph

60 Commits

Author SHA1 Message Date
Nish Krishnan
8598c37671 Support pre-workflow hooks on all comment/auto triggered commands. (#43) (#1418)
Fixes pre-workflow-hooks not logging errors #1371
Prevents pre-workflow-hook from locking and cloning the dir if there are no hooks registered. #1342
2021-02-22 08:34:26 -08:00
Sarvar Muminov
af2a806870 Implement a new policy check workflow (#1317)
* Adding policy_check support into yaml config

* Added policy check model and runtime structs

* Adding BuildPolicyCheckCommand to ProjectCommandBuilder

* Return incorrectly deleted code

* Remove BuildAutoPolicyPlanCommand from ProjectCommandBuilder

* Split runAutoCommand into two functions

runAutoPlanCommand - does what originally RunAutoplancommand was doing
except now it returns CommandResult and []models.ProjectCommandContext
runAutoPolicyCheckCommand - accepts CommandContext, CommandResult, and
[]models.ProjectCommandContext as arguments and runs PolicyCheckStep runner

* Refactor RunCommentCommand
* Remove BuildPolicyCheckCommand and rename StepCmdExec back to TerraformExec
* Add policy step runner logic and conftest interfaces.
* Add show step runner to policy check stage.

* Adding models.PolicyCheckCommand to buildCtx

This also means buildPlanAllCommands call buildCtx twice once with
models.PlanCommand and once with models.PolicyCheckCommand

* Adding new project_command_builder that supports policy_check

* Refactoring PolicyCheck specific logic into a PolicyCheckProjectCommandBuilder

* Moving events.CommandContext to models.CommandContext this will allow me
to remove buildCtx method and move ProjectCommandContext creation into
models package

* Policy Owners might be different types, for that reason we are
refactoring Owners into its own struct with specific keys defining
different owner types

Co-authored-by: Nish Krishnan <nishk@lyft.com>
Co-authored-by: Nish Krishnan <nishkrishnan@users.noreply.github.com>
2021-02-10 18:13:44 -08:00
Sarvar Muminov
3456dc934b Add pre workflow custom hooks to run scripts before workflow execution(plan, apply, etc) (#1255)
* Updated runatlantis.io/docs to have `pre-workflow-hooks` use cases and examples
2020-12-14 15:19:52 -05:00
Quan Hoang
54e3dc2ef0 Skip cloning PR repository in case of no projects configured in repo config file were changed 2020-08-18 15:48:05 -07:00
Luke Kysow
8ac19e4017 Deprecate --repo-whitelist for --repo-allowlist 2020-07-25 23:50:09 -07:00
Chris Alexander
aa1bfc0a27 Add "plan" to continued statement 2020-07-01 10:11:33 -05:00
rob
227ce9cbf4 Upgrade to github/v31 for CompleteAppManifest
split fixtures out elsewhere, add working dir test
2020-06-03 20:18:13 -04:00
Luke Kysow
909723f22e Merge pull request #1051 from runatlantis/draining
Support graceful shutdown
2020-05-25 15:09:25 -07:00
Luke Kysow
78b1ea25d5 Refactor draining feature
- trigger on SIGTERM/INT rather than HTTP POST
- remove atlantis drain command
- refactor into generic status controller
2020-05-25 15:03:08 -07:00
Marc Barlo
0e22d2baab gofmt -s 2020-05-08 10:01:47 -07:00
Marc Barlo
bebfdcaeef Add back the parallel_plan repo cfg option
+ Default parallel plans breaks in a lot of autoplan scenarios i.e. with shared workspaces
+ Added a set of e2e tests to check parallel plans and applies
+ Also added an option to the Terraform client to turn off the plugin cache. This was breaking the e2e test suite (never seen this error in practice)
2020-05-07 22:14:04 -07:00
Benoit BERAUD
c8bbad6de7 Add even more tests 2020-05-05 16:17:43 +02:00
Benoit BERAUD
46a1fe0595 small fixes 2020-05-05 16:15:24 +02:00
David McPike
c8b2252704 Add VCSClient to server ProjectLocker and tests 2020-04-24 22:59:24 -05:00
Luke Kysow
84e41ce110 Refactor -tf-download-url flag changes.
* Fix bad ordering of args calling NewClient()
* Make error messages clearer
2020-01-20 09:19:54 -06:00
Cullen McDermott
d4362ffec3 Add --tf-download-url configuration option 2020-01-20 09:19:54 -06:00
Luke Kysow
b81fe9a5e5 Switch to gomod 2019-08-26 18:38:22 +02:00
Maxime Deravet
d6f2579cf9 Ensure terraform_version is downloaded when using non built-in step. Fixes #675 2019-08-01 14:32:32 -07:00
Luke Kysow
ee8707d239 Add flag for setting Terraform Enterprise hostname (#706)
--tfe-hostname will allow for creating a .terraformrc file with a
different hostname than app.terraform.io
2019-07-12 15:19:43 +01:00
Luke Kysow
4dbdde8543 Upgrade to Terraform 0.12
To be clear, Atlantis was compatible with 0.12 before this commit, but
this change makes 0.12 the default version *if* users haven't set the
--default-tf-version flag.
2019-05-23 11:42:58 -04:00
Luke Kysow
8982a67b78 Run latest goimports 2019-03-30 20:22:49 -05:00
Luke Kysow
846feaed6d Add server-side cfg integration tests 2019-03-28 15:55:34 -05:00
Luke Kysow
d78b106cab Refactor @jjulien's server-side config work. 2019-03-27 14:47:48 -05:00
Luke Kysow
ca58ebd7e0 Autodownload tf versions. Add --default-tf-version.
This changeset has two features:
1. We now automatically download the version of terraform specified in
atlantis.yaml configs if we don't already have that version available
locally.

2. Add a new --default-tf-version flag that allows users to set a
default version of Terraform that we will also download if it's not on
disk.

These mean that users don't need to build custom Docker images to just
add terraform versions. It also means that upgrading the version of
terraform that is packaged with the Atlantis Docker image won't cause
issues for existing users because as long as they're running with
--default-tf-version, Atlantis will always use that version.
2019-03-14 13:51:27 -05:00
Luke Kysow
2fb49130c5 Respond to bitbucket cloud/server username.
Looks like we forgot to add the ability for bitbucket cloud/server users
to invoke Atlantis using the name of the user they're running it as.
2019-03-13 16:13:52 -05:00
Luke Kysow
4fc22aedeb Split status checks into plan and apply.
Split single top-level status check into one plan and one apply check.
These checks will also now track the whole pull request status rather
than just the last action.
2019-03-05 14:29:43 -05:00
Luke Kysow
1997e112d3 Remove duplicate vcs proxy interface
This is the same interface as vcs.Client so no need to have both.
2019-02-25 16:51:26 -05: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
16a4946bea Test new checkout logic. 2019-01-16 18:32:02 -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
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
c4f89958d3 Tweak logging. Add timezone, use everywhere.
- Use logger for all warnings. Previously we were writing warnings from
cmd/server.go directly to stderr which bypassed our normal log format.
- Add the timezone to log output. This is just really nice to have if
you're looking at old logs.
- Change levels to all be 4 characters: DBUG, INFO, WARN, EROR. This
makes the logs easier to read because it lines up.
- Log when we first receive the request as well as when we send a
response. This makes it easier to see where the request starts and ends.
2018-12-19 13:40:13 -06:00
Luke Kysow
374b26f44e Fix non-deterministic tests. 2018-11-01 11:13:34 -05:00
Luke Kysow
16cdcf1165 Remove "Refreshing..." output from top of plan.
When running terraform plan, Terraform writes a line for each resource
it updates. For example:

	null_resource.b: Refreshing state... (ID: 700288721293508840)
	null_resource.a: Refreshing state... (ID: 2853194762920164292)
	null_resource.f: Refreshing state... (ID: 6634469389761751950)

This change removes those lines by splitting the output string after a
separator.

This change is being made because the Refreshing output isn't important
and it will make the comments shorter.
2018-10-30 16:27:55 -05:00
Luke Kysow
c72cd95202 Print commands to run in comments. 2018-08-10 09:26:53 -10:00
Luke Kysow
3b02a1fc31 Test plan/apply all. 2018-08-09 14:23:44 -10:00
Luke Kysow
f8be04e6c6 Update tests for apply all 2018-08-08 17:08:08 -10:00
Luke Kysow
33926a01f2 WebHook -> Webhook 2018-07-24 20:24:27 +02:00
Luke Kysow
718619c045 Rename Bitbucket to BitbucketCloud 2018-07-24 20:23:51 +02:00
Luke Kysow
2ea90c58df Merge pull request #189 from runatlantis/bitbucket
Bitbucket Cloud
2018-07-23 12:40:59 +02:00
Luke Kysow
1fc4667c63 WIP bitbucket 2018-07-19 21:52:33 +02:00
Luke Kysow
d11a927d7d Don't comment back on autoplan no projects. 2018-07-16 17:24:29 +02:00
Luke Kysow
f067818aa5 Test project command runner. 2018-07-01 23:48:32 +02:00
Luke Kysow
13a70c772d Add new --allow-repo-config flag. 2018-06-30 23:27:15 +02:00
Luke Kysow
f01915876d Add env vars to run step 2018-06-29 20:20:55 +02:00
Luke Kysow
9e7509aeee Test command runner 2018-06-29 19:10:10 +02:00
Luke Kysow
12f071b237 Rename atlantisworkspace to workingdir. 2018-06-27 20:43:43 +02:00
Luke Kysow
542a1093fa Fix locking 2018-06-26 14:31:06 +02:00
Luke Kysow
124a016f08 WIP 2018-06-21 18:27:03 +01:00
Luke Kysow
d3ec832eff WIP 2018-06-21 18:18:54 +01:00