Skip to content

refactor: Add roles into the user response #1347

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

Merged
merged 9 commits into from
May 9, 2022

Conversation

BrunoQuaresma
Copy link
Collaborator

Since the roles are already returned by the User model, we just need to parse it from a rbac.Role to codersdk.Role.

Closes #1346

@BrunoQuaresma BrunoQuaresma requested review from Emyrk and a team May 9, 2022 14:39
@BrunoQuaresma BrunoQuaresma self-assigned this May 9, 2022
@BrunoQuaresma BrunoQuaresma requested a review from a team as a code owner May 9, 2022 14:39
Copy link
Contributor

@presleyp presleyp left a comment

Choose a reason for hiding this comment

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

Frontend looks good!

Copy link
Member

@kylecarbs kylecarbs left a comment

Choose a reason for hiding this comment

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

Just one tiny change!

@codecov
Copy link

codecov bot commented May 9, 2022

Codecov Report

Merging #1347 (27e14bc) into main (ad8d9dd) will decrease coverage by 0.01%.
The diff coverage is 96.15%.

@@            Coverage Diff             @@
##             main    #1347      +/-   ##
==========================================
- Coverage   66.44%   66.43%   -0.02%     
==========================================
  Files         284      280       -4     
  Lines       18584    18393     -191     
  Branches      235      235              
==========================================
- Hits        12349    12219     -130     
+ Misses       4967     4923      -44     
+ Partials     1268     1251      -17     
Flag Coverage Δ
unittest-go-macos-latest 53.60% <96.15%> (-0.11%) ⬇️
unittest-go-postgres- 65.16% <96.15%> (+0.02%) ⬆️
unittest-go-ubuntu-latest 56.11% <96.15%> (+0.09%) ⬆️
unittest-go-windows-2022 ?
unittest-js 73.67% <ø> (ø)
Impacted Files Coverage Δ
codersdk/roles.go 72.72% <ø> (-7.92%) ⬇️
site/src/testHelpers/entities.ts 100.00% <ø> (ø)
codersdk/users.go 65.17% <80.00%> (ø)
coderd/roles.go 100.00% <100.00%> (ø)
coderd/users.go 61.74% <100.00%> (+0.38%) ⬆️
cli/configssh.go 62.04% <0.00%> (-6.57%) ⬇️
coderd/httpapi/httpapi.go 71.25% <0.00%> (-6.25%) ⬇️
pty/ptytest/ptytest.go 86.95% <0.00%> (-4.35%) ⬇️
cli/templateinit.go 58.62% <0.00%> (-3.45%) ⬇️
provisioner/echo/serve.go 54.40% <0.00%> (-2.40%) ⬇️
... and 10 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ad8d9dd...27e14bc. Read the comment docs.

@BrunoQuaresma
Copy link
Collaborator Author

Interesting to see the JS tests failing because an API change 👏

coderd/roles.go Outdated
}
}

func ConvertRoles(roles []rbac.Role) []codersdk.Role {
Copy link
Member

Choose a reason for hiding this comment

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

This shouldn't be exported either!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We are using it for some tests here

ExpectedRoles: coderd.ConvertRoles(rbac.OrganizationRoles(admin.OrganizationID)),

Copy link
Member

Choose a reason for hiding this comment

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

We should never need to use internal coderd APIs to check API responses, otherwise, our customers will have to as well!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thinking on:

  • Do not export the convert functions
  • Copy the convert functions into the role tests
  • See if we need restructure the tests at all

@BrunoQuaresma BrunoQuaresma enabled auto-merge (squash) May 9, 2022 16:38
@BrunoQuaresma BrunoQuaresma merged commit e54324d into main May 9, 2022
@BrunoQuaresma BrunoQuaresma deleted the bq/add-roles-in-user-response branch May 9, 2022 16:38
@misskniss misskniss added this to the V2 Beta milestone May 15, 2022
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.

Backend add roles to the User response
4 participants