Commit Graph

844 Commits

Author SHA1 Message Date
Quan Hoang
8b20bebf16 Determine Terraform Cloud workspace from configuration (#2432) 2022-09-30 13:36:53 -07:00
giuli007
2cd8bd9ccc Delete previous plans on autoplan or atlantis plan (#1633)
* Delete previous plans on autoplan or atlantis plan

When using non-default workspaces, plans are stored
in pr-and-workspace-specific directories.
If a PR is subsequently updated it might happen that
some of the plans are no longer relevant with regards
to the latest changes.
This change ensures that plans are always deleted
when a generic plan is triggered either by autoplan
or by a "atlantis plan" command.
NB Plans are not cleaned up when specific projects are
planned explicitly with "atlantis plan -p/-d/-w".

* Also delete locks along with plans when running
autoplan or generic plan command

* Fix Plan deletion tests after 0.19.8 rebase

* Fix Plan deletion tests after v0.19.9-pre.20220912 rebase

* Rename struct field to follow camelCase naming convention

Co-authored-by: giuli007 <giuglioz@gmail.com>
2022-09-23 14:31:24 -07:00
Alberto Llamas
9829fa23c2 Fix: Error when enabling prometheus metrics (#2379) (#2528)
Prometheus metrics names have some restrictions that must match the regex `[a-zA-Z_:][a-zA-Z0-9_:]*`
2022-09-20 21:27:30 -07:00
Brian Zoetewey
1bcf938644 Adding Redis DB option (#2527)
* Adding Redis DB option
This allows selecting something other than the default database of 0.

* Add missing db argument to fix failing tests.
2022-09-20 21:27:16 -07:00
Rui Chen
6fd8130fe1 lint: gofmt -w -s . (#2504)
Signed-off-by: Rui Chen <rui@chenrui.dev>

Signed-off-by: Rui Chen <rui@chenrui.dev>
2022-09-12 18:08:46 -07:00
Daniel Thompson
d5d8e38117 Adding Redis TLS Option (#2510)
* Adding Redis TLS option

* Test fixes and allow for tls skip verify

* Test fixes and allow for tls skip verify
2022-09-09 20:02:26 -07:00
Stas Ostrovskyi
b8297bb1f8 fix: Set mergeable correctly when branch protection doesn't require reviewers (#2470)
* Allow no required reviewers

* Fix comment in tests

Co-authored-by: Stas Ostrovskyi <stasostrovskyi@users.noreply.github.com>
2022-09-08 13:54:50 -07:00
Marc Hildenbrand
178e4a4c09 Fixes for multienv step comment (#2411)
* Fix multienv command

Correctly handles environment variable values that themselves contain "=" (e.g. AWS session tokens)

Ensures that trailing "\n" does not get published as part of the last environment variables value.

* Correct check for empty result in multienv

Check the length of the result string instead of splitting it first and checking the length of envvars (since split always returns an array of length 1)

Co-authored-by: Marc Hildenbrand <mwhildenbrand@gmail.com>
2022-09-08 11:37:09 -07:00
Rui Chen
b5e985c158 lint: remove deprecated io/util package (#2503)
As of go1.16, io/util package has been deprecated

See issue, https://github.com/golang/go/issues/42026

Signed-off-by: Rui Chen <rui@chenrui.dev>

Signed-off-by: Rui Chen <rui@chenrui.dev>
2022-09-08 13:45:00 -04:00
Andrei Vydrin
2d7ee9dfa8 feat: support parallel with execution order groups (#2403) 2022-09-08 06:14:59 -07:00
Yurii Soldak
9f31e49be8 Use single github v4 client (#2480) 2022-09-08 06:04:35 -07:00
Paul O'Connor
4143c87559 bug: Fix GitHub Markdown for added and deleted resources (#2418)
* bug: Fix GitHub Markdown for added and deleted resources

* Fix spacing in test
2022-09-07 17:48:10 -07:00
Vincent
99e1f10c2e Allow /api/ routes without WebAuthentication (#2455) 2022-09-07 17:46:18 -07:00
Daniel Thompson
ab2cdb833a External Locking DB: Redis (#2491)
* Initial build out of redis backend

* Regenerate locking mocks and matchers

* More test cleanup

* More test fixes

* Added tests for redis

* Test fix

* Linting fix

* Dcos update

* Update redis.go

* Update server.go

* Adding nolint to RedisDB struct
2022-09-07 16:57:06 -07:00
Yurii Soldak
a4a49bf46f Use proper http client for github v4 api (#2479)
* Use proper http client for github v4 api

* Remove extra print lines

Co-authored-by: Ray Terrill <rayterrill@users.noreply.github.com>
2022-09-07 16:51:23 -07:00
Håvard Anda Estensen
e1862f0e2d Omit type declaration of vars (#2476) 2022-08-30 09:45:04 -07:00
kangaechu
94c81eadfc enable hostname statsd host key (#2429) 2022-08-25 21:44:49 -07:00
Jonas
5bf7c93f3e ignore GitLab Draft MRs (#2468)
* feat: ignore GitLab Draft MRs

* deepcopy and overwrite unit under test

* add tests for close actions
2022-08-25 10:47:21 -07:00
Jack Lindamood
71233ef3b6 Allow manual PR number (#2465)
Resolves #2464
2022-08-22 11:59:16 -07:00
Ray Terrill
89d33a0737 Make required atlantis/apply status check work with mergeable (#2436)
* Make required apply work with mergeable

* Fix lint hint

* Migrate mergeable approval check to graphql, update tests

* Adding support for check suites

* Adding feature flag protection for new functionality

* Fix linting falsepos

* Adjusted logic to handle required check runs, added doc
2022-08-18 09:46:50 -07:00
Pantelis Karamolegkos
8691b5f79d Removing the check about whether a slack channel exists (#2386) 2022-07-28 08:43:13 -07:00
Rémi Lapeyre
b409cb8470 Add the /plan and /apply endpoints (#997)
* Add the /plan and /apply endpoints

* Resolve conflicts

* Fix wrong merge

* Add missing methods for mocks

* Fix linting error

* Fix linting error

* Move api plan/apply into APIController

* Extract commond code into helper functions

* Implement GetCloneURL for GitHub

Co-authored-by: Li Lin <li.lin@hashicorp.com>
2022-07-27 11:36:49 -07:00
Austin Sherron
6227b56d28 fix: Update multienv_step_runner Env Var Parsing Logic (#2351) (#2354)
* Update multienv_step_runner Env Var Parsing Logic

* Update multienv_step_runner.go to split only on the first = character
* Add affirmative and failing test cases

* Run gofmt
2022-07-27 10:40:14 -07:00
ribejara-te
e0e29bddee fix: repository cloning race condition (#2341) (#2348)
* fix: repository cloning race condition (#2341)

* fix: switched from sync to golang.org/x/sync/semaphore

* fix: check value of sem.Acquire(...)
2022-07-27 10:37:07 -07:00
Connor Edwards
4887091197 fix: use constant time comparison of webhook secret in gitlab event validator (#2392) 2022-07-15 09:54:36 -07:00
Li Lin
e153cea2bf Revert "[fix] Ignore commit checks for atlantis apply on Github (#2311)" (#2388)
* Revert "[fix] Ignore commit checks for atlantis apply on Github (#2311)"

This reverts commit a3db712920.
2022-07-13 17:11:03 -07:00
Paul O'Connor
7a6b5b85bb Only highlight Terraform changes on GitHub (#2337) 2022-07-12 08:58:39 -07:00
Casper Biering
abb9e41787 fix: Log streaming broken with TFE local execution mode (#2364) 2022-07-12 08:53:55 -07:00
David Constenla
b650303032 Add permission to allow GET required_status_checks, linked to #2310 (#2380) 2022-07-12 08:47:52 -07:00
Li Lin
6b0fe76f4e Add --var-file-allowlist in server configuration (#2362) 2022-07-07 10:32:18 -07:00
Rui Chen
2ae89d609c deps: upgrade github.com/docker/docker (#2366)
* deps: upgrade github.com/docker/docker

Signed-off-by: Rui Chen <rui@chenrui.dev>

* pkg: `docker/docker` -> moby/moby

Signed-off-by: Rui Chen <rui@chenrui.dev>
2022-07-06 20:54:48 -04:00
Andrey Vydrin
569031ab23 feat: add execution order group (#2178)
* feat: add execution order group

to apply/plan by order

* fix: use official golanci-lint script
2022-06-29 12:01:54 -07:00
PePe Amengual
77706cb578 Revert "fix: Delete locks and workdirs with potentially stale previous plans which fixes 1624 (#1704)" (#2316)
This reverts commit 82ac706273.
2022-06-28 17:54:57 -07:00
Steve Yoon
e90aa575e0 feat: Prometheus metrics support (#2204)
* support prometheus metrics

* remove redundant error checking

* load prometheus metrics config

* dynamic separator for subscopes

* removing unnecessary config file

* adding a few more metrics test cases

* remove testing handler

* fix upstream merge error
2022-06-28 08:58:15 -07:00
Dominic Barnes
5da69620cf trim whitespace from comments before parsing (#2287) 2022-06-22 11:34:12 -07:00
Aiden Scandella
ff1094fa04 feat: stream output for custom workflows (#2261)
* Start threading job output to RunStepRunner

* Strip ANSI

* Fix lint

* Use waitgroup to avoid test flakiness

* Move waitgroup higher

* Add ANSI test and use strings.Builder

* Fix lint

* Use errors.Wrap per style guide

* Create ShellCommandRunner to encapsulate streaming

* WIP: shell command runner

* Update signatures to propagate error finding version

* Fix log output

* Fix error checking

* Fix accidental whitespace stripping

* Remove unused struct field

* Fix error checking in terraform client

* Add unit tests to verify command output handler was called

* Remove err from async interface

* Remove duplicative log now that shell command runner does it

* Hide output in stream for env/multienv

* Add comment explaining goroutines

* Use printf for better macOS compatibility
2022-06-22 09:29:41 -07:00
Rui Chen
56d463be94 test: update null provider to support test run on m1 machine (#2318)
error message:
```
- Finding hashicorp/null versions matching "3.0.0"...
╷
│ Error: Incompatible provider version
│
│ Provider registry.terraform.io/hashicorp/null v3.0.0 does not have a package
│ available for your current platform, darwin_arm64.
│
│ Provider releases are separate from Terraform CLI releases, so not all providers
│ are available for all platforms. Other versions of this provider may have
│ different platforms supported.
```

Signed-off-by: Rui Chen <rui@chenrui.dev>
2022-06-16 17:29:14 -04:00
Michel Z. Santello
df0d58d29b fix: vcs-status-name hardcoded in PullIsMergeable function (#2312)
* feat: add userConfig.VCSStatusName to applyCommandRunner context

* fix: use vcsstatusname from context

* chore: normalize tests

* chore: update interface mock
2022-06-16 09:26:20 -07:00
Rui Chen
6f7f8f2c5c test: update tests per command package refactoring (#2317) 2022-06-13 17:16:13 -04:00
Chico Venancio
a3db712920 [fix] Ignore commit checks for atlantis apply on Github (#2311)
* [fix] Ignore commit checks for atlantis apply on Github

* Fix typo

* Fmt

* lint
2022-06-13 09:40:05 -07:00
giuli007
82ac706273 fix: Delete locks and workdirs with potentially stale previous plans which fixes 1624 (#1704)
* Delete previous plans on autoplan or atlantis plan

When using non-default workspaces, plans are stored
in pr-and-workspace-specific directories.
If a PR is subsequently updated it might happen that
some of the plans are no longer relevant with regards
to the latest changes.
This change ensures that plans are always deleted
when a generic plan is triggered either by autoplan
or by a "atlantis plan" command.
NB Plans are not cleaned up when specific projects are
planned explicitly with "atlantis plan -p/-d/-w".

* Use DeleteLockCommand to delete locks and workdirs
containing previous plans

Co-authored-by: giuli007 <giuglioz@gmail.com>
2022-06-10 21:18:01 -07:00
Quan Hoang
3744535dac Further parse Gitlab MergeRequest Update events (#1301) 2022-06-09 20:42:58 -07:00
nitrocode
2b772541f5 Add version to /status endpoint (#2295)
* Add version to /status endpoint

* Add version to test

* Fix linting errors
2022-06-05 20:06:37 -07:00
nitrocode
82cf170d8f Ignore gpg signing for tests (#2296) 2022-06-05 20:06:24 -07:00
Aiden Scandella
80ac130d08 fix: update homepage link on project job output page (#2262)
Currently the link goes to "" on my install, which browsers interpret as
the current page. Looking at the other templates in this file, it was
missing a trailing `/`.
2022-05-18 20:19:09 -04:00
Aiden Scandella
8bc3c087bc fix: working dir tests initial branch assumes "master" (#2264)
This fixes the tests to not rely in the implicit value of the
"defaultBranch" git configuration value, since they later assume that
it's "master".

For example, if you run:

```sh
git config --global init.defaultBranch main
```

And then run these tests, you get:

```sh
--- FAIL: TestClone_CheckoutMergeNoneExisting (0.68s)
    working_dir_test.go:71: err running "git checkout master": error:
    pathspec 'master' did not match any file(s) known to git

    --- FAIL: TestClone_CheckoutMergeNoReclone (0.68s)
        working_dir_test.go:127: err running "git checkout master":
        error: pathspec 'master' did not match any file(s) known to git

        --- FAIL: TestClone_CheckoutMergeNoRecloneFastForward (0.68s)
            logger.go:130: 2022-05-17T10:05:33.665-0700 INFO    creating
            dir "/tmp/3762936464/repos/0/default"
                working_dir_test.go:198: unexpected error: running git
                clone --branch master --single-branch
                file:///tmp/3657236513 /tmp/3762936464/repos/0/default:
                Cloning into '/tmp/3762936464/repos/0/default'...
                        warning: Could not find remote branch master to
                        clone.
                                fatal: Remote branch master not found in
                                upstream origin
                                        : exit status 128
                                        --- FAIL:
                                        TestClone_CheckoutMergeConflict
                                        (0.68s)
      working_dir_test.go:232: err running "git checkout master": error:
      pathspec 'master' did not match any file(s) known to git

      --- FAIL: TestClone_MasterHasDiverged (0.68s)
          working_dir_test.go:344: err running "git clone --branch
          master --single-branch /tmp/1931262087 .": Cloning into '.'...
                  warning: Could not find remote branch master to clone.
                          fatal: Remote branch master not found in
                          upstream origin

                          --- FAIL: TestHasDiverged_MasterHasDiverged
(0.68s)
      working_dir_test.go:415: err running "git clone --branch master
      --single-branch /tmp/2356723317 .": Cloning into '.'...
              warning: Could not find remote branch master to clone.
                      fatal: Remote branch master not found in upstream
                      origin

                      FAIL
                      FAIL
                      github.com/runatlantis/atlantis/server/events
                      7.269s
                      FAIL
```
2022-05-17 10:55:02 -07:00
Aiden Scandella
517358e612 Fix branch CI pipeline due to unchecked err in test (#2263)
Currently this is failing on PRs

```
server/events/vcs/gitlab_client_test.go:301:14: Error return value of `w.Write` is not checked (errcheck)
                                                w.Write([]byte(response))
```
2022-05-17 10:33:39 -07:00
Michel Z. Santello
02a1bb6507 [fix] ignore commit status for apply jobs (#2135) (#2137)
* fix: update commit status check logic to match the commit status name

* Update server/events/vcs/gitlab_client.go

chore: simplify ignored statuses logic

Co-authored-by: Emil 'Skeen' Madsen <sovende@gmail.com>

* feat(gitlab_client_test): add PullIsMergeable test case

Co-authored-by: Emil 'Skeen' Madsen <sovende@gmail.com>
2022-05-16 14:05:47 -07:00
Petr Stroganov
4c0a44979f Add missing CleanedBasePath to GithubSetupData created by GithubAppController (#2142) 2022-05-13 14:36:36 -07:00
Istvan Tapaszto
a491542b48 feat: MultiEnv step added (#1793)
* MultiEnv step added

* Values removed from the output

* Fixing tests

* multienv_step_runner_test added

* Documentation of new feature added

* Documentatation of new feature  modified

* multienv_step test file extension changed

* Fixed multinev_step_runner test

* Enhanced debug logging in multienv_step_runner

* Enhanced errorhandling

* Test command modified

* Test command modified

* Test command modified

* Test command modified

* Errorhandling modified

* Test command modified

* Test command modified

* Create empty map in test

* Fixing test ExpOut

* Testing, refactoring, eliminating extra debug log

* MultiEnv result modified from json to plain string

* MultiEnv step Run parameter updated

* Import added

* project_command_runner updated

* project_command_runner updated

* multienv_step_runner_test updated

* multienv doc modified

* Update runatlantis.io/docs/custom-workflows.md

Co-authored-by: PePe Amengual <jose.amengual@gmail.com>

Co-authored-by: Istvan Tapaszto <istvan.tapaszto@msci.com>
Co-authored-by: PePe Amengual <jose.amengual@gmail.com>
2022-05-13 14:30:08 -07:00