Commit Graph

48 Commits

Author SHA1 Message Date
Sarvar Muminov
90e92e3a13 chore: move CommandContext and CommandResult to models (#193) (#2093)
* Moved CommandContext and CommandResult to models (#193)

* Moved CommandContext and CommandResult to models

* move from models to command

rename CommandContext -> Context
rename CommandResult -> Result

* moved command related helpers into command package

* move ProjectCommandContext and ProjectResult to command/project package

* move project command context and project result

* revert unrelated code

* move tests

* fix left over

* fix linting

* fix tests

* remove unused import

* fix project context dependencies

* fix depenedecies

* fix typo
2022-03-21 10:36:13 -07:00
Alexander Dupuy
dc4cc2f614 docs: document approve_policies command in comment_parser (#1886)
* docs: document approve_policies command in help

The `approve_policies` command was added with policy checking but was
never included in the command parser help.

Also update the comments in the file to reflect all of the commands.

* feat: Better message on policy failure

Include the specific command `approve_policies` in the message.
2021-11-17 17:25:29 -05:00
Enoch Lo
89236d8e54 Add flag to enable markdown diff formatting (#1751) 2021-08-30 14:01:52 -07:00
Pat Sier
d358857e80 feat: add version command (#1691) 2021-07-12 11:10:15 -04:00
Nish Krishnan
79309ed39c [ORCA-559] Fix hide previous command logic (#37) (#1549) 2021-05-03 12:47:23 -07:00
Wojciech Krysmann
0886b280f9 Add plan summary to unfolded part of comment (#1518) 2021-04-22 09:14:44 -07: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
Gerald Barker
1137a82c60 Add the ability to disable Atlantis locking a repo (#1340)
* Add the ability to disable Atlantis locking a repo

* Fix incorrect logic when creating locking Client

Co-authored-by: kbaldyga <kbaldyga@gmail.com>

* Add tests for noOpLocker to improve coverage

Co-authored-by: Gerald Barker <geraldbarker@mail.com>
Co-authored-by: kbaldyga <kbaldyga@gmail.com>
2021-01-14 10:20:27 -05:00
chenrui
d51a4706b3 chore(deps): sprig 3.1.0 (#1313)
* chore(deps): sprig 3.1.0

Signed-off-by: Rui Chen <rui@meetup.com>

* go mod vendor

Signed-off-by: Rui Chen <rui@meetup.com>
2020-12-12 21:05:15 -05:00
Gerald Barker
d2610a78af Add Option to globally disable apply (#1230)
* Add Option to globally disable apply

Co-authored-by: Gerald Barker <geraldbarker@mail.com>
2020-10-27 21:01:39 -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
Paris Morali
ab7016063a Atlantis lock discard via VCS comment
This successfully deletes the atlantis lock and
allows a competing PR to plan, but doesn not delete
the actual plans, so a user can still apply after
the lock is discarded.
This will be investigated in a follow up commit

Also fixed the basic mark down rendering for the discard command
2020-06-08 15:56:58 +01:00
Mike Hume
35b6a1bdb2 Merge branch 'wrapped-default' into long-folding 2020-03-29 15:36:53 -07:00
Mike Hume
62d3522d33 Adding --fold-long-output flag to toggle wrapped default 2020-02-18 01:48:28 -08:00
Luke Kysow
889d584514 Refactor branch diverged warning.
- only check for divergence if using checkout strategy merge
2019-11-27 10:52:39 -08:00
Marco Rinalducci
a824ad4d23 Detects if master branch has diverged and warn to pull new commits in comment 2019-11-27 10:52:39 -08:00
Will Soula
b77a09dc97 Add --disable-apply-all flag
Add a flag to disable the use of the command `atlantis apply` so you
can enforce that each plan must be applied separately.
2019-05-23 12:09:51 -04:00
Luke Kysow
568c7f9fd9 Add newline so bitbucket formats markdown 2019-04-24 09:50:28 -03:00
Luke Kysow
5f4a94b0af Move CommandName to models package 2019-02-26 12:03:25 -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
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
ba04564e2a Disable markdown folding on gitlab < 11.1.
On startup, make a call to the /version endpoint of Gitlab to get which
version we're running. Then use that version to determine whether we
should use the markdown folding syntax where the code is expandable.
Versions of Gitlab < 11.1 don't support the "Common Mark" markdown
format.

Fixes https://github.com/runatlantis/atlantis/issues/315
2018-11-29 17:09:12 -06: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
e9b7001266 Add godocs. Refactor ProjectResult. Golint errors. 2018-08-30 16:47:17 -06: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
5a3bb96c3c Fix gometalint issues 2018-08-08 17:08:08 -10:00
Luke Kysow
5ee990cec1 Don't default dir and workspace.
Lay groundwork for atlantis plan/apply to work on everything.
2018-08-08 17:08:08 -10:00
Luke Kysow
a217e1f880 Add comment to apply all with atlantis apply 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
1fc4667c63 WIP bitbucket 2018-07-19 21:52:33 +02:00
Luke Kysow
84078dc21e Remove unused autoplan param. 2018-07-16 17:29:28 +02:00
Luke Kysow
d11a927d7d Don't comment back on autoplan no projects. 2018-07-16 17:24:29 +02:00
Luke Kysow
3339dcd92b Dir/Path -> RepoRelDir, path (in templates) -> dir 2018-06-29 18:05:47 +02:00
Luke Kysow
d3ec832eff WIP 2018-06-21 18:18:54 +01:00
Luke Kysow
45d80fc695 Fix gometalint errors. 2018-06-19 20:59:25 +01:00
Luke Kysow
e7d5bf54fb Implement not deleting repo when same sha 2018-06-18 22:51:39 +01:00
Luke Kysow
d70e57e87b Yaml parsing and validation. 2018-06-13 13:54:04 +01:00
Luke Kysow
3525ab3bd9 WIP 2018-06-12 14:54:38 +01:00
Luke Kysow
8aca81966f Add Apache 2 license and copyright.
Add Apache 2 license and Hootsuite copyright to all golang
files. Add a disclaimer that the files have been modified
hereafter by contributors to this repo in order to abide
by the Apache 2 license requirements.
2018-03-15 17:25:02 -07:00
Luke Kysow
5e5bc60bdc Rename pointer receiver 2018-03-08 11:51:27 -08:00
Luke Kysow
ab1d36d2c8 Comment back on pull request sooner on error.
- Refactor EventParser so it returns a comment we can send to the pull
request when a bad command or help command is commented.
- Remove now unneeded HelpExecutor because we comment right from the
EventsController now
- Use pflag package to parse commands instead of doing it manually
- Comment back when user types terraform instead of atlantis
2018-02-27 17:45:05 -08:00
Luke Kysow
7c1220a655 Rename from environment to workspace 2017-12-17 16:46:49 -08:00
Luke Kysow
cc924899e5 Add documentation for server, bootstrap and server/events packages 2017-11-26 21:41:06 -08:00
Luke Kysow
fa43febf60 Gitlab (#190)
Gitlab initial implementation
2017-11-16 13:22:28 -08:00