Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: clear legacy api (#12917)
ecmadaobfe84ca3afcc
diff --git a/backend/legacyapi/backup.go b/backend/legacyapi/backup.godeleted file mode 100644index 118c88b9ff..0000000000--- a/backend/legacyapi/backup.go+++ /dev/null@@ -1,15 +0,0 @@-package api--// BackupStorageBackend is the storage backend of a backup.-type BackupStorageBackend string--const (- // BackupStorageBackendLocal is the local storage backend for a backup.- BackupStorageBackendLocal BackupStorageBackend = "LOCAL"- // BackupStorageBackendS3 is the AWS S3 storage backend for a backup. Not used yet.- BackupStorageBackendS3 BackupStorageBackend = "S3"- // BackupStorageBackendGCS is the Google Cloud Storage (GCS) storage backend for a backup. Not used yet.- BackupStorageBackendGCS BackupStorageBackend = "GCS"- // BackupStorageBackendOSS is the AliCloud Object Storage Service (OSS) storage backend for a backup. Not used yet.- BackupStorageBackendOSS BackupStorageBackend = "OSS"-)diff --git a/backend/legacyapi/issue.go b/backend/legacyapi/issue.goindex 942d4855f0..6093208438 100644--- a/backend/legacyapi/issue.go+++ b/backend/legacyapi/issue.go@@ -33,24 +33,3 @@ const (func (t IssueType) String() string {return string(t)}--// IssueFieldID is the field ID for an issue.-// It has to be string type because the id for stage field contain multiple parts.-type IssueFieldID string--const (- // IssueFieldName is the field ID for name.- IssueFieldName IssueFieldID = "1"- // IssueFieldStatus is the field ID for status.- IssueFieldStatus IssueFieldID = "2"- // IssueFieldAssignee is the field ID for assignee.- IssueFieldAssignee IssueFieldID = "3"- // IssueFieldDescription is the field ID for description.- IssueFieldDescription IssueFieldID = "4"- // IssueFieldProject is the field ID for project.- IssueFieldProject IssueFieldID = "5"- // IssueFieldSubscriberList is the field ID for subscriber list.- IssueFieldSubscriberList IssueFieldID = "6"- // IssueFieldSQL is the field ID for SQL.- IssueFieldSQL IssueFieldID = "7"-)diff --git a/backend/legacyapi/policy.go b/backend/legacyapi/policy.goindex 918ebef5eb..c7ac873e84 100644--- a/backend/legacyapi/policy.go+++ b/backend/legacyapi/policy.go@@ -90,20 +90,3 @@ var (PolicyTypeIAM: {PolicyResourceTypeWorkspace},})--// SensitiveData is the value for sensitive data.-type SensitiveData struct {- Schema string `json:"schema"`- Table string `json:"table"`- Column string `json:"column"`- Type SensitiveDataMaskType `json:"maskType"`-}--// SensitiveDataMaskType is the mask type for sensitive data.-type SensitiveDataMaskType string--const (- // SensitiveDataMaskTypeDefault is the sensitive data type to hide data with a default method.- // The default method is subject to change.- SensitiveDataMaskTypeDefault SensitiveDataMaskType = "DEFAULT"-)diff --git a/backend/legacyapi/principal.go b/backend/legacyapi/principal.goindex a1edfeddca..e8c5054b78 100644--- a/backend/legacyapi/principal.go+++ b/backend/legacyapi/principal.go@@ -32,15 +32,3 @@ const (// ServiceAccountAccessKeyPrefix is the prefix for service account access key.ServiceAccountAccessKeyPrefix = "bbs_")--// PrincipalAuthProvider is the type of an authentication provider.-type PrincipalAuthProvider string--const (- // PrincipalAuthProviderBytebase is the Bytebase's own authentication provider.- PrincipalAuthProviderBytebase PrincipalAuthProvider = "BYTEBASE"- // PrincipalAuthProviderGitlab is the GitLab (for both GitLab.com and self-hosted GitLab) authentication provider.- PrincipalAuthProviderGitlab PrincipalAuthProvider = "GITLAB"- // PrincipalAuthProviderGitHub is the GitHub (for both GitHub.com and GitHub Enterprise) authentication provider.- PrincipalAuthProviderGitHub PrincipalAuthProvider = "GITHUB"-)diff --git a/backend/legacyapi/project.go b/backend/legacyapi/project.goindex d8e4e5a8f4..3eee8a8aaf 100644--- a/backend/legacyapi/project.go+++ b/backend/legacyapi/project.go@@ -1,8 +1,6 @@package apiconst (- // DefaultProjectUID is the UID for the default project.- DefaultProjectUID = 1// DefaultProjectID is the resource ID for the default project.DefaultProjectID = "default"@@ -12,8 +10,6 @@ const (// This can be mutated by the user. But for now this is only used by onboarding flow to create// a test instance after first signup, so it's safe to refer it.DefaultTestEnvironmentID = "test"- // DefaultTestEnvironmentUID is the initial resource UID for the test environment.- DefaultTestEnvironmentUID = 101// DefaultProdEnvironmentID is the initial resource ID for the prod environment.// This can be mutated by the user. But for now this is only used by onboarding flow to creatediff --git a/backend/legacyapi/setting.go b/backend/legacyapi/setting.goindex 56ec3481d4..4b0d63dd31 100644--- a/backend/legacyapi/setting.go+++ b/backend/legacyapi/setting.go@@ -1,9 +1,5 @@package api-import (- storepb "github.com/bytebase/bytebase/proto/generated-go/store"-)-// SettingName is the name of a setting.type SettingName string@@ -45,15 +41,3 @@ const (// SettingMaskingAlgorithms is the setting name for masking algorithms.SettingMaskingAlgorithm SettingName = "bb.workspace.masking-algorithm")--// SettingWorkspaceMailDeliveryValue is the setting value of SettingMailDelivery type setting.-type SettingWorkspaceMailDeliveryValue struct {- SMTPServerHost string `json:"smtpServerHost"`- SMTPServerPort int `json:"smtpServerPort"`- SMTPUsername string `json:"smtpUsername"`- SMTPPassword *string `json:"smtpPassword"`- SMTPFrom string `json:"smtpFrom"`- SMTPAuthenticationType storepb.SMTPMailDeliverySetting_Authentication `json:"smtpAuthenticationType"`- SMTPEncryptionType storepb.SMTPMailDeliverySetting_Encryption `json:"smtpEncryptionType"`- SMTPTo string `json:"sendTo"`-}diff --git a/backend/legacyapi/stage.go b/backend/legacyapi/stage.godeleted file mode 100644index b6837607c3..0000000000--- a/backend/legacyapi/stage.go+++ /dev/null@@ -1,14 +0,0 @@-package api--// StageStatusUpdateType is the type of the stage status update.-// StageStatusUpdate is a computed event of the contained tasks.-type StageStatusUpdateType string--const (- // StageStatusUpdateTypeEnd means the stage ends. A stage can end multiple times.- // A stage ends if its contained tasks have finished running, i.e. the status of which is one of- // - DONE- // - FAILED- // - CANCELED- StageStatusUpdateTypeEnd StageStatusUpdateType = "END"-)diff --git a/backend/runner/mail/slow_query_weekly_mail.go b/backend/runner/mail/slow_query_weekly_mail.goindex c44e077c55..6e29944f5c 100644--- a/backend/runner/mail/slow_query_weekly_mail.go+++ b/backend/runner/mail/slow_query_weekly_mail.go@@ -96,12 +96,11 @@ func (s *SlowQueryWeeklyMailSender) sendEmail(ctx context.Context, now time.Timereturn}- var storeValue storepb.SMTPMailDeliverySetting- if err := common.ProtojsonUnmarshaler.Unmarshal([]byte(mailSetting.Value), &storeValue); err != nil {+ storeValue := &storepb.SMTPMailDeliverySetting{}+ if err := common.ProtojsonUnmarshaler.Unmarshal([]byte(mailSetting.Value), storeValue); err != nil {slog.Error("Failed to unmarshal setting value", log.BBError(err))return}- apiValue := convertStorepbToAPIMailDeliveryValue(&storeValue)consoleRedirectURL := "www.bytebase.com"workspaceProfileSettingName := api.SettingWorkspaceProfile@@ -150,8 +149,7 @@ func (s *SlowQueryWeeklyMailSender) sendEmail(ctx context.Context, now time.Timeslog.Error("Failed to list dba users", log.BBError(err))} else {for _, user := range users {- apiValue.SMTPTo = user.Email- if err := s.sendNeedConfigSlowQueryPolicyEmail(apiValue, consoleRedirectURL); err != nil {+ if err := s.sendNeedConfigSlowQueryPolicyEmail(storeValue, user.Email, consoleRedirectURL); err != nil {slog.Error("Failed to send need config slow query policy email", slog.String("user", user.Name), slog.String("email", user.Email), log.BBError(err))}}@@ -162,8 +160,7 @@ func (s *SlowQueryWeeklyMailSender) sendEmail(ctx context.Context, now time.Timeslog.Error("Failed to list owner users", log.BBError(err))} else {for _, user := range users {- apiValue.SMTPTo = user.Email- if err := s.sendNeedConfigSlowQueryPolicyEmail(apiValue, consoleRedirectURL); err != nil {+ if err := s.sendNeedConfigSlowQueryPolicyEmail(storeValue, user.Email, consoleRedirectURL); err != nil {slog.Error("Failed to send need config slow query policy email", slog.String("user", user.Name), slog.String("email", user.Email), log.BBError(err))}}@@ -177,8 +174,7 @@ func (s *SlowQueryWeeklyMailSender) sendEmail(ctx context.Context, now time.Timeslog.Error("Failed to list dba users", log.BBError(err))} else {for _, user := range users {- apiValue.SMTPTo = user.Email- if err := send(apiValue, fmt.Sprintf("Database slow query weekly report %s", generateDateRange(now)), body); err != nil {+ if err := send(storeValue, user.Email, fmt.Sprintf("Database slow query weekly report %s", generateDateRange(now)), body); err != nil {slog.Error("Failed to send need config slow query policy email", slog.String("user", user.Name), slog.String("email", user.Email), log.BBError(err))}}@@ -214,9 +210,8 @@ func (s *SlowQueryWeeklyMailSender) sendEmail(ctx context.Context, now time.Timeif user.ID == api.SystemBotID {continue}- apiValue.SMTPTo = user.Emailsubject := fmt.Sprintf("%s database slow query weekly report %s", project.Title, generateDateRange(now))- if err := send(apiValue, subject, body); err != nil {+ if err := send(storeValue, user.Email, subject, body); err != nil {slog.Error("Failed to send need config slow query policy email", slog.String("user", user.Name), slog.String("email", user.Email), log.BBError(err))}}@@ -421,22 +416,22 @@ func engineTypeString(engine storepb.Engine) string {return ""}-func send(mailSetting *api.SettingWorkspaceMailDeliveryValue, subject string, body string) error {+func send(mailSetting *storepb.SMTPMailDeliverySetting, to, subject, body string) error {email := mail.NewEmailMsg()- email.SetFrom(fmt.Sprintf("Bytebase <%s>", mailSetting.SMTPFrom)).- AddTo(mailSetting.SMTPTo).+ email.SetFrom(fmt.Sprintf("Bytebase <%s>", mailSetting.From)).+ AddTo(to).SetSubject(subject).SetBody(body)- client := mail.NewSMTPClient(mailSetting.SMTPServerHost, mailSetting.SMTPServerPort)- client.SetAuthType(convertToMailSMTPAuthType(mailSetting.SMTPAuthenticationType)).- SetAuthCredentials(mailSetting.SMTPUsername, *mailSetting.SMTPPassword).- SetEncryptionType(convertToMailSMTPEncryptionType(mailSetting.SMTPEncryptionType))+ client := mail.NewSMTPClient(mailSetting.Server, int(mailSetting.Port))+ client.SetAuthType(convertToMailSMTPAuthType(mailSetting.Authentication)).+ SetAuthCredentials(mailSetting.Username, mailSetting.Password).+ SetEncryptionType(convertToMailSMTPEncryptionType(mailSetting.Encryption))if err := client.SendMail(email); err != nil {return err}- slog.Debug("Successfully sent need configure slow query policy email", slog.String("to", mailSetting.SMTPTo), slog.String("subject", subject))+ slog.Debug("Successfully sent need configure slow query policy email", slog.String("to", to), slog.String("subject", subject))return nil}@@ -704,7 +699,7 @@ func engineOrder(engine storepb.Engine) int {}}-func (*SlowQueryWeeklyMailSender) sendNeedConfigSlowQueryPolicyEmail(mailSetting *api.SettingWorkspaceMailDeliveryValue, visitURL string) error {+func (*SlowQueryWeeklyMailSender) sendNeedConfigSlowQueryPolicyEmail(mailSetting *storepb.SMTPMailDeliverySetting, to, visitURL string) error {email := mail.NewEmailMsg()needConfigureTemplate, err := emailTemplates.ReadFile("templates/for-dba/need_configure.html")@@ -715,19 +710,19 @@ func (*SlowQueryWeeklyMailSender) sendNeedConfigSlowQueryPolicyEmail(mailSettingbody := strings.ReplaceAll(string(needConfigureTemplate), "{{VISIT_URL}}", visitURL)body = strings.ReplaceAll(body, "{{DOC_LINK}}", `https://www.bytebase.com/docs/slow-query/overview`)- email.SetFrom(fmt.Sprintf("Bytebase <%s>", mailSetting.SMTPFrom)).- AddTo(mailSetting.SMTPTo).+ email.SetFrom(fmt.Sprintf("Bytebase <%s>", mailSetting.From)).+ AddTo(to).SetSubject("Configure your database slow query report").SetBody(body)- client := mail.NewSMTPClient(mailSetting.SMTPServerHost, mailSetting.SMTPServerPort)- client.SetAuthType(convertToMailSMTPAuthType(mailSetting.SMTPAuthenticationType)).- SetAuthCredentials(mailSetting.SMTPUsername, *mailSetting.SMTPPassword).- SetEncryptionType(convertToMailSMTPEncryptionType(mailSetting.SMTPEncryptionType))+ client := mail.NewSMTPClient(mailSetting.Server, int(mailSetting.Port))+ client.SetAuthType(convertToMailSMTPAuthType(mailSetting.Authentication)).+ SetAuthCredentials(mailSetting.Username, mailSetting.Password).+ SetEncryptionType(convertToMailSMTPEncryptionType(mailSetting.Encryption))if err := client.SendMail(email); err != nil {return err}- slog.Debug("Successfully sent need configure slow query policy email", slog.String("to", mailSetting.SMTPTo))+ slog.Debug("Successfully sent need configure slow query policy email", slog.String("to", to))return nil}@@ -757,23 +752,6 @@ func convertToMailSMTPAuthType(auth storepb.SMTPMailDeliverySetting_Authenticatireturn mail.SMTPAuthTypeNone}-func convertStorepbToAPIMailDeliveryValue(pb *storepb.SMTPMailDeliverySetting) *api.SettingWorkspaceMailDeliveryValue {- if pb == nil {- return nil- }- password := pb.Password- value := api.SettingWorkspaceMailDeliveryValue{- SMTPServerHost: pb.Server,- SMTPServerPort: int(pb.Port),- SMTPEncryptionType: pb.Encryption,- SMTPAuthenticationType: pb.Authentication,- SMTPUsername: pb.Username,- SMTPPassword: &password,- SMTPFrom: pb.From,- }- return &value-}-func generateDateRange(now time.Time) string {endDate := now.AddDate(0, 0, -1)startDate := endDate.AddDate(0, 0, -6)