Commit Graph

82 Commits

Author SHA1 Message Date
jskrill
00aae565b2 feat: add autodiscover enabled feature (#3895)
* add flag to allow the user disable the autodiscover

* add global config and doc

* feat: Implement autodiscover.mode

* fix: Minor doc fixes

* fix: Small fixes to docs/indent/tests

* fix: Line length, quoting, function comments

* fix: Add a few more tests and remove newlines

* fix: Always camel case never snake

---------

Co-authored-by: Marcelo Medeiros <m.medeiros@carepay.com>
Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com>
Co-authored-by: PePe Amengual <jose.amengual@gmail.com>
2023-11-29 15:43:53 -08:00
Simon Heather
cd7ae114eb feat: add ability to track git untracked files (#3724) 2023-09-11 10:57:50 -04:00
Simon Heather
ec77a951b0 chore: Fix Go Static Check Errors (#3637)
* Fix Go Static Checks

* Fix working dir tests
2023-08-05 16:41:54 -04:00
Simon Heather
b024cef470 chore: Update server/events/working_dir Logging Configuration (#3636)
* Update server/events/working_dir logging

* Add e2e FileWorkspace logger

* Fix github app working dir test logger

* Update working_dir_test

---------

Co-authored-by: Dylan Page <dylan.page@autodesk.com>
2023-07-31 22:10:03 -04:00
Ross Strickland
76c482b83a feat: global repo params (#3379) 2023-07-07 18:33:21 -04:00
Ken Kaizu
3954955e13 fix(deps): update module github.com/petergtz/pegomock/v3 to v4 (#3534)
* fix(deps): update module github.com/petergtz/pegomock/v3 to v4 in go.mod

* remove pegomock generate m option, which is not support after v4

* make regen-mocks

* replace pegomock v4 primitive eq/matchers

* convert pegomock v4 Eq/Any matchers

* remove custom models.Repo matcher

* pegomock v4 cannot use result method args

ref https://github.com/petergtz/pegomock/issues/123

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-06-20 15:05:23 -04:00
nitrocode
79500182db chore(deps): bump tally to v4 (#3498) 2023-06-08 21:57:46 -04:00
oysteingraendsen
4e867fc36e feat: when using order group, abort plan/apply if any fail (#3323)
* feat: when using order group, abort plan/apply if any fail

* feat: add 'abort_on_execution_order_fail' flag on repo level

* feat: use runProjectCmdsParallelGroups in version_command_runner

* chore: add plan tests

---------

Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com>
2023-05-12 13:24:33 -04:00
Ross Strickland
684f2fa7e0 feat(policies): Add granular policy_sets (#3086)
* Initial work.

* Periodic push.

* Fmt and start adding args to approve_policies cmd.

* keep funcs for now.

* Periodic push.

* Periodic push.

* fmt.

* Move approve policies logic to project_command_runner.

* update some tests

* More test fixes.

* update more tests. fix som logic.

* more tests. add additional info to common data for custom templates.

* fix apply with policies bug. update more tests/fmt

* file perms

* fix error parsing for conftest results.

* Update more tests and linting.

* update documentation.

* Address no-fail case. Address comments.

* Forgot changes.

* fix markdown renderer

* Fix policy fail logic. remove uneeded tmpl var

* targeted policy approvals fix

* Address PR comments.

* empty commit to trigger build

---------

Co-authored-by: PePe Amengual <jose.amengual@gmail.com>
Co-authored-by: rkstrickland <ross.strickland@instacart.com>
Co-authored-by: Dylan Page <dylan.page@autodesk.com>
2023-04-20 21:53:46 -04:00
Isaac Wilson
089dc1aac8 fix(autoplan): modules for per-repo configs (#3272)
* Fix autoplan modules for per-repo configs

* Use utils package for slices.Contains
2023-04-03 06:25:01 -07:00
Adam Zahumenský
953de00f80 feat: --silence-no-projects to comments with -d and -p (#2969)
* Expand --silence-no-projects to targeted commands

* Cover other commands, test+docs

* Add more tests, refactor doc

* fix tests

* fix dangling pending VCS statuses

* fix: codeql yaml

* fix: lint
2023-01-24 08:26:24 -06:00
Ken Kaizu
cb0aadf571 feat: state rm (#2880)
* feat: state rm

* review feedback

* fix conflict for pegomock generation code

* adopt state command into allow-commands

* fix conflicts

* fix: state rm works on workspace

* notify import/state rm discard plan file

* fix lint

* use repeat instead warning for re-plan

* perl -pi -e 's!\* 🔁 plan file was discarded. to!🚮 A plan file was discarded. Re-plan would be required before applying.\n\n\* 🔁 To!g' server/**/*

* follow main branch
2023-01-18 22:02:18 -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
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
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
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
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
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
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
Anton Bronnikov
4cacaeb0c7 Implement branch matching in repo-level config (#2522) 2022-11-08 22:08:20 -08:00
Quan Hoang
8b20bebf16 Determine Terraform Cloud workspace from configuration (#2432) 2022-09-30 13:36:53 -07: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
485c4b508f Revert "fix: add path to WorkingDir methods (#2180)" (#2253)
This reverts commit 1a8344489f.
2022-05-13 10:19:29 -07:00
KevinSnyderCodes
1a8344489f fix: add path to WorkingDir methods (#2180)
* fix: add path to WorkingDir methods

`WorkingDirLocker` and `WorkingDir` are closely related -- the former acquires a lock, which ensures that the latter can safely operate on a given file path.

In #2131 we added `path` to the `WorkingDirLocker` lock key, but neglected to add the same to `WorkingDir`.

This commit adds `path` as an argument to certain `WorkingDir` methods, and includes `path` in the directory that we use to clone the repository for a given project.

Since `path` can include certain special characters such as `/`, we encode `path` as base32 when using it as part of a file path. This should ensure no special characters are used in the filesystem, and that the value can be decoded if desired (unlike hashes such as md5).

Additional changes:

- All calls to changed methods have been updated, including unit tests
- Mocks have been regenerated for `WorkingDir` and `WorkingDirLocker`
- `working_dir_test.go`
  - Commands that operate on filesystem paths have been updated to include the base32 encoded `path` value
  - When running `git init`, we include `-b master` as additional arguments, to ensure that `master` is our default branch (expected by the unit tests)

* Try fixing E2E tests

* Fix DefaultPendingPlanFinder

In addition to iterating over `workspaceDirs`, also iterate over `pathDirs`, and use both `workspace` and `path` to build `repoDir`.

* Fix DefaultPendingPlanFinder unit tests

* Fix DefaultProjectCommandBuilder unit tests

Co-authored-by: Kevin Snyder <kevinsnyder@KevinSnydersMBP.lan>
Co-authored-by: Kevin Snyder <kevinsnyder@ip-192-168-1-188.ec2.internal>
2022-04-08 11:55:35 -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
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
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
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
giuli007
528ee85ea8 Always use the default workspace directory when building commands context (#1620)
When pre_workflow_hooks is being used to generate atlantis.yaml
and projects are set with specific workspaces different than "default",
a different directory is created for each project-workspace pair,
but all those that are not on the "default" workspace will
not have an atlantis.yaml file at their root.

This change ensures that when atlantis is building the projects commands
for either:
- a project-specific plan, triggered via (atlantis plan -d foo -w bar)
- a project-specific apply, triggered vi (atlantis apply -d foo -w bar)
- or applies for all the plans it can find (atlantis apply)
it uses the default workspace to find the atlantis.yaml config.

Co-authored-by: giuli007 <giuglioz@gmail.com>
2021-06-24 10:16:47 -07:00
Marc Barlo
d98474a4aa Fix ParallelPlan and ParallelApply out of order in buildProjectCommandCtx (#1574)
* Fix regression - paralle plan / apply out-of-order

* Add test to check we're correctly setting ParallelPlan/Apply

* Add project command builder tests to check args

* rm vendor
2021-05-10 19:33:21 -04:00
Istvan Tapaszto
429235d40a DeleteSourceBranchOnMerge issue fixed (#1560) 2021-05-10 14:42:12 -04:00
Istvan Tapaszto
632460b20b Delete source branch on merge (#1357)
Co-authored-by: Tapaszto, Istvan <istvan.tapaszto@msciintegration.onmicrosoft.com>
2021-04-22 09:54:18 -07:00
Brian Zoetewey
f290780b61 feat: Add --autoplan-file-list server flag. (#1475)
* Add `--autoplan-file-list` server flag to allow modifying the list of files that trigger planning.

* Set default value for `--autoplan-file-list` and add `terragrunt.hcl` to the list.

* Default is handled in server now. No need for it here.

* Fix syntax error test.

* Fix e2e tests
2021-04-22 09:48:40 -07:00
laurent apollis
d2ef2775c8 Support regexp in command builder on the project name (#1419) 2021-03-05 16:13:23 -08: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
Sarvar Muminov
3456dc934b Add pre workflow custom hooks to run scripts before workflow execution(plan, apply, etc) (#1255)
* Updated runatlantis.io/docs to have `pre-workflow-hooks` use cases and examples
2020-12-14 15:19:52 -05:00
Nish Krishnan
9fa0c91bcb [1193] Fix merge strategy for gh apps 2020-10-14 17:35:38 -07:00
Luke Kysow
7363cce699 Update config-inspect version 2020-08-27 12:26:20 -07:00
Luke Kysow
cbe0b18c0e Refactor --skip-clone-no-changes work. 2020-08-18 15:48:33 -07:00
Quan Hoang
54e3dc2ef0 Skip cloning PR repository in case of no projects configured in repo config file were changed 2020-08-18 15:48:05 -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
Marc Barlo
bebfdcaeef Add back the parallel_plan repo cfg option
+ Default parallel plans breaks in a lot of autoplan scenarios i.e. with shared workspaces
+ Added a set of e2e tests to check parallel plans and applies
+ Also added an option to the Terraform client to turn off the plugin cache. This was breaking the e2e test suite (never seen this error in practice)
2020-05-07 22:14:04 -07:00
Marc Barlo
7452d6aa13 Make parallel plans the default. Add flag for parallel apply 2020-05-05 18:15:10 -07:00