-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add a flag to silence policy checks comments when there's no er…
…ror (#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
- Loading branch information
Showing
13 changed files
with
145 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
server/controllers/events/testfixtures/test-repos/policy-checks-success-silent/atlantis.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
version: 3 | ||
projects: | ||
- dir: . | ||
workspace: default |
12 changes: 12 additions & 0 deletions
12
...trollers/events/testfixtures/test-repos/policy-checks-success-silent/exp-output-apply.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
Ran Apply for dir: `.` workspace: `default` | ||
|
||
```diff | ||
|
||
Apply complete! Resources: 0 added, 0 changed, 0 destroyed. | ||
|
||
Outputs: | ||
|
||
workspace = "default" | ||
|
||
``` | ||
|
23 changes: 23 additions & 0 deletions
23
...llers/events/testfixtures/test-repos/policy-checks-success-silent/exp-output-autoplan.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
Ran Plan for dir: `.` workspace: `default` | ||
|
||
```diff | ||
|
||
Changes to Outputs: | ||
+ workspace = "default" | ||
|
||
You can apply this plan to save these new output values to the Terraform | ||
state, without changing any real infrastructure. | ||
|
||
``` | ||
|
||
* :arrow_forward: To **apply** this plan, comment: | ||
* `atlantis apply -d .` | ||
* :put_litter_in_its_place: To **delete** this plan click [here](lock-url) | ||
* :repeat: To **plan** this project again, comment: | ||
* `atlantis plan -d .` | ||
|
||
--- | ||
* :fast_forward: To **apply** all unapplied plans from this pull request, comment: | ||
* `atlantis apply` | ||
* :put_litter_in_its_place: To delete all plans and locks for the PR, comment: | ||
* `atlantis unlock` |
3 changes: 3 additions & 0 deletions
3
...trollers/events/testfixtures/test-repos/policy-checks-success-silent/exp-output-merge.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Locks and plans deleted for the projects and workspaces modified in this pull request: | ||
|
||
- dir: `.` workspace: `default` |
3 changes: 3 additions & 0 deletions
3
server/controllers/events/testfixtures/test-repos/policy-checks-success-silent/main.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
output "workspace" { | ||
value = terraform.workspace | ||
} |
28 changes: 28 additions & 0 deletions
28
...trollers/events/testfixtures/test-repos/policy-checks-success-silent/policies/policy.rego
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package main | ||
|
||
import input as tfplan | ||
|
||
deny[reason] { | ||
num_deletes.null_resource > 0 | ||
reason := "WARNING: Null Resource creation is prohibited." | ||
} | ||
|
||
resource_types = {"null_resource"} | ||
|
||
resources[resource_type] = all { | ||
some resource_type | ||
resource_types[resource_type] | ||
all := [name | | ||
name := tfplan.resource_changes[_] | ||
name.type == resource_type | ||
] | ||
} | ||
|
||
# number of deletions of resources of a given type | ||
num_deletes[resource_type] = num { | ||
some resource_type | ||
resource_types[resource_type] | ||
all := resources[resource_type] | ||
deletions := [res | res := all[_]; res.change.actions[_] == "create"] | ||
num := count(deletions) | ||
} |
12 changes: 12 additions & 0 deletions
12
server/controllers/events/testfixtures/test-repos/policy-checks-success-silent/repos.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
repos: | ||
- id: /.*/ | ||
apply_requirements: [approved] | ||
policies: | ||
owners: | ||
users: | ||
- runatlantis | ||
policy_sets: | ||
- name: test_policy | ||
path: policies/policy.rego | ||
source: local | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters