From cbe44ce57d8d09954e4d93d850206eb0032fc2f3 Mon Sep 17 00:00:00 2001 From: Alexander Dupuy Date: Mon, 15 Nov 2021 14:14:35 +0100 Subject: [PATCH] feat: Better message on policy failure Include the specific command `approve_policies` in the message. --- .../exp-output-auto-policy-check.txt | 4 +++- .../exp-output-auto-policy-check.txt | 4 +++- .../exp-output-auto-policy-check.txt | 4 +++- .../exp-output-auto-policy-check.txt | 4 +++- .../policy-checks/exp-output-auto-policy-check.txt | 4 +++- server/events/markdown_renderer.go | 5 +++-- server/events/markdown_renderer_test.go | 4 +++- 7 files changed, 21 insertions(+), 8 deletions(-) diff --git a/server/controllers/events/testfixtures/test-repos/policy-checks-apply-reqs/exp-output-auto-policy-check.txt b/server/controllers/events/testfixtures/test-repos/policy-checks-apply-reqs/exp-output-auto-policy-check.txt index 3e9ebf0534..60495fce53 100644 --- a/server/controllers/events/testfixtures/test-repos/policy-checks-apply-reqs/exp-output-auto-policy-check.txt +++ b/server/controllers/events/testfixtures/test-repos/policy-checks-apply-reqs/exp-output-auto-policy-check.txt @@ -10,6 +10,8 @@ FAIL - - main - WARNING: Null Resource creation is prohibit 1 test, 0 passed, 0 warnings, 1 failure, 0 exceptions ``` -* :heavy_check_mark: To **approve** failing policies either request an approval from approvers or address the failure by modifying the codebase. +* :heavy_check_mark: To **approve** failing policies an authorized approver can comment: + * `atlantis approve_policies` +* :repeat: Or, address the policy failure by modifying the codebase and re-planning. diff --git a/server/controllers/events/testfixtures/test-repos/policy-checks-diff-owner/exp-output-auto-policy-check.txt b/server/controllers/events/testfixtures/test-repos/policy-checks-diff-owner/exp-output-auto-policy-check.txt index 3e9ebf0534..60495fce53 100644 --- a/server/controllers/events/testfixtures/test-repos/policy-checks-diff-owner/exp-output-auto-policy-check.txt +++ b/server/controllers/events/testfixtures/test-repos/policy-checks-diff-owner/exp-output-auto-policy-check.txt @@ -10,6 +10,8 @@ FAIL - - main - WARNING: Null Resource creation is prohibit 1 test, 0 passed, 0 warnings, 1 failure, 0 exceptions ``` -* :heavy_check_mark: To **approve** failing policies either request an approval from approvers or address the failure by modifying the codebase. +* :heavy_check_mark: To **approve** failing policies an authorized approver can comment: + * `atlantis approve_policies` +* :repeat: Or, address the policy failure by modifying the codebase and re-planning. diff --git a/server/controllers/events/testfixtures/test-repos/policy-checks-extra-args/exp-output-auto-policy-check.txt b/server/controllers/events/testfixtures/test-repos/policy-checks-extra-args/exp-output-auto-policy-check.txt index 20ba22012c..3e51cc0bd6 100644 --- a/server/controllers/events/testfixtures/test-repos/policy-checks-extra-args/exp-output-auto-policy-check.txt +++ b/server/controllers/events/testfixtures/test-repos/policy-checks-extra-args/exp-output-auto-policy-check.txt @@ -10,6 +10,8 @@ FAIL - - null_resource_policy - WARNING: Null Resource crea 1 test, 0 passed, 0 warnings, 1 failure, 0 exceptions ``` -* :heavy_check_mark: To **approve** failing policies either request an approval from approvers or address the failure by modifying the codebase. +* :heavy_check_mark: To **approve** failing policies an authorized approver can comment: + * `atlantis approve_policies` +* :repeat: Or, address the policy failure by modifying the codebase and re-planning. diff --git a/server/controllers/events/testfixtures/test-repos/policy-checks-multi-projects/exp-output-auto-policy-check.txt b/server/controllers/events/testfixtures/test-repos/policy-checks-multi-projects/exp-output-auto-policy-check.txt index 994b49925e..2df6974dbc 100644 --- a/server/controllers/events/testfixtures/test-repos/policy-checks-multi-projects/exp-output-auto-policy-check.txt +++ b/server/controllers/events/testfixtures/test-repos/policy-checks-multi-projects/exp-output-auto-policy-check.txt @@ -30,7 +30,9 @@ FAIL - - main - WARNING: Forbidden Resource creation is pro 1 test, 0 passed, 0 warnings, 1 failure, 0 exceptions ``` -* :heavy_check_mark: To **approve** failing policies either request an approval from approvers or address the failure by modifying the codebase. +* :heavy_check_mark: To **approve** failing policies an authorized approver can comment: + * `atlantis approve_policies` +* :repeat: Or, address the policy failure by modifying the codebase and re-planning. --- diff --git a/server/controllers/events/testfixtures/test-repos/policy-checks/exp-output-auto-policy-check.txt b/server/controllers/events/testfixtures/test-repos/policy-checks/exp-output-auto-policy-check.txt index 3e9ebf0534..60495fce53 100644 --- a/server/controllers/events/testfixtures/test-repos/policy-checks/exp-output-auto-policy-check.txt +++ b/server/controllers/events/testfixtures/test-repos/policy-checks/exp-output-auto-policy-check.txt @@ -10,6 +10,8 @@ FAIL - - main - WARNING: Null Resource creation is prohibit 1 test, 0 passed, 0 warnings, 1 failure, 0 exceptions ``` -* :heavy_check_mark: To **approve** failing policies either request an approval from approvers or address the failure by modifying the codebase. +* :heavy_check_mark: To **approve** failing policies an authorized approver can comment: + * `atlantis approve_policies` +* :repeat: Or, address the policy failure by modifying the codebase and re-planning. diff --git a/server/events/markdown_renderer.go b/server/events/markdown_renderer.go index 36e7a0c680..00bddd4c6b 100644 --- a/server/events/markdown_renderer.go +++ b/server/events/markdown_renderer.go @@ -371,8 +371,9 @@ var unwrappedErrTmplText = "**{{.Command}} Error**\n" + "{{.Error}}\n" + "```" + "{{ if eq .Command \"Policy Check\" }}" + - "\n* :heavy_check_mark: To **approve** failing policies either request an approval from approvers or address the failure by modifying the codebase.\n" + - "{{ end }}" + "\n* :heavy_check_mark: To **approve** failing policies an authorized approver can comment:\n" + + " * `atlantis approve_policies`\n" + + "* :repeat: Or, address the policy failure by modifying the codebase and re-planning.{{end}}" var wrappedErrTmplText = "**{{.Command}} Error**\n" + "
Show Output\n\n" + "```\n" + diff --git a/server/events/markdown_renderer_test.go b/server/events/markdown_renderer_test.go index 0679a700b6..94fb228469 100644 --- a/server/events/markdown_renderer_test.go +++ b/server/events/markdown_renderer_test.go @@ -49,7 +49,9 @@ func TestRenderErr(t *testing.T) { models.PolicyCheckCommand, err, "**Policy Check Error**\n```\nerr\n```" + - "\n* :heavy_check_mark: To **approve** failing policies either request an approval from approvers or address the failure by modifying the codebase.\n\n", + "\n* :heavy_check_mark: To **approve** failing policies an authorized approver can comment:\n" + + " * `atlantis approve_policies`\n" + + "* :repeat: Or, address the policy failure by modifying the codebase and re-planning.\n\n" }, }