Commit Graph

810 Commits

Author SHA1 Message Date
Luke Kysow
10bbe0abe3 Merge pull request #378 from jocelynthode/fix_regression_gitlab
Fix URL parsing not working when passing only a domain to GitlabHostname
2018-12-10 08:39:51 -06:00
Jocelyn Thode
2adaf4b24c Fix URL parsing not working when passing only a domain to GitlabHostname
Fixes https://github.com/runatlantis/atlantis/issues/377
2018-12-08 20:27:57 +01:00
Luke Kysow
5f89527049 Return plan output on error.
If terraform plan returns an error, we still want to print the output to
the pull request.
2018-12-07 10:15:42 -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
9adb7eb89a Merge pull request #372 from runatlantis/bitbucket-comment-length
Split Bitbucket Server comments if over max length
2018-12-04 10:07:55 -06:00
Luke Kysow
b13a85b4f1 Use Bitbucket 2.0 API for comments.
Bitbucket released the 2.0 version for the commenting on pull requests
API:
https://community.atlassian.com/t5/Bitbucket-questions/Re-Bitbucket-Cloud-REST-API-v2-0-Commenting-on-Pull-Re/qaq-p/849427/comment-id/30070#M30070.
Previously, this was only available in version 1.0. Since 1.0 will be
deprecated, it's best to move to the latest version.
2018-12-04 09:58:52 -06:00
Luke Kysow
bf19968cec Split Bitbucket Server comments if over max length
- Refactor the comment split method into a common package
2018-12-04 09:58:37 -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
1263ccb463 Move gitlab client setup into constructor. 2018-11-29 15:19:21 -06:00
Luke Kysow
63557b4cb5 Change exact open/closing of split messages. Test. 2018-11-22 18:41:18 -06:00
Tobias Bielohlawek
e32a57b6f3 Fix broken format for continued comments on GitHub
Adds close and (re)open <details> tag in between the split portions to 
ensure the markup is correct across multiple comments. This isn't the prettiest, but a close result, under the assumption continued-comments are in 99% within a terraform output anyway...
2018-11-22 15:07:56 -06:00
Luke Kysow
af5c44c1df Log warning if unable to resolve GitLab hostname.
The GitLab client doesn't do a good job logging errors if the hostname
isn't resolvable so we log an error early to help users.
2018-11-22 13:57:00 -06:00
Luke Kysow
f1cced0e7f Merge pull request #357 from runatlantis/basepath
Allow running Atlantis behind a path-based proxy
2018-11-21 12:48:21 -06:00
Luke Kysow
fa4aad4a74 Refine basepath changes.
- Refactoring work from https://github.com/runatlantis/atlantis/pull/314
- Use just the path in templates, not the fully qualified URL since that
is a best practice.
- Add logging to errors when rendering templates.
- Silence help output on cli errors since the help output is now so
large that you have to scroll up to see the errors.
2018-11-21 11:33:31 -06:00
Luke Kysow
deebb22b5d Use int instead of string for bitbucket response. 2018-11-16 13:38:29 -05:00
Jonathan Lange
670131fa63 Prefix URLs in templates with AtlantisURL
Resolves #213

Allows users to run Atlantis behind a shared reverse proxy, which is a fairly
common use case.
2018-11-06 11:03:58 +00: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
2d214b2727 Restrict possible project names.
We should only allow project names (which are specified in an
atlantis.yaml file) that don't need to be url escaped. The one
exceptional character is '/' which we allow because users like to name
their projects to match the directory they're in. We use the same rule
that Terraform uses for workspace names.

I've also changed the characters that are replaced when writing out the
plan filename to only remove invalid filename characters instead of just
allowing alphanumeric. This is the smallest amount of change required to
ensure the filename is valid.
2018-10-30 13:01:48 -05:00
John Lin
b652568798 replace all invalid char in plan filename 2018-10-30 11:43:24 -05:00
Luke Kysow
4d3c567d87 Make project locked message look better.
When the plan fails, it gets the error prepended with **Plan Failed**:.
Thus we don't need to add our own "**Unable to run plan**" error.
2018-10-30 11:16:16 -05:00
Luke Kysow
4fcece0f9d Fix tests when git config uses gpg signing.
- some of the tests run git so if you're using gpg signing you need
  to disable that.
- refactor test helpers to use tb.Helper() and make the error output red.
  This is useful because if another helper uses one of these helpers,
  when it calls .Helper() its output will also be up the stack.
2018-10-30 11:15:46 -05:00
marc bassil
189b0591ef Updating message when project is locked. 2018-10-26 14:03:08 -04:00
Matt McFarland
05a0b09402 Remove unneccessary NewRepo call in tests 2018-10-16 12:47:26 -05:00
Matt McFarland
901cc0aa20 Update per requested changes, fix typos in test comments 2018-10-16 12:43:13 -05:00
Matt McFarland
23b56238b1 Add initial implementation of --silence-whitelist-errors server flag 2018-10-11 15:25:24 -05:00
Luke Kysow
e98caf3094 Quote args and plan path that may contain spaces.
Bitbucket repo owner names can contain spaces. Need to quote everywhere
these might be used because we're executing with sh -c.
2018-10-01 19:04:48 -05:00
Luke Kysow
e69c36ad55 Add new -var args for tf plan.
Previously we added -var atlantis_repo=runatlantis/atlantis but the '/'
character is not a valid character for the AWS assume role session name.
To fix this, this commit adds -var atlantis_repo_owner=runatlantis and
-var atlantis_repo_name=atlantis (where runatlantis and atlantis would
be the values for the repo the pull request is from ).
2018-10-01 11:35:45 -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
c56aa9e104 Quote the -out variable in terraform plan.
Fixes #290. In Bitbucket Server, the repo owner name can have spaces.
This causes errors when running terraform plan -out path with spaces so
we need to quote it: terraform plan -out "path with spaces".
2018-09-27 15:40:47 -05:00
Jeremy Olexa
c278bac6be Execute tf with vars that give source of run.
Add new variables to execute TF with:
  -var atlantis_repo=owner/repo
  -var atlantis_pull_num=10

These can be used within TF to set the session_name of the AWS session
that Terraform creates. This allows all API calls to be traced back to a
specific pull request and user.
2018-09-25 12:31:20 -05:00
Luke Kysow
411b8f87f1 Merge pull request #278 from runatlantis/commentfolding
Fold long output. Fix diff highlighting.
2018-09-15 09:17:58 -07: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
e8c7d819b5 Inputfalse (#277)
Add input=false to init, plan, and apply step runners
2018-09-14 14:47:51 -07:00
Luke Kysow
af419ef3e1 Fix gometalint errors 2018-09-07 10:54:48 -07:00
Luke Kysow
f057d6d7d9 Merge pull request #247 from runatlantis/godocs
Add godocs. Refactor ProjectResult. Golint errors.
2018-09-07 10:39:42 -07:00
Luke Kysow
e9b7001266 Add godocs. Refactor ProjectResult. Golint errors. 2018-08-30 16:47:17 -06:00
Ben Abrams
a80e285270 change server startup log message from warn to info level
Server startup should be something expected therefore an info rather than a warning.

```
2018/08/28 18:37:50 [WARN] server: Atlantis started - listening on port 4141
```

Signed-off-by: Ben Abrams <me@benabrams.it>
2018-08-28 11:56:37 -07:00
Luke Kysow
b8a90a5807 Remove accidentally checked in file. 2018-08-23 15:43:44 -10:00
Luke Kysow
307cd31361 Release 0.4.7 2018-08-23 15:36:24 -10:00
Luke Kysow
5fb3ac115e Support GitLab subgroups.
GitLab allows repos to be nested under multiple subgroups,
for example owner/group/subgroup/subsubgroup/repo vs. owner/repo. This
change enables that functionality.
2018-08-23 10:24:54 -10:00
Luke Kysow
3e650dc3a0 Fix error parsing tf version when TF_LOG set 2018-08-21 08:52:25 -10:00
Luke Kysow
756435e467 Expose repo name, owner, and branch to run step runner for custom steps (#232)
Commits by @mootpt (squashed)
2018-08-20 11:13:27 -10:00
Luke Kysow
13f79f3963 Split init step test into its own. 2018-08-17 13:52:43 -10:00
Jeff Knurek
62f7526db4 INIT: if the init cmd fails providing more info in the logs is helpful 2018-08-17 13:51:32 -10:00
Luke Kysow
44f3036e7a New landing page 2018-08-16 13:02:09 -10: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