-
Notifications
You must be signed in to change notification settings - Fork 892
refactor: Return DisplayName and Name in the roles endpoint #1328
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1328 +/- ##
==========================================
+ Coverage 58.09% 66.56% +8.47%
==========================================
Files 282 280 -2
Lines 18521 18383 -138
Branches 231 235 +4
==========================================
+ Hits 10759 12237 +1478
+ Misses 6601 4902 -1699
- Partials 1161 1244 +83
Continue to review full report at Codecov.
|
Closes #1329 |
codersdk/roles.go
Outdated
return roles, json.NewDecoder(res.Body).Decode(&roles) | ||
} | ||
|
||
func RolesFromName(roleNames []string) []Role { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created this function to use in the endpoints to not break any internal implementation.
codersdk/roles.go
Outdated
return roles, json.NewDecoder(res.Body).Decode(&roles) | ||
} | ||
|
||
func RolesFromName(roleNames []string) []Role { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of having this function that may convert a role name to a role, you should just have a function in the rbac package that returns all site role objects.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting. How would you call that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I'm trying to say is we should avoid having to first get the "role names" and then convert those to "roles" in a potentially lossy fashion. We should just have a function that returns the roles instead of a function that returns the role names in the rbac package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it. I made the update, please let me know what you think about the changes. Merging it for now.
No description provided.