Commit Graph

700 Commits

Author SHA1 Message Date
Ken Kaizu
f09a9d4c01 feat: --allow-commands restricts available atlantis commands (#2877)
* feat: --allow-command configuration restricts available atlantis commands

* add version and approve_policies into allow commands defaults

* allow-commands accept all keyword which allows all commands

* remove redundant nest

* more detail abount allow-commands all keyword

* Update server/events/comment_parser.go
2022-12-27 22:52:39 -06:00
Ken Kaizu
27b9897517 chore(build): rm pegomock experimental feature for smooth mock generation (#2886)
* disable pegomock --use-experimental-model-gen, cause random fail by segv

* make regen-mocks

* fix mock code which uses non experimental pegomock codes
2022-12-27 19:58:15 -06:00
Marcus Ramberg
de953fe255 fix(command_parser): Update command parser help text (#2878)
Change it to use the new customizable executable command
2022-12-25 08:37:17 -06:00
Mattias Ängehov
35cb9b87b4 feat: Allow top-level repo level configs without projects defined (#2853)
* Allow top repo cfg keys to bet set w/o projects

This will enable top-level keys to be set in `atlantis.yaml` even when
using autoplanning strategy.

* Add tests for setting top-level keys w/o projects

Signed-off-by: Mattias Ängehov <mattias.angehov@castoredc.com>

Signed-off-by: Mattias Ängehov <mattias.angehov@castoredc.com>
Co-authored-by: PePe Amengual <jose.amengual@gmail.com>
2022-12-23 15:15:30 -06:00
Ken Kaizu
692ceae171 upgrade go-playground/validator from v9 to v10 (#2863)
Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com>
2022-12-23 11:26:07 -06:00
Ken Kaizu
eca3b536aa upgrade github.com/hashicorp/go-getter to v2 (#2865) 2022-12-23 08:25:25 -06:00
Ken Kaizu
4e0d4ecc40 feat: atlantis import (#2783)
* feat: atlantis import

* feat: atlantis import

* regenerate mock comment builder

* remove duplicate err check

* instrumented import command runner/builder

* atlantis import subcommand accept args before hyphen

* fix link checker

* docs: review feedback

* fix atlantis import options order

* Update runatlantis.io/docs/using-atlantis.md

Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com>

* Update runatlantis.io/docs/using-atlantis.md

Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com>

* Update runatlantis.io/docs/using-atlantis.md

Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com>

* Update runatlantis.io/docs/using-atlantis.md

Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com>

* Update runatlantis.io/docs/using-atlantis.md

Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com>

* Update runatlantis.io/docs/command-requirements.md

Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com>

* Update runatlantis.io/docs/command-requirements.md

Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com>

* Update runatlantis.io/docs/command-requirements.md

Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com>

* Update server/events/comment_parser.go

Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com>

* Update server/events/comment_parser.go

Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com>

* Update runatlantis.io/docs/command-requirements.md

Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com>

* Update runatlantis.io/docs/command-requirements.md

Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com>

* Update runatlantis.io/docs/command-requirements.md

Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com>

* Update runatlantis.io/docs/server-side-repo-config.md

Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com>

* Update runatlantis.io/docs/command-requirements.md

Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com>

* Update runatlantis.io/docs/command-requirements.md

Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com>

* Update runatlantis.io/docs/command-requirements.md

Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com>

* Update runatlantis.io/docs/command-requirements.md

Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com>

* Update runatlantis.io/docs/command-requirements.md

Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com>

* Update server/events/command_requirement_handler.go

Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com>

* Update server/events/command_requirement_handler_test.go

Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com>

* fix test import usage

* fix e2e expected txt

* fix doc link

* docs: workflow import stage/step

* docs fixup

Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com>
2022-12-22 18:37:29 -06:00
Adam Verigin
faa027acbd feat: Add flag to disable downloading tf for airgapped environments (#2843)
* Move terraform version listing into Terraform client

* Add flag to disable Terraform downloads

* Fallback to exact version matching if unable to list TF versions

* Add new config option to documentation

* Fix and update tests

* Fix check-lint errors

* Change option name

* Remove obsolete commented code

* Migrate version detection logic into terraform client

* Improve consistency in new function signatures & log statements

* Test requests before calling terraform-switch, to prevent unnecessary crashes

* Fix broken tests

* Silence gosec error

* Close response body
2022-12-22 13:37:35 -06:00
Fabiano Soares Honorato
9a38e35493 bugfix: Initialize metrics with empty tags (#2847)
* Initialize metrics with empty tags

* Better name for Project tags

* No need for dedicated set scope tags on metrics
2022-12-21 12:36:44 -06:00
nitrocode
b94575ac88 Use go-github v48 (#2839) 2022-12-20 10:38:21 -06:00
nitrocode
3086788cd5 chore(deps): Use google/shlex (#2840)
* Use google/shlex

* Use google/shlex (fix test)

* Run gofmt -s -w
2022-12-20 10:33:33 -06:00
Ken Kaizu
2d29db6893 fix: Policy check summary not shown outside of "Show Output" details (#2837) 2022-12-20 07:28:12 -06:00
Fabiano Soares Honorato
cb485f11ee feat: Add pre and post workflow hook status (#2441)
* Add pre and post workflow hook status

* fix missing mocks

* fix pre/post workflow hooks tests

* add cmd output to file

* fix typo

* add cmd output to file on pre workflow hooks

* Add hooks output to web UI

* Remove unnecessary dependencies

* Clean the code and make tests work again

* Make lint happy

* Small fixes, create dedicated UUID generator and docs

* Add missing commentary

* Use matchers instead of mocking for tests and fix e2e tests

* Change 'OUTPUT_FILE' to 'OUTPUT_STATUS_FILE'

* Reduce SendWorkflowHook calls on hooks

* Apply suggestions from code review

Co-authored-by: PePe Amengual <jose.amengual@gmail.com>
Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com>
2022-12-19 14:20:34 -06:00
Ken Kaizu
08e9c5a17e feat: customize atlantis.yaml file name in server side config (#2798)
* feat: customize atlantis.yaml file name in server side config

* Update server/events/vcs/bitbucketcloud/client.go

* Update server/events/vcs/bitbucketserver/client.go

* Update server/events/vcs/not_configured_vcs_client.go

* Update server/events/vcs/azuredevops_client.go

* docs: repo_config_file multiple atlantis servers usecase example

* docs: multiple atlantis server usage which show how to call one atlantis server

* Update runatlantis.io/docs/server-side-repo-config.md

* Apply suggestions from code review

* Update runatlantis.io/docs/server-side-repo-config.md

Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com>
2022-12-18 23:02:38 -06:00
Sebastian Poxhofer
01a9a5f5a7 feat: dismiss approvals when planning (#2696)
* feat: dismiss approvals when planning

* feat: add pagination and move query in separate method

* tests: add test for dismissing

* refactor: fix linting issue

* implement change requests

* Update cmd/server.go

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

Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com>
Co-authored-by: PePe Amengual <jose.amengual@gmail.com>
2022-12-18 22:31:10 -06:00
James Williams
71819a28f4 Switch clone URL structure for *.visualstudio.com URLs for AzureDevOps (#2810)
* Switch clone URL structure for visualstudio.com URLs

* Add comment for ADO URL if statement. Add test

* Test else statement in ParseAzureDevopsRepo
2022-12-18 18:32:46 -06:00
Fabiano Soares Honorato
6a7f79e749 Metrics initialization (#2767)
* Add builder metrics initialization

* Add pull_closed metrics initialization

* Add builder metrics initialization

* use InitCounter from metrics package to initialize prometheus counters
2022-12-16 22:22:06 -06:00
Ken Kaizu
8d74878f9d feat: customize vcs comment command executable name (#2805) 2022-12-16 19:16:36 -08:00
Ken Kaizu
4d957836ad Enable or disable repo_locking per repo in repos.yaml and atlantis.yaml (#2700)
* disable repo locking repos.yaml and atlantis.yaml with allow override

* rename disable_repo_locking into repo_locking

* add both enable/disable repo_locking test

Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com>
2022-12-09 16:13:31 -06:00
Fabiano Soares Honorato
66dc30e755 feat: prevent planning and applying directories outside PR scope using --restrict-file-list (#2440)
* Add --strict-plan-file-list config

* Update server.go

* Update server-configuration.md

* Update server_test.go

* Run gofmt -w

* Add --strict-plan-file-list for projects

* Add --strict-plan-file-list tests

* Change --strict-plan-file-list to --restrict-file-list

* Update --restrict-file-list documentation

* Update --restrict-file-list and --enable-regexp-cmd documentation

Co-authored-by: Fabiano Honorato <fabiano.honorato@ifood.com.br>
Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com>
Co-authored-by: PePe Amengual <jose.amengual@gmail.com>
2022-12-09 09:33:40 -06:00
Michel Z. Santello
c800f706e4 fix(gitlab_client): prevent duplicate pipelines in gitlab merge requests (#2745)
* fix(gitlab_client): change CommitStatus update logic to prevent duplicated pipelines in MRs

* chore: refactor refTarget logic

* chore: fix tests

* chore: fix lint

* chore: remove nested if
2022-12-07 13:14:39 -08:00
Chris Sainty
e60dd843f4 feat: support atlantis.yaml without defined projects (#2300)
* Support atlantis.yaml without defined projects

* Update server/events/project_command_builder.go

* Update server/events/project_command_builder.go

* Correct test of no modified projects

* Flip if statement

* Remove duplicate check on hasRepoCfg

Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com>
2022-12-01 01:03:27 -08:00
noah
61bcfbab2b feat: auto-plan projects when modules change (#2507)
* feat: auto-plan projects when modules change

Fixes #920

* rename Downstream->Dependent; docs cleanup

* chore: gofmt -s
2022-11-28 14:12:29 -08:00
nitrocode
629e688b0c Allow --gh-team-allowlist to work with team names and slugs (#2719)
* Add team slugs

* Expand test to include both names and slugs

* docs: add version document of flag before/after

* docs: this will be merged for next release
2022-11-25 12:47:49 -06:00
FBLGit
f8b1ea9b88 Detect terraform versions using >= and ~> specifiers (#1776)
* Refactor TFVersion from Dir with tfswitch lib

* Added tests and cleaned up code

* linted fmtd

* fixed conflict go.mod

* bumped to tf1.0.6

* bumped go.mod

* Update project_command_context_builder.go

* Bump warrensbox/terraform-switcher

* Fix tests

* rm redundant mocks library import

Co-authored-by: xmurias <xmurias@gmail.com>
Co-authored-by: Xavier <77047592+xavipanda@users.noreply.github.com>
Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com>
2022-11-20 21:27:17 -06:00
Ken Kaizu
cde8faaf57 Fix GitHub app uses slug as user name to work --hide-prev-plan-comments correctly (#2697)
* Fix GitHub app uses slug as user name

* Update server/events/vcs/github_credentials_test.go

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

Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com>
Co-authored-by: PePe Amengual <jose.amengual@gmail.com>
2022-11-20 16:18:34 -06:00
Alberto Rojas
949ee3fa5f metrics: Add Metrics tags to multiple Scopes (#2687)
* metrics: Add Metrics tags to multiple Scopes

* metrics: Fix base_repo and pr_number

* metrics: Refactor SetScope to SetScopeTags

* metrics: Add SetGitScopeTags function

* metrics: docs reword project_context SetScopeTags description

* metrics: test Add TestNewScope_PrometheusTaggingCapabilities
2022-11-19 08:31:46 -06:00
ribejara-te
020eeba85d upgrade Git clone locking mechanism to go1.19 (#2521)
Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com>
2022-11-18 18:19:24 -06:00
nitrocode
b760e8c869 Bump testing-env and go-cty@v1.12.1 (#2686)
* Bump github.com/zclconf/go-cty@v1.12.1

* Bump github.com/zclconf/go-cty@v1.11.1

* Bump github.com/zclconf/go-cty@v1.12.1

* Bump testing-env to latest

* Set conftest to 0.35.0

* conftest to 0.45.0, run docker tests locally

* set gha test.yml to latest testing-env image

* Update Makefile target descs, rm sudo

* Use testing-env:2022.11.17

* Add sudo back in for gha workflow

* Set conftest to 0.35.0

* test gha: rm setup

* Rename "Version" to "Conftest" for version regex

* Use cases and language import

* Use io instead of ioutil
2022-11-17 16:57:04 -06:00
nitrocode
d85662cdf1 Rename default branch to main (#2662)
* Rename default branch to main

* Bump git, curl, and openssl packages
2022-11-14 11:28:29 -06:00
nitrocode
ec995dd794 Bump all dependencies (#2675)
* Bump all dependencies using go get -u

* Added nolint: gosec for writing git creds
2022-11-14 00:50:57 -06:00
Eng Zer Jun
49c5eba458 test: use T.TempDir to create temporary test directory (#2671)
This commit replaces `os.MkdirTemp` with `t.TempDir` in tests. The
directory created by `t.TempDir` is automatically removed when the test
and all its subtests complete.

Prior to this commit, temporary directory created using `os.MkdirTemp`
needs to be removed manually by calling `os.RemoveAll`, which is omitted
in some tests. The error handling boilerplate e.g.
	defer func() {
		if err := os.RemoveAll(dir); err != nil {
			t.Fatal(err)
		}
	}
is also tedious, but `t.TempDir` handles this for us nicely.

Reference: https://pkg.go.dev/testing#T.TempDir
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2022-11-13 14:13:29 -06:00
Thomas Lorreyte
7f75002b6b feat: add policy check summary in wrapped messages (#2452)
Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com>
2022-11-12 22:45:19 -06:00
nitrocode
ac6a8239aa Use official slack/slack-go library (#2669)
* Use slack-go

* rm'ed a couple tests due open issue in pegomock
2022-11-12 20:32:19 -06:00
Ross Strickland
d620d5de98 Add custom templating support (#2647)
* added custom templates support

* made default templates DRY

* Change init to anonymous function.

* Initialize anonymous function inside var

* - Add flag/cfg param for custom template dir
- Add test for custom template

* Add documentation.

* Address PR comments.

Co-authored-by: Ricard Bejarano <ribejara@thousandeyes.com>
2022-11-11 09:56:33 -06:00
Anton Bronnikov
4cacaeb0c7 Implement branch matching in repo-level config (#2522) 2022-11-08 22:08:20 -08:00
Adam Verigin
c3462f9073 Add COMMENT_ARGS to pre/post-workflow hook execution environment (#2621) 2022-11-07 14:50:49 -06:00
Michel Z. Santello
479f2b7edb fix: prevent commit status update in incorrect MR (#2636)
* fix: prevent commit status in incorrect MR
  - closes https://github.com/runatlantis/atlantis/issues/2484

* chore: update test 'TestGitlabClient_UpdateStatus'
2022-11-04 09:22:55 -07:00
Volodymyr Stupnytskyi
4cc5cf6848 Updating diffKeywordRegex to properly handle new test case (#2551)
* new resource was added to test TestRenderProjectResultsWithEnableDiffMarkdownFormat

* Correct test case

* 1st regex change

* Adding one more pattern to regex

Co-authored-by: dyurovskykh-tivo <Dmytro.Yurovskykh@tivo.com>
2022-11-04 09:19:39 -07:00
Devan Patel
c03ef1d68f Bitbucket Server: Send password as Bearer instead of Basic Auth (#2461)
* Bitbucket Server: Send password as Bearer instead of Basic Auth

Signed-off-by: Devan Patel <Dev25@users.noreply.github.com>

* docs: Add Bearer note for Bitbucket Server auth

Signed-off-by: Dev <Dev25@users.noreply.github.com>

Signed-off-by: Devan Patel <Dev25@users.noreply.github.com>
Signed-off-by: Dev <Dev25@users.noreply.github.com>
2022-10-31 14:48:07 -07:00
Tyler Lubeck
9ab3fd2416 Add tags to project metrics (#2623)
* Add tags to project metrics

This adds a few tags that I've found useful for our monitoring of a
many-project terraform repository. There are likely more tags that can
be added in other areas, but I figured I'd start small and get feedback
before increasing the blast radius

* Add labels, handle nils, alphabetize

* Move //nolint to line of assignment
2022-10-27 20:04:06 -05:00
Marc Barlo
3bfd769211 feat: add a flag to silence policy checks comments when there's no error (#2405)
* Add a flag to silence policy checks comments when there's no error

* Add e2e test cases for the quiet policy checks flag

* add documentation for quiet-policy-checks flag

* Update user_config.go

Fix indentation

* Update user_config.go

* fmt
2022-10-26 23:35:49 -07:00
Forest Oden
d0715faee1 fix: typo in log message when running parallel plans (#2620)
Signed-off-by: Forest Oden <forest.oden@beatport.com>
2022-10-25 17:28:34 -04:00
chavacava
57b01166a6 fix #2537 by removing redundant conditional branch (#2545) 2022-10-10 21:13:24 -07:00
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
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
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
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