Commit Graph

32 Commits

Author SHA1 Message Date
Alexey Kosenko
1f9b90e715 feat(post-workflow-hook): pass the result status of executed command to the post hook envs (#5308)
Signed-off-by: a1k0u <alko7enko@gmail.com>
2025-02-10 21:27:30 +00:00
Pierre Guinoiseau
90b1b13b71 feat: Add support for GitLab groups (#4001)
Signed-off-by: Pierre Guinoiseau <pierre@guinoiseau.nz>
2025-01-25 18:39:37 +00:00
Andrew Borg
9e0f3d1bb5 feat: Support project-level Terraform distribution selection (#5167)
Signed-off-by: Andrew Borg <andrew.b.borg@gmail.com>
Co-authored-by: PePe Amengual <2208324+jamengual@users.noreply.github.com>
Co-authored-by: Simon Heather <32168619+X-Guardian@users.noreply.github.com>
2025-01-02 21:06:01 -08:00
Rui Chen
9babb2b044 chore: fix typo pt2 (#5203)
Signed-off-by: Rui Chen <rui@chenrui.dev>
2024-12-28 18:20:38 -05:00
Nick King
9a0c648748 feat: add ability to delegate authorization to external sources (#4864) 2024-09-03 15:39:04 -07:00
Rui Chen
8dccb2beb4 chore(lint): linting the codebase (#4668)
Signed-off-by: Rui Chen <rui@chenrui.dev>
2024-06-17 11:22:30 -04:00
Andrej Svenke
78373f690e feat: add silence_pr_comments on plan and apply (#4543) 2024-05-31 21:52:22 -04:00
Pierre Guinoiseau
82bec78dff feat: Add option to lock on apply instead of plan (#3879)
Co-authored-by: PePe Amengual <jose.amengual@gmail.com>
2024-05-16 22:27:27 -07:00
Xing Yahao
267b2f133b feat: make api plan apply support workflow hooks (#4482)
Co-authored-by: PePe Amengual <jose.amengual@gmail.com>
2024-05-01 09:06:35 -07:00
Luay-Sol
f79ece8243 feat: Add project depends on functionality (#3292)
* feat: implemented the code for the depends on functionality

Co-authored-by: Vincent <106497818+vincentgna@users.noreply.github.com>
2023-12-11 12:43:34 -08:00
PePe Amengual
d083aa119f Revert "feat: Add project depends on functionality (#3821)" (#3825)
This reverts commit cf2b7911f4.
2023-10-06 11:35:38 -04:00
Brett Galkowski
22060fe5d2 feat: Add option allowing usage of custom policy check tools (#3765)
* Adding new flag everywhere relevant, implementing policy result workaround

* Fixing unit test str matching, adding custom policy conditional to step_runner

* Adding documentation steps for custom policy tools

* Refactoring ConftestOutput attribute to PolicyOutput
2023-10-06 10:57:29 -04:00
Vincent
cf2b7911f4 feat: Add project depends on functionality (#3821)
* feat: implemented the code for the depends on functionnality

* chore: Address PR comments

---------

Co-authored-by: Luay-Sol <luay.grira@solace.com>
2023-10-06 10:10:40 -04:00
chroju
fbb12fe3b9 feat: set atlantis/apply check to successful if all plans are No Changes (#3378)
* mod: rename updateCommitStatus func

* feat: add PlannedNoChangesPlanStatus

* Add skipApplyNoChanges option to PlanCommandRunner

* Add skipApplyNoChanges option to ApplyCommandRunner

* Add --skip-apply-no-changes flag

* Fix typo

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

* Rename --skip-apply-no-changes flag

* Refactor updateCommitStatus functions

* chore(docs): add detailed use case for the flag

* test: add plan_command_runner set apply status

* feat: set apply status to successful by default when result is 'No Changes'

---------

Co-authored-by: chroju <chroju@users.noreply.github.com>
Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com>
2023-08-03 11:15:13 -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
434bab5c70 [Feature] - Add clear policy approval functionality. (#3351)
* Add clear policy approval functionality.

* Fix param name, update doc.

* fix test, add e2e test

* empty commit to re-trigger tests.

---------

Co-authored-by: PePe Amengual <jose.amengual@gmail.com>
2023-05-02 11:02:04 -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
Luke Young
5d47eeb63b feat: add plan_requirements capability (#2979)
* Add plan_requirements

* Pass pull request fetcher down to plan runner

* Adding tests

* Replace sliceContainsF with slice.Contains

* Remove policy check for plan

Co-authored-by: Casey Miller <camiller@confluent.io>
Co-authored-by: PePe Amengual <jose.amengual@gmail.com>
Co-authored-by: Casey Miller <47993553+camillsir@users.noreply.github.com>
2023-01-21 00:20:04 -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
Leandro López
04f1d062d6 Improve plan summary performance (#2907)
* Add benchmark for *PlanSuccess.Summary

This is for taking a baseline and comparing with future
improvements. I just did a test run and got the following results:

$ go test -bench=. ./server/events/command
goos: darwin
goarch: arm64
pkg: github.com/runatlantis/atlantis/server/events/command
BenchmarkPlanSuccess_Summary/empty_summary,_no_matches-10                  82564             12415 ns/op           27352 B/op        114 allocs/op
BenchmarkPlanSuccess_Summary/changes-10                                   167904              7148 ns/op           14309 B/op         69 allocs/op
BenchmarkPlanSuccess_Summary/no_changes-10                                 92410             12984 ns/op           27705 B/op        114 allocs/op
BenchmarkPlanSuccess_Summary/changes_outside_Terraform-10                  89256             13505 ns/op           27882 B/op        117 allocs/op
BenchmarkPlanSuccess_Summary/changes_and_changes_outside-10               159199              7527 ns/op           14493 B/op         72 allocs/op
PASS
ok      github.com/runatlantis/atlantis/server/events/command   7.536s

To have a better comparison I've ran all the benchmarks with 200,000
iterations, and got this:

$ go test -bench=. ./server/events/command -benchtime=200000x
goos: darwin
goarch: arm64
pkg: github.com/runatlantis/atlantis/server/events/command
BenchmarkPlanSuccess_Summary/changes_and_changes_outside-10               200000              7637 ns/op           14487 B/op         72 allocs/op
BenchmarkPlanSuccess_Summary/empty_summary,_no_matches-10                 200000             12379 ns/op           27352 B/op        114 allocs/op
BenchmarkPlanSuccess_Summary/changes-10                                   200000              7134 ns/op           14312 B/op         69 allocs/op
BenchmarkPlanSuccess_Summary/no_changes-10                                200000             12960 ns/op           27692 B/op        114 allocs/op
BenchmarkPlanSuccess_Summary/changes_outside_Terraform-10                 200000             13731 ns/op           27862 B/op        117 allocs/op
PASS
ok      github.com/runatlantis/atlantis/server/events/command   11.837s

Signed-off-by: Leandro López (inkel) <leandro.lopez@grafana.com>

* Compile summary regexps only once

By initializing these regexes at program first run instead of every
time the function is called we gain better resource usage and much
faster results, as shown in this results with 200,000 iterations as in
the previous commit:

$ go test -bench=. ./server/events/command -benchtime=200000x
goos: darwin
goarch: arm64
pkg: github.com/runatlantis/atlantis/server/events/command
BenchmarkPlanSuccess_Summary/empty_summary,_no_matches-10                 200000                29.49 ns/op            0 B/op          0 allocs/op
BenchmarkPlanSuccess_Summary/changes-10                                   200000               450.4 ns/op             0 B/op          0 allocs/op
BenchmarkPlanSuccess_Summary/no_changes-10                                200000               357.9 ns/op             0 B/op          0 allocs/op
BenchmarkPlanSuccess_Summary/changes_outside_Terraform-10                 200000               824.1 ns/op           193 B/op          3 allocs/op
BenchmarkPlanSuccess_Summary/changes_and_changes_outside-10               200000               754.8 ns/op           177 B/op          3 allocs/op
PASS
ok      github.com/runatlantis/atlantis/server/events/command   0.943s

With 200,000 iterations the results were almost immediately and I
couldn't observe the real performance, so I've removed the limitation
and got the following:

$ go test -bench=. ./server/events/command -benchtime=200000x
goos: darwin
goarch: arm64
pkg: github.com/runatlantis/atlantis/server/events/command
BenchmarkPlanSuccess_Summary/empty_summary,_no_matches-10                 200000                29.49 ns/op            0 B/op          0 allocs/op
BenchmarkPlanSuccess_Summary/changes-10                                   200000               450.4 ns/op             0 B/op          0 allocs/op
BenchmarkPlanSuccess_Summary/no_changes-10                                200000               357.9 ns/op             0 B/op          0 allocs/op
BenchmarkPlanSuccess_Summary/changes_outside_Terraform-10                 200000               824.1 ns/op           193 B/op          3 allocs/op
BenchmarkPlanSuccess_Summary/changes_and_changes_outside-10               200000               754.8 ns/op           177 B/op          3 allocs/op
PASS
ok      github.com/runatlantis/atlantis/server/events/command   0.943s

I've also compared the results of running the benchamrks with 200,000
iterations, 10 times each, and these are the results:

$ benchstat orig.txt improv.txt
name                                                old time/op    new time/op    delta
PlanSuccess_Summary/empty_summary,_no_matches-10      12.6µs ± 2%     0.0µs ± 1%   -99.90%  (p=0.000 n=10+9)
PlanSuccess_Summary/changes-10                        7.19µs ± 0%    0.36µs ± 2%   -94.96%  (p=0.000 n=8+9)
PlanSuccess_Summary/no_changes-10                     13.2µs ± 2%     0.4µs ± 0%   -97.27%  (p=0.000 n=10+9)
PlanSuccess_Summary/changes_outside_Terraform-10      13.7µs ± 1%     0.8µs ± 0%   -94.02%  (p=0.000 n=9+9)
PlanSuccess_Summary/changes_and_changes_outside-10    7.71µs ± 5%    0.75µs ± 0%   -90.21%  (p=0.000 n=10+8)

name                                                old alloc/op   new alloc/op   delta
PlanSuccess_Summary/empty_summary,_no_matches-10      27.4kB ± 0%     0.0kB       -100.00%  (p=0.000 n=10+10)
PlanSuccess_Summary/changes-10                        14.3kB ± 0%     0.0kB       -100.00%  (p=0.000 n=9+10)
PlanSuccess_Summary/no_changes-10                     27.7kB ± 0%     0.0kB       -100.00%  (p=0.000 n=10+10)
PlanSuccess_Summary/changes_outside_Terraform-10      27.9kB ± 0%     0.2kB ± 0%   -99.31%  (p=0.000 n=10+7)
PlanSuccess_Summary/changes_and_changes_outside-10    14.5kB ± 0%     0.2kB ± 0%   -98.78%  (p=0.000 n=10+8)

name                                                old allocs/op  new allocs/op  delta
PlanSuccess_Summary/empty_summary,_no_matches-10         114 ± 0%         0       -100.00%  (p=0.000 n=10+10)
PlanSuccess_Summary/changes-10                          69.0 ± 0%       0.0       -100.00%  (p=0.000 n=10+10)
PlanSuccess_Summary/no_changes-10                        114 ± 0%         0       -100.00%  (p=0.000 n=10+10)
PlanSuccess_Summary/changes_outside_Terraform-10         117 ± 0%         3 ± 0%   -97.44%  (p=0.000 n=10+10)
PlanSuccess_Summary/changes_and_changes_outside-10      72.0 ± 0%       3.0 ± 0%   -95.83%  (p=0.000 n=10+10)

Signed-off-by: Leandro López (inkel) <leandro.lopez@grafana.com>

* Remove extra allocation

There's no need for fmt.Sprintf for such a simple use.

Signed-off-by: Leandro López (inkel) <leandro.lopez@grafana.com>

* Add MarkdownRenderer benchmark for diff markdown format

Signed-off-by: Leandro López (inkel) <leandro.lopez@grafana.com>

* Compile markdown diff regexes once

This change doesn't improve performance as dramatically as the summary
regexes do, however, it does reduce the amount of resources used:

$ benchstat markdowndiff.orig.txt markdowndiff.inkel.txt
name                                                                                                                   old time/op    new time/op    delta
RenderProjectResultsWithEnableDiffMarkdownFormat/single_successful_plan_with_diff_markdown_formatted/verbose_true-10      727µs ± 0%     717µs ± 2%   -1.31%  (p=0.002 n=10+10)
RenderProjectResultsWithEnableDiffMarkdownFormat/single_successful_plan_with_diff_markdown_formatted/verbose_false-10     725µs ± 0%     715µs ± 1%   -1.33%  (p=0.000 n=9+10)

name                                                                                                                   old alloc/op   new alloc/op   delta
RenderProjectResultsWithEnableDiffMarkdownFormat/single_successful_plan_with_diff_markdown_formatted/verbose_true-10      171kB ± 0%     153kB ± 0%  -10.60%  (p=0.000 n=10+10)
RenderProjectResultsWithEnableDiffMarkdownFormat/single_successful_plan_with_diff_markdown_formatted/verbose_false-10     171kB ± 0%     153kB ± 0%  -10.60%  (p=0.000 n=10+10)

name                                                                                                                   old allocs/op  new allocs/op  delta
RenderProjectResultsWithEnableDiffMarkdownFormat/single_successful_plan_with_diff_markdown_formatted/verbose_true-10        364 ± 0%       214 ± 0%  -41.29%  (p=0.000 n=10+9)
RenderProjectResultsWithEnableDiffMarkdownFormat/single_successful_plan_with_diff_markdown_formatted/verbose_false-10       358 ± 0%       207 ± 0%  -42.05%  (p=0.000 n=10+10)

Signed-off-by: Leandro López (inkel) <leandro.lopez@grafana.com>

Signed-off-by: Leandro López (inkel) <leandro.lopez@grafana.com>
2023-01-04 12:28:51 -08:00
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
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
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
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
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
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
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
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
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
Rui Chen
b1fb97047b links(github): replace help.github.com with docs.github.com links (#2227)
* links(github): replace help.github.com with docs.github.com links

* fix another link

Signed-off-by: Rui Chen <rui@chenrui.dev>
2022-04-29 17:35:42 -04: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