Skip to content
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

feat(user_controller): create user -> sync three roles #3555

Merged
merged 2 commits into from Jul 21, 2023

Conversation

geniuxy
Copy link
Contributor

@geniuxy geniuxy commented Jul 20, 2023

🤖 Generated by Copilot at 62c5f74

Summary

🆕📦🔒

This pull request adds role-based access control for users in the sealos system by defining three user roles (Owner, Manager, and Developer) and updating the user controller and its dependencies accordingly. It also fixes some minor formatting and naming issues in the code.

sealos users get
role-based access control
autumn leaves fall

Walkthrough

  • Define a new type UserRoleType and three constants for different user roles (Owner, Manager, and Developer) in user_types.go (link)
  • Import the userv1 package and use the UserRoleType type in rbac.go (link)
  • Modify the GetUserRole function in rbac.go to return different policy rules based on the role type (link)
  • Refactor the syncRole function in user_controller.go to create three roles for each user instead of one role with the same name as the user (link)
  • Extract the logic for creating a single role into a separate function createRole and pass the role type as a parameter in user_controller.go (link)
  • Use the GetUserRole function with the role type parameter to get the appropriate policy rules for each role in user_controller.go (link)
  • Use the OwnerRoleType constant instead of the user name for the role reference in the role binding in user_controller.go (link)
  • Use the string function to convert the UserRoleType value to a string for the role name in user_controller.go (link)
  • Update the tag of the user controller image from dev to latest in kustomization.yaml (link)
  • Rename the import alias for the k8s.io/api/rbac/v1 package from v12 to rbacv1 in user_controller.go (link, link, link)
    • Update the Watches method calls and the syncRoleBinding function to use the rbacv1 alias instead of the v12 alias for the Role, RoleBinding, and ClusterRoleBinding types in user_controller.go (link, link)
  • Add a dependency on the golang.org/x/exp package to the go.mod file (link)
  • Add checksums for the github.com/vbauerster/mpb/v7 and gopkg.in/warnings.v0 packages to the go.sum file (link, link)
  • Remove an extra newline in the kustomization.yaml file (link)
  • Correct a variable name in the syncRole function in user_controller.go (link)

@sealos-ci-robot
Copy link
Member

sealos-ci-robot commented Jul 20, 2023

🤖 Generated by lychee action

Summary

Status Count
🔍 Total 914
✅ Successful 347
⏳ Timeouts 0
🔀 Redirected 0
👻 Excluded 566
❓ Unknown 0
🚫 Errors 0

Full action output

Full Github Actions output

@codecov
Copy link

codecov bot commented Jul 20, 2023

Codecov Report

Patch and project coverage have no change.

Comparison is base (5240908) 72.97% compared to head (66b38a9) 72.97%.

❗ Current head 66b38a9 differs from pull request most recent head 9f6a3d4. Consider uploading reports for the commit 9f6a3d4 to get more accurate results

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3555   +/-   ##
=======================================
  Coverage   72.97%   72.97%           
=======================================
  Files           8        8           
  Lines         618      618           
=======================================
  Hits          451      451           
  Misses        132      132           
  Partials       35       35           

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Collaborator

@lingdie lingdie left a comment

Choose a reason for hiding this comment

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

lgtm

@lingdie lingdie merged commit 0599f60 into labring:main Jul 21, 2023
58 of 59 checks passed
@geniuxy geniuxy deleted the user_3_role branch July 25, 2023 10:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants