Skip to content

feat: add WORKSPACE, PROJECT_NAME, and CHECK_TYPE env vars to external team_authz commands - #6710

Open
david-lawrence-tc wants to merge 2 commits into
runatlantis:mainfrom
tigertext:feat/team-authz-env-vars
Open

feat: add WORKSPACE, PROJECT_NAME, and CHECK_TYPE env vars to external team_authz commands#6710
david-lawrence-tc wants to merge 2 commits into
runatlantis:mainfrom
tigertext:feat/team-authz-env-vars

Conversation

@david-lawrence-tc

Copy link
Copy Markdown

what

  • Export WORKSPACE as an environment variable to external team_authz commands. It is always set during per-project checks, and set during pre-flight checks when the user explicitly passed -w.
  • Export PROJECT_NAME during pre-flight checks when the user explicitly passed -p (previously it was only available during per-project checks).
  • Export CHECK_TYPE (pre_flight or project) so external commands can tell which authorization phase is running and handle missing workspace/project context accordingly.
  • Document the new variables in repo-and-project-permissions.md and add tests for the external allowlist runner.

why

  • External team_authz commands currently cannot make workspace-aware authorization decisions (e.g. "only the prod team may apply in the production workspace"). The workspace is already carried on TeamAllowlistCheckerContext but was never exported to the external command's environment.
  • Because the pre-flight check runs before clone/project discovery, workspace/project context can legitimately be absent there. CHECK_TYPE makes the phase explicit so scripts don't have to infer it from the incidental emptiness of REPO_ROOT/PULL_NUM.
  • Supersedes feat: Add environment variables to external team_authz commands #6348, applying the review feedback there: the API and VERBOSE env vars have been dropped, per the maintainer suggestion to add only what solves the immediate problem.

tests

  • Added server/core/runtime/external_team_allowlist_runner_test.go covering all exported env vars, CHECK_TYPE values for both phases, empty-workspace behavior (variable set but empty), env inheritance/override, and error handling.
  • Updated TestCheckUserPermissions internal tests for the new checkUserPermissions signature.
  • go build ./... and go test ./server/events/... ./server/core/runtime/... pass locally.

references

@dosubot dosubot Bot added feature New functionality/enhancement go Pull requests that update Go code labels Jul 28, 2026
@github-actions github-actions Bot added the docs Documentation label Jul 28, 2026
…l team_authz commands

External team_authz commands previously had no way to make workspace- or
project-aware authorization decisions during the pre-flight check, and no
way to distinguish the pre-flight check from the per-project check.

- Export WORKSPACE to the external command (always set for project checks;
  set during pre-flight checks when the user passed -w explicitly)
- Export PROJECT_NAME during pre-flight checks when the user passed -p
  explicitly (previously only available for project checks)
- Export CHECK_TYPE (pre_flight | project) so scripts can apply different
  logic when workspace/project context is unavailable

Fixes runatlantis#6342

Signed-off-by: David Lawrence <161499966+david-lawrence-tc@users.noreply.github.com>
Assisted-by: Claude <noreply@anthropic.com>
@david-lawrence-tc
david-lawrence-tc force-pushed the feat/team-authz-env-vars branch from d0e1a96 to d9f8847 Compare July 28, 2026 22:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation feature New functionality/enhancement go Pull requests that update Go code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Workspace Environment Variable to External Team Authz Commands

1 participant