sealos
sealos copied to clipboard
refactor(main): refactor user and update old user data
🤖 Generated by Copilot at cd3a87e
Summary
🚀🗑️♻️
This pull request refactors the controllers/user package to use the new config and kubeconfig packages for getting user configuration and generating kubeconfig files. It removes unused code and simplifies the role and webhook configurations. It also improves the naming and organization of the types and methods in the code.
kubeconfig
package simplifies user access code autumn leaves unused
Walkthrough
- Simplify role permissions for user API group by allowing all verbs on all resources and apiGroups (link)
- Remove unused code and webhook configurations for UserGroup and UserGroupBinding types as they are no longer using webhooks for validation or mutation (link, link, link, link, link, link)
- Move PodSecurityVersion constant from helper package to config package as it is more related to configuration than helper functions (link)
- Define functions for getting default namespace, user subjects, user namespace, and user role for user API group in config package instead of helper package for better organization and consistency (link, link, link, link, link)
- Add GetCondition and DiffCondition functions to helper package to simplify the logic of updating conditions for user API types (link, link)
- Move Cert, CSR, and Webhook types and related functions from helper package to kubeconfig package as they are more related to generating kubeconfig files than helper functions (link, link, link)
- Rename Cert, CSR, and Webhook types to CertConfig, CsrConfig, and WebhookConfig and rename their KubeConfig methods to Apply for consistency with other types and methods in kubeconfig package (link, link, link, link, link, link, link, link, link, link, link)
- Define Interface interface and DefaultConfig type in kubeconfig package to abstract the common logic of generating kubeconfig files based on different methods, such as cert, csr, token, or webhook (link)
- Define Apply method for ServiceAccountConfig type that implements Interface interface and creates or updates a service account and a secret for the user, fetches the token from the secret, and generates a kubeconfig file with the token (link)
- Define some utility functions for decoding certificates, generating random strings, and getting secret names in kubeconfig package (link)
- Modify updateCsr method in CsrConfig type to simplify the logic of creating or updating the CSR resource by checking if the csr field is already set, and to remove the unused code for setting the owner reference and label for the user API group (link, link, link)
- Modify test cases in
suite_test.go
file in kubeconfig package to use the Interface interface and the Apply method instead of the KubeConfig method for generating kubeconfig files (link, link, link, link) - Remove import statement for helper package in
controllers/account_controller.go
file as it is not needed and avoid importing the same package as the current file (link) - Remove
cache.go
file andkubeconfig.go
file as they are no longer used (link, link) - Ignore
user.env
file in.gitignore
file as it may contain sensitive information or environment variables for testing (link)
Whoa! Easy there, Partner!
This PR is too big. Please break it up into smaller PRs.
🤖 Generated by lychee action
Summary
Status | Count |
---|---|
🔍 Total | 724 |
✅ Successful | 303 |
⏳ Timeouts | 0 |
🔀 Redirected | 0 |
👻 Excluded | 420 |
❓ Unknown | 0 |
🚫 Errors | 0 |
Full action output
Codecov Report
Patch and project coverage have no change.
Comparison is base (
74944fd
) 72.97% compared to head (b08c8f2
) 72.97%.
Additional details and impacted files
@@ Coverage Diff @@
## main #3359 +/- ##
=======================================
Coverage 72.97% 72.97%
=======================================
Files 8 8
Lines 618 618
=======================================
Hits 451 451
Misses 132 132
Partials 35 35
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.