Commit Graph

39 Commits

Author SHA1 Message Date
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
Nish Krishnan
10d7b282e8 Fix e2e test fixtures for tf0.14. (#1396) 2021-02-10 16:48:35 -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
Luke Kysow
8ac19e4017 Deprecate --repo-whitelist for --repo-allowlist 2020-07-25 23:50:09 -07:00
Paris Morali
aed8d22b52 Implement atlantis unlock
This command is run on a pr and deletes all locks for the pr
2020-06-23 20:42:03 -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
Josh Soref
2cf5b0a42a Spelling (#902)
Spelling fixes
2020-01-20 12:46:00 -06: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
568c7f9fd9 Add newline so bitbucket formats markdown 2019-04-24 09:50:28 -03:00
Luke Kysow
846feaed6d Add server-side cfg integration tests 2019-03-28 15:55:34 -05:00
Luke Kysow
25fed35728 New version 3 of atlantis.yaml
This version changes how we parse custom run steps.
Previously we used the go-shlex library to parse the steps but this
caused users issues because they'd have to use weird escaping.

Now we simply pass the step directy to sh -c without any parsing. The
parsing was unnecessary.
2019-03-28 13:45:12 -05:00
Luke Kysow
2fb8f4d4ff Support bitbucket server pr:deleted event
If a pull request is deleted, Atlantis should delete the locks.
Fixes #498
2019-03-01 11:36:22 -05: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
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
1d7bb42955 Fix tests 2019-01-10 19:46:29 -05:00
Luke Kysow
934b51b64f Add project name to comments.
If projects are configured using an atlantis.yaml with a specific
project name, include that in the output for comments. This is useful
because often the project names are better identifiers than the
directory and workspace names and also because some projects use the
same dir and workspace so the only way to differentiate them is via
their names.

Fixes #353
2018-12-04 12:01:05 -06:00
Luke Kysow
70d194830a Fix pre plan output being removed.
Prior to this change, we were formatting the output from terraform plan
inside the markdown_renderer. Part of this formatting is to remove all
output relating to refreshing state. The way we were doing this was to
simply delete all lines before the refreshing completes.

The problem with this approach was that any output from custom steps
that ran before plan would also be deleted. This change moves the
formatting of the plan output inside the plan step. Then the
markdown_renderer deals with the pre-formatted output and doesn't need
to delete anything before it combines all the step outputs into one.
2018-11-30 08:54:20 -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
5d05f3df3b Fix multi-project output.
Was causing output to look broken for GitHub.
2018-09-28 10:21:18 -05:00
Luke Kysow
bac2ee7619 Fold long output. Fix diff highlighting.
* If output is longer than 12 lines, wrap it in markdown folding for
GitLab and GitHub.
* Reformat the Terraform plan output so that the + and - lines show up
highlighted properly when using the diff syntax highlighting
2018-09-15 09:12:43 -07: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
2ea90c58df Merge pull request #189 from runatlantis/bitbucket
Bitbucket Cloud
2018-07-23 12:40:59 +02:00
Luke Kysow
0e5a29da2a Update exp responses. 2018-07-20 14:37:44 +02:00
Luke Kysow
d11a927d7d Don't comment back on autoplan no projects. 2018-07-16 17:24:29 +02:00
Luke Kysow
a6574b897d Change default when_modified to **/*.tf*
This is so .tfvars files match.
2018-07-10 14:24:30 +02:00
Luke Kysow
f01915876d Add env vars to run step 2018-06-29 20:20:55 +02:00
Luke Kysow
3339dcd92b Dir/Path -> RepoRelDir, path (in templates) -> dir 2018-06-29 18:05:47 +02:00
Luke Kysow
542a1093fa Fix locking 2018-06-26 14:31:06 +02:00
Luke Kysow
d3ec832eff WIP 2018-06-21 18:18:54 +01:00
Luke Kysow
6b507eb721 Add -p flag. 2018-06-19 20:51:59 +01:00
Luke Kysow
e7d5bf54fb Implement not deleting repo when same sha 2018-06-18 22:51:39 +01:00
Luke Kysow
d9a47361e5 Implement when_modified. 2018-06-18 19:55:14 +01:00
Luke Kysow
de5c4061bd Add -var test. 2018-06-18 10:28:58 +01:00
Luke Kysow
a9e9e18f2e Enable multiple cases for e2e testing 2018-06-16 18:11:30 +01:00
Luke Kysow
e97b98e4a0 Add first e2e test with mocks. 2018-06-15 17:52:14 +01:00
Luke Kysow
31dc84853a [Draft] Add --repo-whitelist option.
- this option is now required which breaks BC
- will validate that an event is coming from a repo that we trust
- started refactoring event_controller tests to use less mocks
2018-03-08 17:49:47 -08:00