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

Fix bytebase nginx controller. #3111

Merged
merged 2 commits into from
May 20, 2023
Merged

Fix bytebase nginx controller. #3111

merged 2 commits into from
May 20, 2023

Conversation

zzjin
Copy link
Collaborator

@zzjin zzjin commented May 20, 2023

🤖 Generated by Copilot at ee71450

Summary

🍪🔒🌐

This pull request updates the Bytebase controller and client to use a new authentication and authorization mechanism based on login cookies, and to simplify the Bytebase CRD and the nginx configuration. It also removes some unused or redundant fields and imports, and improves the performance and consistency of the Bytebase API client. It affects the files controllers/db/bytebase/* and controllers/db/bytebase/config/crd/bases/bytebase.db.sealos.io_bytebases.yaml.

BytebaseSpec changes
login cookie and password
autumn of simpleness

Walkthrough

  • Remove the ExternalURL field from the BytebaseSpec type and the Bytebase CRD, and derive the external URL from the hostname and the default domain suffix (link, link, link)
  • Add the LoginCookie and RootPassword fields to the BytebaseSpec type and the Bytebase CRD, and store the login cookie information and the root password in the Bytebase status (link, link, link, link)
  • Remove the AuthResponse type and the GetHeaders method from the api package, and add the LoginCookie type and the GetLoginCookie method to the api package and the Client interface (link, link, link, link)
  • Modify the Login and Signup methods of the Client struct in the client package to use the login cookie instead of the web token for authentication and authorization, and remove the CheckUserExists method (link, link, link, link)
  • Modify the NewClient function in the client package to accept a Bytebase CRD object as a parameter and check if the login cookie is already set in the Bytebase status (link)
  • Modify the syncNginxIngress and getClientCookie functions in the bytebase package to use the Bytebase CRD object as a source of the login cookie information (link, link)
  • Modify the doRequest, doAuthRequest, CreateEnvironment, and CreateInstance functions in the client package and the subpackages to use the bytes package instead of the strings and io packages for creating HTTP requests with JSON payloads (link, link, link, link, link, link)
  • Remove the Debug2 field from the BytebaseControllerConfig type and the DefaultPassword field from the Reconciler struct, which are no longer needed (link, link, link)
  • Add an import statement for the api package from the bytebase client to the v1 package, and remove the import statement for the net/http package from the api package (link, link)
  • Add a line to the DeepCopyInto method of the BytebaseSpec type to copy the LoginCookie field, which is generated by the controller-runtime library (link)

By add cookie to status, to solve nginx annotation change.

Signed-off-by: zzjin <tczzjin@gmail.com>
@codecov
Copy link

codecov bot commented May 20, 2023

Codecov Report

Patch and project coverage have no change.

Comparison is base (d4bc9be) 72.97% compared to head (7cbafa3) 72.97%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3111   +/-   ##
=======================================
  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.

Signed-off-by: zzjin <tczzjin@gmail.com>
@zzjin zzjin requested a review from dinoallo May 20, 2023 16:35
@fanux fanux merged commit 6b4e561 into labring:main May 20, 2023
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants