Commit Graph

789 Commits

Author SHA1 Message Date
KevinSnyderCodes
3ffd1c57df fix: unit tests for DefaultWorkingDirLocker.TryLock() (#2159)
* fix: add path to DefaultWorkingDirLocker.TryLock()

In the release notes for v0.13.0: https://github.com/runatlantis/atlantis/blob/master/CHANGELOG.md#features-4

> Running in parallel is only supported if you're using workspaces to separate your projects. Projects in separate directories can not be run in parallel currently.

This commit adds `path` as an argument to `DefaultWorkingDirLocker.TryLock()` and includes `path` in the `workspaceKey` used to check if a project is locked. This should allow projects in separate directories to run in parallel.

To my knowledge, there is no functional reason that projects in separate directories cannot run in parallel.

All calls to `DefaultWorkingDirLocker.TryLock()` have been updated. A new unit test `TestTryLockWithDifferentPaths` has been added to test the behavior of locking two separate directories with the same workspace name.

* Add documntation for parallel_plan and parallel_apply options

* Fix working_dir_locker_test.go

- Fix expected error message for `TestTryLock()`
- Use `.` as default path for calls to `DefaultWorkingDirLocker.TryLock()`

Co-authored-by: Kevin Snyder <kevinsnyder@ip-192-168-4-61.ec2.internal>
Co-authored-by: Kevin Snyder <kevinsnyder@ip-10-60-10-94.ec2.internal>
Co-authored-by: Kevin Snyder <kevinsnyder@Kevin-Snyders-MacBook-Pro.local>
Co-authored-by: Kevin Snyder <kevinsnyder@ip-10-60-10-189.ec2.internal>
Co-authored-by: Rui Chen <rui@chenrui.dev>
2022-03-22 15:05:00 -07:00
KevinSnyderCodes
5288389897 fix: allow projects in separate directories to run in parallel (#2131)
* fix: add path to DefaultWorkingDirLocker.TryLock()

In the release notes for v0.13.0: https://github.com/runatlantis/atlantis/blob/master/CHANGELOG.md#features-4

> Running in parallel is only supported if you're using workspaces to separate your projects. Projects in separate directories can not be run in parallel currently.

This commit adds `path` as an argument to `DefaultWorkingDirLocker.TryLock()` and includes `path` in the `workspaceKey` used to check if a project is locked. This should allow projects in separate directories to run in parallel.

To my knowledge, there is no functional reason that projects in separate directories cannot run in parallel.

All calls to `DefaultWorkingDirLocker.TryLock()` have been updated. A new unit test `TestTryLockWithDifferentPaths` has been added to test the behavior of locking two separate directories with the same workspace name.

* Add documntation for parallel_plan and parallel_apply options

Co-authored-by: Kevin Snyder <kevinsnyder@ip-192-168-4-61.ec2.internal>
Co-authored-by: Kevin Snyder <kevinsnyder@ip-10-60-10-94.ec2.internal>
2022-03-21 16:08:52 -07:00
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
Nish Krishnan
d1d1539ced feat: Add stats support for basic operations (#2147) 2022-03-18 15:18:13 -07:00
Raymond Chen
4e4568501d fix: fix unmarshall error in graphql call (#2128)
* Fix unmarshall error in GraphQL call #2090

* Add unit tests for GetTeamNamesForUser

* Fix lint error
2022-03-09 14:37:58 -08:00
rui
797b12de34 fix(gitlab): update tests (relates to #1971) (#2120)
Signed-off-by: Rui Chen <rui@chenrui.dev>
2022-03-07 12:06:56 -05:00
Maxime Brunet
24e8cf7a79 fix(bitbucketcloud)!: Use AccountID as username instead of Nickname (#2034)
* fix(bitbucketcloud)!: Use AccountID as username instead of Nickname

* Update PullRequest.Author as well

* Remove unused Nickname field
2022-03-07 11:57:10 -05:00
Frank
898118501c fix(gitlab): change pending to running state (#1971)
* fix(gitlab-client): change pending to running state

* change default state
2022-03-07 11:24:26 -05:00
Maxime Brunet
f9a41c9bc6 fix(bitbucketcloud): Ensure status key has at most 40 characters (#2037)
* fix(bitbucketcloud): Ensure status key has at most 40 characters

* Use fmt.Sprintf()
2022-03-07 11:19:55 -05:00
Andre Ziviani
1a7cc360a9 feat: add a pending status for apply when running plan command (#2053)
* add a pending status for apply when running plan command

* fix status updater logic, we should only update the status after we check if the PR is mergeable like the doc next to it says

* do not dismiss the PR if the only our "atlantis/apply" status is pending/failing

* fix logic and tests

* linting
2022-03-04 14:49:54 -05:00
Javier Palomo
7c89523319 fix(web-templates): use CleanedBasePath for titles (#2091)
A follow-up to https://github.com/runatlantis/atlantis/pull/2079

After upgrading to https://github.com/runatlantis/atlantis/releases/tag/v0.18.3 in our own
infra, I noticed a minor issue with the links in the titles, they are still pointing to /
even when '--atlantis-url' is provided.
2022-03-01 14:18:03 -05:00
Javier Palomo
51d434d46b fix(web-templates): use CleanedBasePath for static content (#2079)
* fix(web-templates): use CleanedBasePath for static content

When setting '--atlantis-url' this static content 404s.

For example, we can see this when comparig:
- /lock --> works seamless with a custom `--atlantis-url`
- /jobs --> doesn't work when using a custom `--atlantis-url`

* fix(web-templates): regenerate bindata_assetfs
2022-02-28 10:43:39 -05:00
Pantelis Karamolegkos
6248472237 Removing web credentials from debug log (#2072)
* Hashing web credentials

* Fix syntactic error

* Using strong cryptogrpahic primitive

* Entirely removing credentials

* Removing unused constant

* Removing redundant formatting parameters
2022-02-17 15:38:09 -08:00
Aayush Gupta
58e9b42bbc feat: Use UUIDs to identify log streaming jobs (#2051)
* Add UUID for Log Streaming Job ID (#167)

* Update log handler to close buffered  channels when an operation is complete (#170)

* Add preliminary check before registering new receivers in the log handler (#173)

* Using projectOutputBuffers to check for jobID instead of receiverBuffers (#181)

* Refactor log handler  (#175)

* Reverting go.mod and go.sum

* Fix lint errors

* Fix linting
2022-02-09 13:15:49 -08:00
Raymond Chen
136b23ac11 fix: get user teams with GitHub GraphQL API (#2045) 2022-02-04 19:47:30 -05:00
Sarvar Muminov
7a927c050b Moving config files to core/config (#2036)
* Moving config files to core/config

* fix package names

* fix package dependencies

* linting fixes

* more linting fixes

* ran golangci-lint run --fix
2022-02-03 11:06:04 -08:00
Roman Pertsev
576f8fbf4b Fix URL generation (#2021)
* fix org generation

* fix key generation

* fix variable name

* add normalization vars

* encapsulate vars

Co-authored-by: Roman Pertsev <roman.pertsev@nordigy.ru>
2022-01-31 12:15:16 -07:00
Iain Lane
e3f0dd5553 Retry /files/ requests to github (#2002)
Similar to #1131, we see this for /files/ too, resulting in a plan
error.

Closes #1905
2022-01-25 09:49:11 -05:00
Aayush Gupta
7d3f3fb490 fix: broken Log Streaming URL when working directory is set to "./" (#2015)
* Replacing . with _ when generating project identifier if project name is not set

* Adding test for GenerateProjectJobURL when working dir set to .

* Replacing . with _ when generating project identifier if project name is not set

* Fixing merge conflicts
2022-01-24 12:18:50 -08:00
Aayush Gupta
e20e1328f2 Update GenerateProjectJobURL to account for nested repo names (#2012) 2022-01-24 10:30:18 -08:00
Leandro López
ca28b577a4 chore: improve /healthz endpoint performance (#2014)
* Add benchmark for /healthz endpoint

This benchmark will measure not only speed but also how much memory
each request to /healthz allocate. I'm adding the benchmark to have a
baseline to compare.

Signed-off-by: Leandro López (inkel) <inkel.ar@gmail.com>

* Hardcode /healthz body into a variable

We know it will always be this value, there's no need to import and
call json.MarshalIndent.

Signed-off-by: Leandro López (inkel) <inkel.ar@gmail.com>

* Initialize /healthz body only once

Signed-off-by: Leandro López (inkel) <inkel.ar@gmail.com>
2022-01-22 23:08:12 -05:00
Aayush Gupta
e06d181272 fix: add back basic auth support (#2008)
* Fix issue 1980

* Adding comment
2022-01-20 00:32:14 -05:00
Braden Schaeffer
1811514ecf Fix support for terraform workspaces (#2006)
Fixes #1517 and basically is a rebased version of #1578.
2022-01-18 11:56:20 -08:00
Ed Laur
1b30fe0456 Make IsOwner policy check case-insensitive (#1989) 2022-01-14 12:56:58 -08:00
Tim McFadden
b859f72561 feat: post workflow hooks (#1990)
* Add post-workflow hooks

* docs: Add cost estimation as post workflow use case

Co-authored-by: Gerald Barker <geraldbarker@gmail.com>
2022-01-12 19:57:45 -05:00
Jordy Ruiter
0092cfbd56 Add XTerm JS to the server static files (#1985) 2022-01-12 14:52:43 -08:00
Gerald Barker
8f98558f54 Fix autoplan when .terraform.lock.hcl is modifed (#1991) 2022-01-12 11:17:43 -08:00
Bruno Ferreira
cc513d4ef1 fix: allowed regexp prefixes for exact matches (#1962)
* test: adds failing test case

* fix: return project if there's an exact match, even if the prefix is not on the allowed list
2022-01-05 11:16:28 -05:00
Nish Krishnan
b7b28b807a fix: default permissions for gh-team-allowlist. (#1974)
* Fix default permissions for gh-team-allowlist.

* Fix broken links.
2022-01-04 11:20:29 -08:00
Nish Krishnan
64612019f4 Revert "feat: filter out atlantis/apply from mergeability clause (#18… (#1968)
* Revert "feat: filter out atlantis/apply from mergeability clause (#1856)"

This reverts commit d01796b9d9.

* Add missing import.
2022-01-01 15:11:39 -05:00
Aayush Gupta
004074a29f feat: streaming terraform logs in real-time (#1937) 2021-12-30 09:52:52 -05:00
Justin Roberson
6dda3dfde1 fix: fallback to default TF version in apply step (#1931)
The plan step has a mechanism to use the default tf version from the Terraform
client if the context does not define one, however the apply step does not have
this. This results in remote executions of apply failing with a nil pointer
dereference when it checks tfVersion in StripRefreshingFromPlanOutput. This fix
involves copying what the PlanStepRunner does and falls back to the default
version if the context's version is nil.
2021-12-22 14:54:14 -05:00
Paul Erickson
bc368465a0 feat: add GitHub team allowlist configuration option (#1694)
* Add GitHub team allowlist configuration option

Co-authored-by: PePe (Jose) Amengual <jamengual@sonatype.com>
Co-authored-by: Troy Neeriemer <tneeriemer@sonatype.com>
Co-authored-by: Ted Roby <troby+github@sonatype.com>
Co-authored-by: Paul Erickson <perickson@sonatype.com>

* Check team allowlist in command runner, rather than event controller

* Remove unneeded trimming

* Test wildcard groups and commands

* Improve error logging

Co-authored-by: PePe (Jose) Amengual <jamengual@sonatype.com>
Co-authored-by: Troy Neeriemer <tneeriemer@sonatype.com>
Co-authored-by: Ted Roby <troby+github@sonatype.com>
2021-12-21 16:08:43 -08:00
Nish Krishnan
33b4d6325a refactor: Add PullStatusFetcher interface (#1904) 2021-11-18 11:42:36 -08:00
Bruno Ferreira
79af92458a feat: adds allowed_regexp_prefixes parameter to use with the --enable-regexp-cmd flag (#1884)
* adds AllowedRegexpPrefixes config and use it on the FindProjectsByName method

* adds tests for the new AllowedRegexpPrefixes config

* update documentation with the new AllowedRegexpPrefixes config
2021-11-17 17:25:48 -05: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
Kevin Wendt
f5b6ab09ec fix: allow requests to /healthz without authentication (#1896)
* fix: allow requests to /healthz without authentication

* allow unauthed requests to /status
2021-11-14 20:02:44 -05:00
Nish Krishnan
a8bfd77452 Move runtime common under existing runtime package. (#1875) 2021-11-01 11:32:52 -07:00
Mihail Kuzmich
8c9184b80a feat: add new bitbucket server webhook event type pr:from_ref_updated (#1866) 2021-10-28 11:50:05 -07:00
Daniel Grimes
4248e2ebf4 fix(azure): allow correct path to be derived for on premise installation (#1863)
* add .devcontainer to .gitignore

* allow AzureDevOps host to be specified in the user_config

* fix spacing issues

* gofmt

* fixes to cmd and update to approach

* add specific self host fixtures

* add specific self host parser tests

* update code to azure self hosted devops

* go fmt

Co-authored-by: atlantisbot <lkysow+atlantis@gmail.com>
2021-10-26 10:34:47 -07:00
FBLGit
cbf35ca0ed feat: add BasicAuth Support to Atlantis ServeHTTP (#1777)
* Add BasicAuth Support to Atlantis ServeHTTP

* Added Security notes

Co-authored-by: xmurias <xmurias@gmail.com>
2021-10-21 14:58:30 -07:00
Nish Krishnan
d01796b9d9 feat: filter out atlantis/apply from mergeability clause (#1856)
Filter out atlantis apply status during mergeability check.
2021-10-19 13:51:22 -07:00
Daniel Grimes
571f91fbda fix(azure): allow host to be specified in user_config for on premise installation (#1860)
* add .devcontainer to .gitignore

* allow AzureDevOps host to be specified in the user_config

* fix spacing issues

* gofmt

* fixes to cmd and update to approach

Co-authored-by: atlantisbot <lkysow+atlantis@gmail.com>
2021-10-17 14:07:14 -04:00
Bea Hughes
070f5174e7 chore: use golang-jwt/jwt to replace dgrijalva/jwt-go (#1845)
* Migrate dgrijalva/jwt-go to golang-jwt/jwt/v4

dgrijalva's jwt is no longer maintained. The golang-jwt says it is a
drop in replacement for v4. This also fixes CVE-2020-26160 which
possibly won't be fixed in dgrijalva's version.

* Update occurrences of bradleyfalzon/ghinstallation to v2

v2.0.3 pulls in golang-jwt/jwt over the now unmaintained
dgrijalva/jwt-go.
2021-10-07 00:41:37 -04:00
Eng Zer Jun
38cf7b0141 refactor: move from io/ioutil to io and os package (#1843)
The io/ioutil package has been deprecated as of Go 1.16, see
https://golang.org/doc/go1.16#ioutil. This commit replaces the existing
io/ioutil functions with their new definitions in io and os packages.

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2021-10-07 00:37:42 -04:00
Nicholas (Nick) Meyer
875e2adc40 Improve github pull request call retries (#1810)
* Improve github pull request call retries

Retry with fixed 1 second backoff up to 3 retries was added by #1131 to
address #1019, but the issue continued to show up (#1453).

Increase max attempts to 5 and use exponential backoff for a maximum
total retry time of (2^n - n - 1) seconds, which is roughly 30 seconds
for current max attempts n = 5.

Also move the sleep to the top of the loop so that we never sleep
without sending the request again on the last iteration.

* Fix style with gofmt -s
2021-10-04 09:59:53 -07:00
wpbeckwith
da7e04290b Add support for deleting a branch on merge in BitBucket Server (#1792)
* Add support for deleting a branch on merge in BitBucket Server

* Add support for deleting a branch on merge in BitBucket Server

* Making linter happy although the code would fall through and return err anyway.

* Add client_test for deleting source branch

* Added err check

Co-authored-by: Wendell Beckwith <wendell.beckwith@redfin.com>
2021-09-27 09:26:37 -07:00
Aayush Gupta
bb2c239dd9 Updating client interface and adding ApprovalStatus model (#1827) 2021-09-22 12:41:05 -07:00
Masayuki Morita
4b6c2f65da build(lint): use revive instead of golint (#1801)
* Use revive instead of golint

The golint was officially deprecated.
https://github.com/golang/go/issues/38968

We have been using golint via golangci-lint and golangci-lint now
recommends using revive instead of golint.
https://golangci-lint.run/usage/linters/
> golint: The repository of the linter has been archived by the owner.
> Replaced by revive.

The revive is a drop-in replacement of golint. I think switching to
revive is a reasonable choice to check the same rules for free.
https://github.com/mgechev/revive

* Fix lint errors reported by revive

The revive is almost the same as golint, but there seems to be a bit
different results.

https://app.circleci.com/pipelines/github/runatlantis/atlantis/1519/workflows/75fd7da5-1532-4ed7-ac8a-4884902818a4/jobs/8314
https://github.com/runatlantis/atlantis/runs/3565887247?check_suite_focus=true
2021-09-10 09:14:56 -07:00
Sarvar Muminov
a2d82b9f45 Set ParallelPolicyCheckEnabled to the same value as ParallelPlanEnabled (#1802) 2021-09-09 09:21:26 -07:00