-
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.
- Loading branch information
1 parent
3d69174
commit 2de7e7a
Showing
12 changed files
with
174 additions
and
5 deletions.
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
4 changes: 4 additions & 0 deletions
4
server/controllers/events/testdata/test-repos/policy-checks-custom-run-steps/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 |
3 changes: 3 additions & 0 deletions
3
...ers/events/testdata/test-repos/policy-checks-custom-run-steps/exp-output-apply-failed.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 @@ | ||
Ran Apply for dir: `.` workspace: `default` | ||
|
||
**Apply Failed**: All policies must pass for project before running apply. |
14 changes: 14 additions & 0 deletions
14
...ontrollers/events/testdata/test-repos/policy-checks-custom-run-steps/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,14 @@ | ||
Ran Apply for dir: `.` workspace: `default` | ||
|
||
```diff | ||
null_resource.simple: | ||
null_resource.simple: | ||
|
||
Apply complete! Resources: 1 added, 0 changed, 0 destroyed. | ||
|
||
Outputs: | ||
|
||
workspace = "default" | ||
|
||
``` | ||
|
5 changes: 5 additions & 0 deletions
5
...events/testdata/test-repos/policy-checks-custom-run-steps/exp-output-approve-policies.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,5 @@ | ||
Approved Policies for 1 projects: | ||
|
||
1. dir: `.` workspace: `default` | ||
|
||
|
39 changes: 39 additions & 0 deletions
39
...vents/testdata/test-repos/policy-checks-custom-run-steps/exp-output-auto-policy-check.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,39 @@ | ||
Ran Policy Check for dir: `.` workspace: `default` | ||
|
||
**Policy Check Failed**: Some policy sets did not pass. | ||
```diff | ||
pre-conftest output | ||
|
||
``` | ||
|
||
#### Policy Set: `test_policy` | ||
```diff | ||
FAIL - <redacted plan file> - main - WARNING: Null Resource creation is prohibited. | ||
|
||
1 test, 0 passed, 0 warnings, 1 failure, 0 exceptions | ||
|
||
``` | ||
|
||
|
||
```diff | ||
post-conftest output | ||
|
||
``` | ||
|
||
#### Policy Approval Status: | ||
``` | ||
policy set: test_policy: requires: 1 approval(s), have: 0. | ||
``` | ||
* :heavy_check_mark: To **approve** this project, comment: | ||
* `atlantis approve_policies -d .` | ||
* :put_litter_in_its_place: To **delete** this plan click [here](lock-url) | ||
* :repeat: To re-run policies **plan** this project again by commenting: | ||
* `atlantis plan -d .` | ||
|
||
--- | ||
* :heavy_check_mark: To **approve** all unapplied plans from this pull request, comment: | ||
* `atlantis approve_policies` | ||
* :put_litter_in_its_place: To delete all plans and locks for the PR, comment: | ||
* `atlantis unlock` | ||
* :repeat: To re-run policies **plan** this project again by commenting: | ||
* `atlantis plan` |
35 changes: 35 additions & 0 deletions
35
...rollers/events/testdata/test-repos/policy-checks-custom-run-steps/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,35 @@ | ||
Ran Plan for dir: `.` workspace: `default` | ||
|
||
<details><summary>Show Output</summary> | ||
|
||
```diff | ||
Terraform used the selected providers to generate the following execution | ||
plan. Resource actions are indicated with the following symbols: | ||
+ create | ||
|
||
Terraform will perform the following actions: | ||
|
||
# null_resource.simple[0] will be created | ||
+ resource "null_resource" "simple" { | ||
+ id = (known after apply) | ||
} | ||
|
||
Plan: 1 to add, 0 to change, 0 to destroy. | ||
|
||
Changes to Outputs: | ||
+ workspace = "default" | ||
``` | ||
|
||
* :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 .` | ||
</details> | ||
Plan: 1 to add, 0 to change, 0 to destroy. | ||
|
||
--- | ||
* :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
...ontrollers/events/testdata/test-repos/policy-checks-custom-run-steps/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` |
7 changes: 7 additions & 0 deletions
7
server/controllers/events/testdata/test-repos/policy-checks-custom-run-steps/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,7 @@ | ||
resource "null_resource" "simple" { | ||
count = 1 | ||
} | ||
|
||
output "workspace" { | ||
value = terraform.workspace | ||
} |
28 changes: 28 additions & 0 deletions
28
...ontrollers/events/testdata/test-repos/policy-checks-custom-run-steps/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) | ||
} |
19 changes: 19 additions & 0 deletions
19
server/controllers/events/testdata/test-repos/policy-checks-custom-run-steps/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,19 @@ | ||
policies: | ||
owners: | ||
users: | ||
- runatlantis | ||
policy_sets: | ||
- name: test_policy | ||
path: policies/policy.rego | ||
source: local | ||
|
||
workflows: | ||
default: | ||
policy_check: | ||
steps: | ||
- show | ||
- run: "echo 'pre-conftest output'" | ||
- policy_check: | ||
extra_args: | ||
- --no-fail | ||
- run: "echo 'post-conftest output'" |
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