Skip to content

feat: generate RBAC scope name constants - #19896

Merged
ThomasK33 merged 1 commit into
mainfrom
thomask33/09-19-feat_add_scope_constants_generation
Sep 24, 2025
Merged

ThomasK33 merged 1 commit into
mainfrom
thomask33/09-19-feat_add_scope_constants_generation

Conversation

@ThomasK33

Copy link
Copy Markdown
Member

Generate RBAC scope name constants

This PR adds a new generated file coderd/rbac/scopes_constants_gen.go that contains typed constants for all RBAC scope names in the format Scope<Resource><Action>. For example, ScopeWorkspaceRead for the scope "workspace:read".

These constants make it easier to reference specific scopes in code without using string literals, improving type safety and making refactoring easier.

The PR:

  • Adds a new template file scripts/typegen/scopenames.gotmpl
  • Updates the typegen script to support generating scope name constants
  • Updates the Makefile to include the new generated file in build targets

@ThomasK33
ThomasK33 force-pushed the thomask33/09-19-feat_add_scope_constants_generation branch from efb80b5 to 0dadef5 Compare September 19, 2025 18:48
@ThomasK33
ThomasK33 force-pushed the thomask33/19846-build-time-check-db-enum-contains-all-rbac-scopes branch from 1d5d9f1 to ce47b02 Compare September 19, 2025 18:50
@ThomasK33
ThomasK33 force-pushed the thomask33/09-19-feat_add_scope_constants_generation branch 2 times, most recently from 0149b55 to 6de9975 Compare September 22, 2025 13:47
@ThomasK33
ThomasK33 force-pushed the thomask33/19846-build-time-check-db-enum-contains-all-rbac-scopes branch from ce47b02 to 37f92fe Compare September 22, 2025 13:47
@ThomasK33
ThomasK33 requested a review from Emyrk September 22, 2025 13:50
@ThomasK33
ThomasK33 marked this pull request as ready for review September 22, 2025 13:50
@ThomasK33
ThomasK33 force-pushed the thomask33/09-19-feat_add_scope_constants_generation branch from 6de9975 to 99afbd9 Compare September 22, 2025 15:28
@ThomasK33
ThomasK33 force-pushed the thomask33/19846-build-time-check-db-enum-contains-all-rbac-scopes branch 2 times, most recently from 9c60b1f to 2666417 Compare September 22, 2025 16:33
@ThomasK33
ThomasK33 force-pushed the thomask33/09-19-feat_add_scope_constants_generation branch 2 times, most recently from 6a22bcc to 2dc79e0 Compare September 22, 2025 17:03
@ThomasK33
ThomasK33 force-pushed the thomask33/19846-build-time-check-db-enum-contains-all-rbac-scopes branch 3 times, most recently from 3a1adbe to 9d2bcc2 Compare September 22, 2025 17:27
@ThomasK33
ThomasK33 force-pushed the thomask33/09-19-feat_add_scope_constants_generation branch from 2dc79e0 to 92537e5 Compare September 22, 2025 17:27
@ThomasK33
ThomasK33 force-pushed the thomask33/19846-build-time-check-db-enum-contains-all-rbac-scopes branch from 9d2bcc2 to ec7f46a Compare September 22, 2025 17:42
@ThomasK33
ThomasK33 force-pushed the thomask33/09-19-feat_add_scope_constants_generation branch 2 times, most recently from 4810c5e to 6d04e1c Compare September 23, 2025 08:53
@ThomasK33
ThomasK33 force-pushed the thomask33/19846-build-time-check-db-enum-contains-all-rbac-scopes branch from ec7f46a to 0fb96eb Compare September 23, 2025 08:53
@ThomasK33
ThomasK33 force-pushed the thomask33/09-19-feat_add_scope_constants_generation branch from 6d04e1c to 49feb2d Compare September 23, 2025 20:53
@ThomasK33
ThomasK33 force-pushed the thomask33/19846-build-time-check-db-enum-contains-all-rbac-scopes branch from 0fb96eb to 0d6db42 Compare September 23, 2025 20:54
@ThomasK33
ThomasK33 force-pushed the thomask33/19846-build-time-check-db-enum-contains-all-rbac-scopes branch from 0d6db42 to e0432eb Compare September 24, 2025 08:36
@ThomasK33
ThomasK33 force-pushed the thomask33/09-19-feat_add_scope_constants_generation branch from 49feb2d to a9ec515 Compare September 24, 2025 08:36
@ThomasK33
ThomasK33 force-pushed the thomask33/19846-build-time-check-db-enum-contains-all-rbac-scopes branch from e0432eb to b4b6ef1 Compare September 24, 2025 08:58
@ThomasK33
ThomasK33 force-pushed the thomask33/09-19-feat_add_scope_constants_generation branch from a9ec515 to 316bcd9 Compare September 24, 2025 08:58
@ThomasK33
ThomasK33 force-pushed the thomask33/19846-build-time-check-db-enum-contains-all-rbac-scopes branch from b4b6ef1 to cfd4f7f Compare September 24, 2025 12:51
@ThomasK33
ThomasK33 force-pushed the thomask33/09-19-feat_add_scope_constants_generation branch from 316bcd9 to 2dd3612 Compare September 24, 2025 12:51
Comment thread scripts/typegen/main.go Resolved
Comment thread scripts/typegen/main.go Resolved
@ThomasK33
ThomasK33 changed the base branch from thomask33/19846-build-time-check-db-enum-contains-all-rbac-scopes to graphite-base/19896 September 24, 2025 16:06
@ThomasK33
ThomasK33 force-pushed the thomask33/09-19-feat_add_scope_constants_generation branch from 2dd3612 to eddb2a7 Compare September 24, 2025 16:06
@graphite-app
graphite-app Bot changed the base branch from graphite-base/19896 to main September 24, 2025 16:07
@ThomasK33
ThomasK33 force-pushed the thomask33/09-19-feat_add_scope_constants_generation branch 2 times, most recently from ab8574e to cffaa05 Compare September 24, 2025 16:09
Add build-time generation of typed Go constants for all RBAC scope
names to improve type safety and prevent typos when referencing
scopes in code.

- Add scopenames.gotmpl template for generating ScopeName constants
- Extend scripts/typegen/main.go to support "scopenames" template
- Generate coderd/rbac/scopes_constants_gen.go with all typed constants
- Update Makefile to include generated file in build targets
- Constants follow pattern Scope<Resource><Action> = "resource:action"
@ThomasK33
ThomasK33 force-pushed the thomask33/09-19-feat_add_scope_constants_generation branch from cffaa05 to 84de60e Compare September 24, 2025 16:27
@ThomasK33
ThomasK33 merged commit adb7521 into main Sep 24, 2025
@ThomasK33
ThomasK33 deleted the thomask33/09-19-feat_add_scope_constants_generation branch September 24, 2025 16:40
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 24, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants