Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

refactor: consolidate template and workspace acl validation#19192

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
aslilac merged 16 commits intomainfromlilac/acl-update-validator
Aug 7, 2025

Conversation

aslilac
Copy link
Member

@aslilacaslilac commentedAug 6, 2025
edited
Loading

  • AddsValidateUserIDs query andValidateGroupIDs queries
    • I know for groups I probably could've usedGetGroups, but that has a join in it and would send more data over the wire. Plus it's just nice for these two queries to have parity and there isn't a good equivalent for users already. I hope we can find more places that these will be useful.
    • Also also I looked at theEXPLAIN and this one should be faster (tho not exactly fast, it could certainly be optimized more)
  • Introduces anACLUpdateValidator interface that lets us create little adapters type for resources that implement an/acl [patch] endpoint like templates and workspaces. It handles validating UUIDs, validating role names, and ensuring that the IDs given actually correspond to IDs in the database.
  • Updates the existing endpoints to use this new interface

Emyrk reacted with heart emoji
@aslilac
Copy link
MemberAuthor

I think this should finally address all your feedback on the first PR (except for the addition of an "update ACL" verb). sorry for the delay!

Emyrk reacted with thumbs up emoji

@aslilac
Copy link
MemberAuthor

aslilac commentedAug 6, 2025
edited
Loading

also do you know how I can get sqlc to use the right name for this argument so the linters will quit yelling at me

jk, I just realized it was only yelling about a file that I can edit, not the fully generated files

@aslilacaslilac requested a review fromEmyrkAugust 6, 2025 22:40
Copy link
Member

@EmyrkEmyrk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I would like us to test sending in deleted users to theValidate. Idk if we should auto delete or what.

Can also make an issue and follow up 👍

Comment on lines +14 to +26
typeUpdateValidator[Role codersdk.WorkspaceRole| codersdk.TemplateRole]interface {
// Users should return a map from user UUIDs (as strings) to the role they
// are being assigned. Additionally, it should return a string that will be
// used as the field name for the ValidationErrors returned from Validate.
Users() (map[string]Role,string)
// Groups should return a map from group UUIDs (as strings) to the role they
// are being assigned. Additionally, it should return a string that will be
// used as the field name for the ValidationErrors returned from Validate.
Groups() (map[string]Role,string)
// ValidateRole should return an error that will be used in the
// ValidationError if the role is invalid for the corresponding resource type.
ValidateRole(roleRole)error
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

❤️

@aslilac
Copy link
MemberAuthor

I tested a deleted user in one of the template tests at least:

deletedUser.ID.String():codersdk.TemplateRoleDeleted,

I'm working on another pr right now to add the other workspace ACL endpoints and a bunch of tests for all of them

@aslilacaslilac merged commit26458cd intomainAug 7, 2025
26 checks passed
@aslilacaslilac deleted the lilac/acl-update-validator branchAugust 7, 2025 16:15
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsAug 7, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@EmyrkEmyrkEmyrk approved these changes

Assignees

@aslilacaslilac

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@aslilac@Emyrk

[8]ページ先頭

©2009-2025 Movatter.jp