Skip to content

feat: show policy approvers in PR comments#6353

Draft
edbighead wants to merge 1 commit into
runatlantis:mainfrom
edbighead:show-policy-approvers-in-comments
Draft

feat: show policy approvers in PR comments#6353
edbighead wants to merge 1 commit into
runatlantis:mainfrom
edbighead:show-policy-approvers-in-comments

Conversation

@edbighead

Copy link
Copy Markdown
Contributor

Summary

When a conftest policy check fails, Atlantis posts a GitHub comment with a "Policy Approval Status" section but doesn't indicate who is allowed to approve — forcing contributors to hunt through Atlantis config to find the right team or person to contact.

This PR surfaces the configured owner teams and users directly in the PR comment for each failing policy set:

  • Adds OwnerUsers []string and OwnerTeams []string to PolicySetResult
  • Populates them in conftest_client.go and project_command_runner.go by merging global (PolicySets.Owners) and per-set owners with case-insensitive deduplication
  • Renders approver info in both wrapped and unwrapped policy check comment templates — only when owners are configured, so existing behaviour is unchanged when no owners are set

Example output (when owners are configured):

#### Policy Approval Status:
...
* :white_check_mark: To **approve** this project, comment:
  ```shell
  atlantis approve_policies ...
  • common-policies approval required from: teams: infra-team users: alice

## Test plan

- [x] Existing unit tests pass: `go test ./server/events/... ./server/core/runtime/policy/...`
- [x] Updated `conftest_client_test.go` expected JSON strings to include new fields
- [x] Template change is backward-compatible: no output change when `OwnerUsers` and `OwnerTeams` are both empty

🤖 Generated with [Claude Code](https://claude.com/claude-code)

@edbighead edbighead force-pushed the show-policy-approvers-in-comments branch 2 times, most recently from cd890b3 to f9588ab Compare March 30, 2026 12:29
When a conftest policy check fails, include the configured owner
teams and users in the Policy Approval Status section of the PR
comment so reviewers know who to contact for approval.

- Add OwnerUsers/OwnerTeams fields to PolicySetResult
- Add PolicyOwners.MergedWith() to valid package for shared dedup logic
- Populate owner fields in conftest_client.go and project_command_runner.go
- Render approver info in policy_check_results_wrapped/unwrapped.tmpl
  only when owners are configured (no output change otherwise)

Signed-off-by: Ed Laur <eduard.laur@wolt.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@edbighead edbighead force-pushed the show-policy-approvers-in-comments branch from f9588ab to ddefb70 Compare March 30, 2026 12:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant