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: move const to common (#16424)
Danny Xud948600122ae
diff --git a/backend/api/lsp/completion.go b/backend/api/lsp/completion.goindex a9c521dea9..5fff5591b0 100644--- a/backend/api/lsp/completion.go+++ b/backend/api/lsp/completion.go@@ -10,7 +10,7 @@ import ("github.com/pkg/errors""github.com/sourcegraph/jsonrpc2"- "github.com/bytebase/bytebase/backend/base"+ "github.com/bytebase/bytebase/backend/common"parserbase "github.com/bytebase/bytebase/backend/plugin/parser/base""github.com/bytebase/bytebase/backend/store""github.com/bytebase/bytebase/backend/store/model"@@ -51,7 +51,7 @@ func (h *Handler) handleTextDocumentCompletion(ctx context.Context, _ *jsonrpc2.defaultDatabase := h.getDefaultDatabase()engine := h.getEngineType(ctx)- if !base.EngineSupportAutoComplete(engine) {+ if !common.EngineSupportAutoComplete(engine) {slog.Debug("Engine is not supported", slog.String("engine", engine.String()))return newEmptyCompletionList(), nil}diff --git a/backend/api/v1/acl.go b/backend/api/v1/acl.goindex 5f4d780be0..60537c0de5 100644--- a/backend/api/v1/acl.go+++ b/backend/api/v1/acl.go@@ -17,7 +17,6 @@ import ("github.com/pkg/errors""github.com/bytebase/bytebase/backend/api/auth"- "github.com/bytebase/bytebase/backend/base""github.com/bytebase/bytebase/backend/common""github.com/bytebase/bytebase/backend/common/log""github.com/bytebase/bytebase/backend/component/config"@@ -298,7 +297,7 @@ func getResourceFromRequest(request any, method string) ([]*common.Resource, errreturn nil, errors.Wrapf(err, "failed to get projectID from %q", r.GetDatabase().GetProject())}// Allow to transfer databases to the default project.- if projectID == base.DefaultProjectID {+ if projectID == common.DefaultProjectID {continue}resources = append(resources, &common.Resource{Name: r.GetDatabase().GetProject()})diff --git a/backend/api/v1/actuator_service.go b/backend/api/v1/actuator_service.goindex be8be43f25..a42a38bc1e 100644--- a/backend/api/v1/actuator_service.go+++ b/backend/api/v1/actuator_service.go@@ -141,7 +141,7 @@ func (s *ActuatorService) generateOnboardingData(ctx context.Context, user *storinstanceMessages := []*store.InstanceMessage{{ResourceID: "test-sample-instance",- EnvironmentID: base.DefaultTestEnvironmentID,+ EnvironmentID: common.DefaultTestEnvironmentID,Metadata: &storepb.Instance{Title: "Test Sample Instance",DataSources: []*storepb.DataSource{@@ -154,7 +154,7 @@ func (s *ActuatorService) generateOnboardingData(ctx context.Context, user *stor},{ResourceID: "prod-sample-instance",- EnvironmentID: base.DefaultProdEnvironmentID,+ EnvironmentID: common.DefaultProdEnvironmentID,Metadata: &storepb.Instance{Title: "Prod Sample Instance",DataSources: []*storepb.DataSource{diff --git a/backend/api/v1/database_service.go b/backend/api/v1/database_service.goindex 73da2ae790..3d644e7449 100644--- a/backend/api/v1/database_service.go+++ b/backend/api/v1/database_service.go@@ -235,7 +235,7 @@ func getListDatabaseFilter(filter string) (*store.ListResourceFilter, error) {return fmt.Sprintf("(db.metadata->>'drifted')::boolean %s TRUE", condition), nilcase "exclude_unassigned":if excludeUnassigned, ok := value.(bool); excludeUnassigned && ok {- positionalArgs = append(positionalArgs, base.DefaultProjectID)+ positionalArgs = append(positionalArgs, common.DefaultProjectID)return fmt.Sprintf("db.project != $%d", len(positionalArgs)), nil}return "TRUE", nildiff --git a/backend/api/v1/database_service_test.go b/backend/api/v1/database_service_test.goindex aa4ded8159..5cac16cf90 100644--- a/backend/api/v1/database_service_test.go+++ b/backend/api/v1/database_service_test.go@@ -8,7 +8,7 @@ import ("google.golang.org/grpc/codes""google.golang.org/grpc/status"- "github.com/bytebase/bytebase/backend/base"+ "github.com/bytebase/bytebase/backend/common""github.com/bytebase/bytebase/backend/store"storepb "github.com/bytebase/bytebase/proto/generated-go/store"v1pb "github.com/bytebase/bytebase/proto/generated-go/v1"@@ -176,7 +176,7 @@ func TestListDatabaseFilter(t *testing.T) {input: `(label == "region:asia" || label == "tenant:bytebase") && exclude_unassigned == true`,want: &store.ListResourceFilter{Where: `(((db.metadata->'labels'->>'region' = ANY($1)) OR (db.metadata->'labels'->>'tenant' = ANY($2))) AND (db.project != $3))`,- Args: []any{"asia", "bytebase", base.DefaultProjectID},+ Args: []any{"asia", "bytebase", common.DefaultProjectID},},},}diff --git a/backend/api/v1/instance_service.go b/backend/api/v1/instance_service.goindex 71076c681b..d319180a63 100644--- a/backend/api/v1/instance_service.go+++ b/backend/api/v1/instance_service.go@@ -517,7 +517,7 @@ func (s *InstanceService) DeleteInstance(ctx context.Context, request *v1pb.Dele}if request.Force {if len(databases) > 0 {- defaultProjectID := base.DefaultProjectID+ defaultProjectID := common.DefaultProjectIDif _, err := s.store.BatchUpdateDatabases(ctx, databases, &store.BatchUpdateDatabases{ProjectID: &defaultProjectID}); err != nil {return nil, err}@@ -525,7 +525,7 @@ func (s *InstanceService) DeleteInstance(ctx context.Context, request *v1pb.Dele} else {var databaseNames []stringfor _, database := range databases {- if database.ProjectID != base.DefaultProjectID {+ if database.ProjectID != common.DefaultProjectID {databaseNames = append(databaseNames, database.DatabaseName)}}diff --git a/backend/api/v1/issue_service.go b/backend/api/v1/issue_service.goindex a9212b2126..0ac9e97d38 100644--- a/backend/api/v1/issue_service.go+++ b/backend/api/v1/issue_service.go@@ -14,7 +14,6 @@ import ("google.golang.org/grpc/codes""google.golang.org/grpc/status"- "github.com/bytebase/bytebase/backend/base""github.com/bytebase/bytebase/backend/common""github.com/bytebase/bytebase/backend/common/log""github.com/bytebase/bytebase/backend/component/config"@@ -478,7 +477,7 @@ func (s *IssueService) createIssueDatabaseChange(ctx context.Context, request *vs.webhookManager.CreateEvent(ctx, &webhook.Event{Actor: user,- Type: base.EventTypeIssueCreate,+ Type: common.EventTypeIssueCreate,Comment: "",Issue: webhook.NewIssue(issue),Project: webhook.NewProject(issue.Project),@@ -561,7 +560,7 @@ func (s *IssueService) createIssueGrantRequest(ctx context.Context, request *v1ps.webhookManager.CreateEvent(ctx, &webhook.Event{Actor: user,- Type: base.EventTypeIssueCreate,+ Type: common.EventTypeIssueCreate,Comment: "",Issue: webhook.NewIssue(issue),Project: webhook.NewProject(issue.Project),@@ -662,7 +661,7 @@ func (s *IssueService) createIssueDatabaseDataExport(ctx context.Context, requess.webhookManager.CreateEvent(ctx, &webhook.Event{Actor: user,- Type: base.EventTypeIssueCreate,+ Type: common.EventTypeIssueCreate,Comment: "",Issue: webhook.NewIssue(issue),Project: webhook.NewProject(issue.Project),@@ -797,7 +796,7 @@ func (s *IssueService) ApproveIssue(ctx context.Context, request *v1pb.ApproveIss.webhookManager.CreateEvent(ctx, &webhook.Event{Actor: s.store.GetSystemBotUser(ctx),- Type: base.EventTypeIssueApprovalCreate,+ Type: common.EventTypeIssueApprovalCreate,Comment: "",Issue: webhook.NewIssue(issue),Project: webhook.NewProject(issue.Project),@@ -819,7 +818,7 @@ func (s *IssueService) ApproveIssue(ctx context.Context, request *v1pb.ApproveIs// notify issue approveds.webhookManager.CreateEvent(ctx, &webhook.Event{Actor: s.store.GetSystemBotUser(ctx),- Type: base.EventTypeIssueApprovalPass,+ Type: common.EventTypeIssueApprovalPass,Comment: "",Issue: webhook.NewIssue(issue),Project: webhook.NewProject(issue.Project),@@ -846,7 +845,7 @@ func (s *IssueService) ApproveIssue(ctx context.Context, request *v1pb.ApproveIs}s.webhookManager.CreateEvent(ctx, &webhook.Event{Actor: user,- Type: base.EventTypeIssueRolloutReady,+ Type: common.EventTypeIssueRolloutReady,Comment: "",Issue: webhook.NewIssue(issue),Project: webhook.NewProject(issue.Project),@@ -1056,7 +1055,7 @@ func (s *IssueService) RequestIssue(ctx context.Context, request *v1pb.RequestIss.webhookManager.CreateEvent(ctx, &webhook.Event{Actor: s.store.GetSystemBotUser(ctx),- Type: base.EventTypeIssueApprovalCreate,+ Type: common.EventTypeIssueApprovalCreate,Comment: "",Issue: webhook.NewIssue(issue),Project: webhook.NewProject(issue.Project),@@ -1177,7 +1176,7 @@ func (s *IssueService) UpdateIssue(ctx context.Context, request *v1pb.UpdateIssuwebhookEvents = append(webhookEvents, &webhook.Event{Actor: user,- Type: base.EventTypeIssueUpdate,+ Type: common.EventTypeIssueUpdate,Comment: "",Issue: webhook.NewIssue(issue),Project: webhook.NewProject(issue.Project),@@ -1203,7 +1202,7 @@ func (s *IssueService) UpdateIssue(ctx context.Context, request *v1pb.UpdateIssuwebhookEvents = append(webhookEvents, &webhook.Event{Actor: user,- Type: base.EventTypeIssueUpdate,+ Type: common.EventTypeIssueUpdate,Comment: "",Issue: webhook.NewIssue(issue),Project: webhook.NewProject(issue.Project),@@ -1337,7 +1336,7 @@ func (s *IssueService) BatchUpdateIssuesStatus(ctx context.Context, request *v1pfunc() {s.webhookManager.CreateEvent(ctx, &webhook.Event{Actor: user,- Type: base.EventTypeIssueStatusUpdate,+ Type: common.EventTypeIssueStatusUpdate,Comment: request.Reason,Issue: webhook.NewIssue(updatedIssue),Project: webhook.NewProject(updatedIssue.Project),@@ -1433,7 +1432,7 @@ func (s *IssueService) CreateIssueComment(ctx context.Context, request *v1pb.Cres.webhookManager.CreateEvent(ctx, &webhook.Event{Actor: user,- Type: base.EventTypeIssueCommentCreate,+ Type: common.EventTypeIssueCommentCreate,Comment: request.IssueComment.Comment,Issue: webhook.NewIssue(issue),Project: webhook.NewProject(issue.Project),diff --git a/backend/api/v1/issue_service_test.go b/backend/api/v1/issue_service_test.goindex a1221faf9d..bb2fe05fef 100644--- a/backend/api/v1/issue_service_test.go+++ b/backend/api/v1/issue_service_test.go@@ -5,7 +5,6 @@ import ("github.com/stretchr/testify/require"- "github.com/bytebase/bytebase/backend/base""github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/proto/generated-go/store"v1pb "github.com/bytebase/bytebase/proto/generated-go/v1"@@ -19,11 +18,11 @@ func TestConvertToApprovalNode(t *testing.T) {{node: &storepb.ApprovalNode{Type: storepb.ApprovalNode_ANY_IN_GROUP,- Role: common.FormatRole(base.WorkspaceDBA.String()),+ Role: common.FormatRole("customRole"),},want: &v1pb.ApprovalNode{Type: v1pb.ApprovalNode_ANY_IN_GROUP,- Role: common.FormatRole(base.WorkspaceDBA.String()),+ Role: common.FormatRole("customRole"),},},}diff --git a/backend/api/v1/project_service.go b/backend/api/v1/project_service.goindex a0f71c819a..aae3e0a0a3 100644--- a/backend/api/v1/project_service.go+++ b/backend/api/v1/project_service.go@@ -139,7 +139,7 @@ func getListProjectFilter(filter string) (*store.ListResourceFilter, error) {return fmt.Sprintf("project.resource_id = $%d", len(positionalArgs)), nilcase "exclude_default":if excludeDefault, ok := value.(bool); excludeDefault && ok {- positionalArgs = append(positionalArgs, base.DefaultProjectID)+ positionalArgs = append(positionalArgs, common.DefaultProjectID)return fmt.Sprintf("project.resource_id != $%d", len(positionalArgs)), nil}return "TRUE", nil@@ -323,7 +323,7 @@ func (s *ProjectService) UpdateProject(ctx context.Context, request *v1pb.Updateif project.Deleted {return nil, status.Errorf(codes.NotFound, "project %q has been deleted", request.Project.Name)}- if project.ResourceID == base.DefaultProjectID {+ if project.ResourceID == common.DefaultProjectID {return nil, status.Errorf(codes.InvalidArgument, "default project cannot be updated")}@@ -445,7 +445,7 @@ func (s *ProjectService) DeleteProject(ctx context.Context, request *v1pb.Deleteif project.Deleted {return nil, status.Errorf(codes.NotFound, "project %q has been deleted", request.Name)}- if project.ResourceID == base.DefaultProjectID {+ if project.ResourceID == common.DefaultProjectID {return nil, status.Errorf(codes.InvalidArgument, "default project cannot be deleted")}@@ -457,7 +457,7 @@ func (s *ProjectService) DeleteProject(ctx context.Context, request *v1pb.Delete// We don't move the sheet to default project because BYTEBASE_ARTIFACT sheets belong to the issue and issue project.if request.Force {if len(databases) > 0 {- defaultProject := base.DefaultProjectID+ defaultProject := common.DefaultProjectIDif _, err := s.store.BatchUpdateDatabases(ctx, databases, &store.BatchUpdateDatabases{ProjectID: &defaultProject}); err != nil {return nil, err}@@ -599,7 +599,7 @@ func (s *ProjectService) SetIamPolicy(ctx context.Context, request *v1pb.SetIamP}// Must contain one owner binding.if !existProjectOwner {- return nil, status.Errorf(codes.InvalidArgument, "IAM Policy must have at least one binding with %s", base.ProjectOwner.String())+ return nil, status.Errorf(codes.InvalidArgument, "IAM Policy must have at least one binding with %s", common.ProjectOwner)}policy, err := convertToStoreIamPolicy(ctx, s.store, request.Policy)@@ -950,12 +950,12 @@ func (s *ProjectService) TestWebhook(ctx context.Context, request *v1pb.TestWebhwebhookplugin.Context{URL: webhook.URL,Level: webhookplugin.WebhookInfo,- EventType: string(base.EventTypeIssueCreate),+ EventType: string(common.EventTypeIssueCreate),Title: fmt.Sprintf("Test webhook %q", webhook.Title),TitleZh: fmt.Sprintf("测试 webhook %q", webhook.Title),Description: "This is a test",Link: fmt.Sprintf("%s/projects/%s/webhooks/%s", setting.ExternalUrl, project.ResourceID, fmt.Sprintf("%s-%d", slug.Make(webhook.Title), webhook.ID)),- ActorID: base.SystemBotID,+ ActorID: common.SystemBotID,ActorName: "Bytebase",ActorEmail: s.store.GetSystemBotUser(ctx).Email,CreatedTS: time.Now().Unix(),@@ -1008,23 +1008,23 @@ func convertToActivityTypeStrings(types []v1pb.Activity_Type) ([]string, error)case v1pb.Activity_TYPE_UNSPECIFIED:return nil, common.Errorf(common.Invalid, "activity type must not be unspecified")case v1pb.Activity_TYPE_ISSUE_CREATE:- result = append(result, string(base.EventTypeIssueCreate))+ result = append(result, string(common.EventTypeIssueCreate))case v1pb.Activity_TYPE_ISSUE_COMMENT_CREATE:- result = append(result, string(base.EventTypeIssueCommentCreate))+ result = append(result, string(common.EventTypeIssueCommentCreate))case v1pb.Activity_TYPE_ISSUE_FIELD_UPDATE:- result = append(result, string(base.EventTypeIssueUpdate))+ result = append(result, string(common.EventTypeIssueUpdate))case v1pb.Activity_TYPE_ISSUE_STATUS_UPDATE:- result = append(result, string(base.EventTypeIssueStatusUpdate))+ result = append(result, string(common.EventTypeIssueStatusUpdate))case v1pb.Activity_TYPE_ISSUE_APPROVAL_NOTIFY:- result = append(result, string(base.EventTypeIssueApprovalCreate))+ result = append(result, string(common.EventTypeIssueApprovalCreate))case v1pb.Activity_TYPE_ISSUE_PIPELINE_STAGE_STATUS_UPDATE:- result = append(result, string(base.EventTypeStageStatusUpdate))+ result = append(result, string(common.EventTypeStageStatusUpdate))case v1pb.Activity_TYPE_ISSUE_PIPELINE_TASK_RUN_STATUS_UPDATE:- result = append(result, string(base.EventTypeTaskRunStatusUpdate))+ result = append(result, string(common.EventTypeTaskRunStatusUpdate))case v1pb.Activity_TYPE_NOTIFY_ISSUE_APPROVED:- result = append(result, string(base.EventTypeIssueApprovalPass))+ result = append(result, string(common.EventTypeIssueApprovalPass))case v1pb.Activity_TYPE_NOTIFY_PIPELINE_ROLLOUT:- result = append(result, string(base.EventTypeIssueRolloutReady))+ result = append(result, string(common.EventTypeIssueRolloutReady))default:return nil, common.Errorf(common.Invalid, "unsupported activity type: %v", tp)}@@ -1036,23 +1036,23 @@ func convertNotificationTypeStrings(types []string) []v1pb.Activity_Type {var result []v1pb.Activity_Typefor _, tp := range types {switch tp {- case string(base.EventTypeIssueCreate):+ case string(common.EventTypeIssueCreate):result = append(result, v1pb.Activity_TYPE_ISSUE_CREATE)- case string(base.EventTypeIssueCommentCreate):+ case string(common.EventTypeIssueCommentCreate):result = append(result, v1pb.Activity_TYPE_ISSUE_COMMENT_CREATE)- case string(base.EventTypeIssueUpdate):+ case string(common.EventTypeIssueUpdate):result = append(result, v1pb.Activity_TYPE_ISSUE_FIELD_UPDATE)- case string(base.EventTypeIssueStatusUpdate):+ case string(common.EventTypeIssueStatusUpdate):result = append(result, v1pb.Activity_TYPE_ISSUE_STATUS_UPDATE)- case string(base.EventTypeIssueApprovalCreate):+ case string(common.EventTypeIssueApprovalCreate):result = append(result, v1pb.Activity_TYPE_ISSUE_APPROVAL_NOTIFY)- case string(base.EventTypeStageStatusUpdate):+ case string(common.EventTypeStageStatusUpdate):result = append(result, v1pb.Activity_TYPE_ISSUE_PIPELINE_STAGE_STATUS_UPDATE)- case string(base.EventTypeTaskRunStatusUpdate):+ case string(common.EventTypeTaskRunStatusUpdate):result = append(result, v1pb.Activity_TYPE_ISSUE_PIPELINE_TASK_RUN_STATUS_UPDATE)- case string(base.EventTypeIssueApprovalPass):+ case string(common.EventTypeIssueApprovalPass):result = append(result, v1pb.Activity_TYPE_NOTIFY_ISSUE_APPROVED)- case string(base.EventTypeIssueRolloutReady):+ case string(common.EventTypeIssueRolloutReady):result = append(result, v1pb.Activity_TYPE_NOTIFY_PIPELINE_ROLLOUT)default:result = append(result, v1pb.Activity_TYPE_UNSPECIFIED)@@ -1252,7 +1252,7 @@ func convertToStoreIamPolicyMember(ctx context.Context, stores *store.Store, mem} else if strings.HasPrefix(member, common.GroupBindingPrefix) {email := strings.TrimPrefix(member, common.GroupBindingPrefix)return common.FormatGroupEmail(email), nil- } else if member == base.AllUsers {+ } else if member == common.AllUsers {return member, nil}return "", status.Errorf(codes.InvalidArgument, "unsupport member %s", member)@@ -1398,7 +1398,7 @@ func validateIAMPolicy(if len(binding.Members) == 0 {continue}- if binding.Role == fmt.Sprintf("roles/%s", base.ProjectOwner) {+ if binding.Role == fmt.Sprintf("roles/%s", common.ProjectOwner) {existProjectOwner = true}@@ -1429,7 +1429,7 @@ func validateBindings(bindings []*v1pb.Binding, roles []*store.RoleMessage, maxireturn err}- if binding.Role != fmt.Sprintf("roles/%s", base.ProjectOwner) && maximumRoleExpiration != nil {+ if binding.Role != fmt.Sprintf("roles/%s", common.ProjectOwner) && maximumRoleExpiration != nil {// Only validate when maximumRoleExpiration is set and the role is not project owner.if err := validateExpirationInExpression(binding.GetCondition().GetExpression(), maximumRoleExpiration); err != nil {return status.Errorf(codes.InvalidArgument, "failed to validate expiration for binding %v: %v", binding.Role, err.Error())@@ -1537,7 +1537,7 @@ func validateExpirationInExpression(expr string, maximumRoleExpiration *duration}func validateMember(member string) error {- if member == base.AllUsers {+ if member == common.AllUsers {return nil}diff --git a/backend/api/v1/project_service_test.go b/backend/api/v1/project_service_test.goindex 080511cf2b..5436b65dd3 100644--- a/backend/api/v1/project_service_test.go+++ b/backend/api/v1/project_service_test.go@@ -13,7 +13,7 @@ import ("google.golang.org/grpc/status""google.golang.org/protobuf/types/known/durationpb"- "github.com/bytebase/bytebase/backend/base"+ "github.com/bytebase/bytebase/backend/common""github.com/bytebase/bytebase/backend/store"storepb "github.com/bytebase/bytebase/proto/generated-go/store"v1pb "github.com/bytebase/bytebase/proto/generated-go/v1"@@ -411,14 +411,14 @@ func TestListProjectFilter(t *testing.T) {input: `exclude_default == true`,want: &store.ListResourceFilter{Where: `(project.resource_id != $1)`,- Args: []any{base.DefaultProjectID},+ Args: []any{common.DefaultProjectID},},},{input: `(name.matches("sample") || resource_id.matches("Sample")) && exclude_default == true`,want: &store.ListResourceFilter{Where: `(((LOWER(project.name) LIKE '%sample%') OR (LOWER(project.resource_id) LIKE '%sample%')) AND (project.resource_id != $1))`,- Args: []any{base.DefaultProjectID},+ Args: []any{common.DefaultProjectID},},},}diff --git a/backend/api/v1/query_result_masker.go b/backend/api/v1/query_result_masker.goindex 53c9c15382..2ae483e2c6 100644--- a/backend/api/v1/query_result_masker.go+++ b/backend/api/v1/query_result_masker.go@@ -6,7 +6,7 @@ import ("github.com/pkg/errors"- "github.com/bytebase/bytebase/backend/base"+ "github.com/bytebase/bytebase/backend/common""github.com/bytebase/bytebase/backend/component/masker"parserbase "github.com/bytebase/bytebase/backend/plugin/parser/base""github.com/bytebase/bytebase/backend/store"@@ -111,7 +111,7 @@ func (s *QueryResultMasker) getMaskersForQuerySpan(ctx context.Context, m *maskimaskers = append(maskers, masker.NewNoneMasker())case 1:// If there is only one source column, and comes from the expression, we fall back to the default full masker.- if !spanResult.IsPlainField && base.EngineSupportQuerySpanPlainField(instance.Metadata.GetEngine()) {+ if !spanResult.IsPlainField && common.EngineSupportQuerySpanPlainField(instance.Metadata.GetEngine()) {maskers = append(maskers, masker.NewDefaultFullMasker())} else {maskers = append(maskers, effectiveMaskers[0])@@ -134,7 +134,7 @@ func (s *QueryResultMasker) getMaskerForColumnResource(action storepb.MaskingExceptionPolicy_MaskingException_Action,currentPrincipal *store.UserMessage,) (masker.Masker, error) {- if instance != nil && !base.EngineSupportMasking(instance.Metadata.GetEngine()) {+ if instance != nil && !common.EngineSupportMasking(instance.Metadata.GetEngine()) {return masker.NewNoneMasker(), nil}database, err := s.store.GetDatabaseV2(ctx, &store.FindDatabaseMessage{diff --git a/backend/api/v1/release_service_check.go b/backend/api/v1/release_service_check.goindex 22069d1957..aac4795b3f 100644--- a/backend/api/v1/release_service_check.go+++ b/backend/api/v1/release_service_check.go@@ -9,7 +9,6 @@ import ("github.com/pkg/errors"- "github.com/bytebase/bytebase/backend/base""github.com/bytebase/bytebase/backend/common""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/catalog"@@ -236,7 +235,7 @@ func (s *ReleaseService) CheckRelease(ctx context.Context, request *v1pb.CheckRe}checkResult.RiskLevel = riskLevelEnum}- if base.EngineSupportSQLReview(instance.Metadata.GetEngine()) {+ if common.EngineSupportSQLReview(instance.Metadata.GetEngine()) {adviceStatus, sqlReviewAdvices, err := s.runSQLReviewCheckForFile(ctx, catalog, instance, database, changeType, statement)if err != nil {return nil, status.Errorf(codes.Internal, "failed to check SQL review: %v", err)diff --git a/backend/api/v1/review_config_service.go b/backend/api/v1/review_config_service.goindex 6b91cf4995..d2e790d7bc 100644--- a/backend/api/v1/review_config_service.go+++ b/backend/api/v1/review_config_service.go@@ -202,7 +202,7 @@ func (s *ReviewConfigService) convertToV1ReviewConfig(ctx context.Context, revieif err := common.ProtojsonUnmarshaler.Unmarshal([]byte(policy.Payload), p); err != nil {return nil, status.Errorf(codes.Internal, "failed to unmarshal tag policy, error %v", err)}- if p.Tags[string(base.ReservedTagReviewConfig)] != config.Name {+ if p.Tags[string(common.ReservedTagReviewConfig)] != config.Name {continue}diff --git a/backend/api/v1/rollout_service.go b/backend/api/v1/rollout_service.goindex 0394862916..51385279ff 100644--- a/backend/api/v1/rollout_service.go+++ b/backend/api/v1/rollout_service.go@@ -15,7 +15,6 @@ import ("google.golang.org/grpc/status""google.golang.org/protobuf/types/known/timestamppb"- "github.com/bytebase/bytebase/backend/base""github.com/bytebase/bytebase/backend/common""github.com/bytebase/bytebase/backend/common/log""github.com/bytebase/bytebase/backend/component/config"@@ -601,7 +600,7 @@ func (s *RolloutService) BatchRunTasks(ctx context.Context, request *v1pb.BatchR}s.webhookManager.CreateEvent(ctx, &webhook.Event{Actor: user,- Type: base.EventTypeTaskRunStatusUpdate,+ Type: common.EventTypeTaskRunStatusUpdate,Comment: request.Reason,Issue: webhook.NewIssue(issueN),Project: webhook.NewProject(project),@@ -701,7 +700,7 @@ func (s *RolloutService) BatchSkipTasks(ctx context.Context, request *v1pb.Batch}s.webhookManager.CreateEvent(ctx, &webhook.Event{Actor: user,- Type: base.EventTypeTaskRunStatusUpdate,+ Type: common.EventTypeTaskRunStatusUpdate,Comment: request.Reason,Issue: webhook.NewIssue(issueN),Project: webhook.NewProject(project),@@ -818,7 +817,7 @@ func (s *RolloutService) BatchCancelTaskRuns(ctx context.Context, request *v1pb.}s.webhookManager.CreateEvent(ctx, &webhook.Event{Actor: user,- Type: base.EventTypeTaskRunStatusUpdate,+ Type: common.EventTypeTaskRunStatusUpdate,Comment: request.Reason,Issue: webhook.NewIssue(issueN),Rollout: webhook.NewRollout(rollout),diff --git a/backend/api/v1/rollout_service_task.go b/backend/api/v1/rollout_service_task.goindex ddf31d406a..7f36752ad1 100644--- a/backend/api/v1/rollout_service_task.go+++ b/backend/api/v1/rollout_service_task.go@@ -10,7 +10,6 @@ import ("github.com/pkg/errors""google.golang.org/protobuf/proto"- "github.com/bytebase/bytebase/backend/base""github.com/bytebase/bytebase/backend/common""github.com/bytebase/bytebase/backend/common/log""github.com/bytebase/bytebase/backend/component/dbfactory"@@ -149,7 +148,7 @@ func getTaskCreatesFromCreateDatabaseConfig(ctx context.Context, s *store.Store,return nil, err}sheet, err := sheetManager.CreateSheet(ctx, &store.SheetMessage{- CreatorID: base.SystemBotID,+ CreatorID: common.SystemBotID,ProjectID: project.ResourceID,Title: fmt.Sprintf("Sheet for creating database %v", databaseName),Statement: statement,diff --git a/backend/api/v1/sql_service.go b/backend/api/v1/sql_service.goindex 31b01d29e2..2982da3275 100644--- a/backend/api/v1/sql_service.go+++ b/backend/api/v1/sql_service.go@@ -169,7 +169,7 @@ func (s *SQLService) Query(ctx context.Context, request *v1pb.QueryRequest) (*v1// Validate the request.// New query ACL experience.- if !request.Explain && !base.EngineSupportQueryNewACL(instance.Metadata.GetEngine()) {+ if !request.Explain && !common.EngineSupportQueryNewACL(instance.Metadata.GetEngine()) {if err := validateQueryRequest(instance, statement); err != nil {return nil, err}@@ -297,7 +297,7 @@ func extractSourceTable(comment string) (string, string, string, error) {func getSchemaMetadata(engine storepb.Engine, dbSchema *model.DatabaseSchema) *model.SchemaMetadata {switch engine {case storepb.Engine_POSTGRES:- return dbSchema.GetDatabaseMetadata().GetSchema(base.BackupDatabaseNameOfEngine(storepb.Engine_POSTGRES))+ return dbSchema.GetDatabaseMetadata().GetSchema(common.BackupDatabaseNameOfEngine(storepb.Engine_POSTGRES))case storepb.Engine_MSSQL:return dbSchema.GetDatabaseMetadata().GetSchema("dbo")default:@@ -311,11 +311,11 @@ func replaceBackupTableWithSource(ctx context.Context, stores *store.Store, inst// Don't need to check the database name for postgres here.// We backup the table to the same database with bbdataarchive schema for Postgres.case storepb.Engine_ORACLE:- if database.DatabaseName != base.BackupDatabaseNameOfEngine(storepb.Engine_ORACLE) {+ if database.DatabaseName != common.BackupDatabaseNameOfEngine(storepb.Engine_ORACLE) {return nil}default:- if database.DatabaseName != base.BackupDatabaseNameOfEngine(instance.Metadata.GetEngine()) {+ if database.DatabaseName != common.BackupDatabaseNameOfEngine(instance.Metadata.GetEngine()) {return nil}}@@ -385,11 +385,11 @@ func generateNewColumn(engine storepb.Engine, column parserbase.ColumnResource,func isBackupTable(engine storepb.Engine, column parserbase.ColumnResource) bool {switch engine {case storepb.Engine_POSTGRES:- return column.Schema == base.BackupDatabaseNameOfEngine(storepb.Engine_POSTGRES)+ return column.Schema == common.BackupDatabaseNameOfEngine(storepb.Engine_POSTGRES)case storepb.Engine_ORACLE:- return column.Database == base.BackupDatabaseNameOfEngine(storepb.Engine_ORACLE)+ return column.Database == common.BackupDatabaseNameOfEngine(storepb.Engine_ORACLE)default:- return column.Database == base.BackupDatabaseNameOfEngine(engine)+ return column.Database == common.BackupDatabaseNameOfEngine(engine)}}@@ -1323,7 +1323,7 @@ func (s *SQLService) accessCheck(for _, span := range spans {// New query ACL experience.- if base.EngineSupportQueryNewACL(instance.Metadata.GetEngine()) {+ if common.EngineSupportQueryNewACL(instance.Metadata.GetEngine()) {var permission iam.Permissionswitch span.Type {case parserbase.QueryTypeUnknown:@@ -1629,7 +1629,7 @@ func (s *SQLService) SQLReviewCheck(instance *store.InstanceMessage,database *store.DatabaseMessage,) (storepb.Advice_Status, []*v1pb.Advice, error) {- if !base.EngineSupportSQLReview(instance.Metadata.GetEngine()) || database == nil {+ if !common.EngineSupportSQLReview(instance.Metadata.GetEngine()) || database == nil {return storepb.Advice_SUCCESS, nil, nil}diff --git a/backend/api/v1/user_service.go b/backend/api/v1/user_service.goindex dd7198dd6b..9334e081c9 100644--- a/backend/api/v1/user_service.go+++ b/backend/api/v1/user_service.go@@ -374,7 +374,7 @@ func (s *UserService) CreateUser(ctx context.Context, request *v1pb.CreateUserReif err != nil {return nil, status.Errorf(codes.Internal, "failed to generate access key for service account.")}- password = fmt.Sprintf("%s%s", base.ServiceAccountAccessKeyPrefix, pwd)+ password = fmt.Sprintf("%s%s", common.ServiceAccountAccessKeyPrefix, pwd)} else {if password != "" {if err := s.validatePassword(ctx, password); err != nil {@@ -409,14 +409,14 @@ func (s *UserService) CreateUser(ctx context.Context, request *v1pb.CreateUserRe// The first end user should be workspace admin.updateRole := &store.PatchIamPolicyMessage{Member: common.FormatUserUID(user.ID),- Roles: []string{common.FormatRole(base.WorkspaceAdmin.String())},+ Roles: []string{common.FormatRole(common.WorkspaceAdmin)},}if _, err := s.store.PatchWorkspaceIamPolicy(ctx, updateRole); err != nil {return nil, err}}- isFirstUser := user.ID == base.PrincipalIDForFirstUser+ isFirstUser := user.ID == common.PrincipalIDForFirstUsers.metricReporter.Report(ctx, &metric.Metric{Name: metricapi.PrincipalRegistrationMetricName,Value: 1,@@ -532,7 +532,7 @@ func (s *UserService) UpdateUser(ctx context.Context, request *v1pb.UpdateUserReif err != nil {return nil, status.Errorf(codes.Internal, "failed to generate access key for service account.")}- password := fmt.Sprintf("%s%s", base.ServiceAccountAccessKeyPrefix, val)+ password := fmt.Sprintf("%s%s", common.ServiceAccountAccessKeyPrefix, val)passwordPatch = &passwordcase "mfa_enabled":if request.User.MfaEnabled {@@ -701,7 +701,7 @@ func (s *UserService) getActiveUserCount(ctx context.Context) (int, error) {}func (s *UserService) hasExtraWorkspaceAdmin(ctx context.Context, policy *storepb.IamPolicy, userID int) (bool, error) {- workspaceAdminRole := common.FormatRole(base.WorkspaceAdmin.String())+ workspaceAdminRole := common.FormatRole(common.WorkspaceAdmin)userMember := common.FormatUserUID(userID)for _, binding := range policy.GetBindings() {@@ -712,7 +712,7 @@ func (s *UserService) hasExtraWorkspaceAdmin(ctx context.Context, policy *storepif member == userMember {continue}- if member == base.AllUsers {+ if member == common.AllUsers {activeEndUserCount, err := s.getActiveUserCount(ctx)if err != nil {return false, err@@ -940,5 +940,5 @@ func isUserWorkspaceAdmin(ctx context.Context, stores *store.Store, user *store.return false, err}roles := utils.GetUserFormattedRolesMap(ctx, stores, user, workspacePolicy.Policy)- return roles[common.FormatRole(base.WorkspaceAdmin.String())], nil+ return roles[common.FormatRole(common.WorkspaceAdmin)], nil}diff --git a/backend/api/v1/workspace_service.go b/backend/api/v1/workspace_service.goindex d7c61e485d..243b6e8456 100644--- a/backend/api/v1/workspace_service.go+++ b/backend/api/v1/workspace_service.go@@ -7,7 +7,7 @@ import ("google.golang.org/grpc/status""google.golang.org/protobuf/encoding/protojson"- "github.com/bytebase/bytebase/backend/base"+ "github.com/bytebase/bytebase/backend/common""github.com/bytebase/bytebase/backend/component/iam""github.com/bytebase/bytebase/backend/store""github.com/bytebase/bytebase/backend/utils"@@ -56,7 +56,7 @@ func (s *WorkspaceService) SetIamPolicy(ctx context.Context, request *v1pb.SetIaif err != nil {return nil, err}- users := utils.GetUsersByRoleInIAMPolicy(ctx, s.store, base.WorkspaceAdmin, iamPolicy)+ users := utils.GetUsersByRoleInIAMPolicy(ctx, s.store, common.WorkspaceAdmin, iamPolicy)if !containsActiveEndUser(users) {return nil, status.Errorf(codes.InvalidArgument, "workspace must have at least one admin")}diff --git a/backend/base/database.go b/backend/base/database.godeleted file mode 100644index 93afd3c27d..0000000000--- a/backend/base/database.go+++ /dev/null@@ -1,48 +0,0 @@-package base--import storepb "github.com/bytebase/bytebase/proto/generated-go/store"--func BackupDatabaseNameOfEngine(e storepb.Engine) string {- //exhaustive:enforce- switch e {- case- storepb.Engine_MYSQL,- storepb.Engine_TIDB,- storepb.Engine_MSSQL,- storepb.Engine_POSTGRES:- return "bbdataarchive"- case- storepb.Engine_ORACLE:- return "BBDATAARCHIVE"- case- storepb.Engine_ENGINE_UNSPECIFIED,- storepb.Engine_SNOWFLAKE,- storepb.Engine_CASSANDRA,- storepb.Engine_SQLITE,- storepb.Engine_MONGODB,- storepb.Engine_REDIS,- storepb.Engine_CLICKHOUSE,- storepb.Engine_SPANNER,- storepb.Engine_BIGQUERY,- storepb.Engine_REDSHIFT,- storepb.Engine_MARIADB,- storepb.Engine_OCEANBASE,- storepb.Engine_OCEANBASE_ORACLE,- storepb.Engine_DM,- storepb.Engine_STARROCKS,- storepb.Engine_RISINGWAVE,- storepb.Engine_HIVE,- storepb.Engine_COCKROACHDB,- storepb.Engine_DORIS,- storepb.Engine_DYNAMODB,- storepb.Engine_ELASTICSEARCH,- storepb.Engine_DATABRICKS,- storepb.Engine_COSMOSDB,- storepb.Engine_TRINO:- // Fallback to the default name for other engines.- return "bbdataarchive"- default:- // Fallback to the default name for other engines.- return "bbdataarchive"- }-}diff --git a/backend/base/instance.go b/backend/base/instance.godeleted file mode 100644index 79e9a7f19f..0000000000--- a/backend/base/instance.go+++ /dev/null@@ -1,4 +0,0 @@-package base--// DefaultInstanceMaximumConnections is the maximum number of connections outstanding per instance by default.-const DefaultInstanceMaximumConnections = 10diff --git a/backend/base/member.go b/backend/base/member.godeleted file mode 100644index 6ba85c04c2..0000000000--- a/backend/base/member.go+++ /dev/null@@ -1,21 +0,0 @@-package base--// Role is the type of a role.-type Role string--const (- WorkspaceAdmin Role = "workspaceAdmin"- WorkspaceDBA Role = "workspaceDBA"- WorkspaceMember Role = "workspaceMember"- ProjectOwner Role = "projectOwner"- ProjectDeveloper Role = "projectDeveloper"- ProjectExporter Role = "projectExporter"- ProjectReleaser Role = "projectReleaser"- ProjectViewer Role = "projectViewer"- SQLEditorUser Role = "sqlEditorUser"- UnknownRole Role = "UNKNOWN"-)--func (r Role) String() string {- return string(r)-}diff --git a/backend/base/policy.go b/backend/base/policy.godeleted file mode 100644index 624cebc938..0000000000--- a/backend/base/policy.go+++ /dev/null@@ -1,6 +0,0 @@-package base--const (- // ReservedTagReviewConfig is the tag for review config.- ReservedTagReviewConfig string = "bb.tag.review_config"-)diff --git a/backend/base/principal.go b/backend/base/principal.godeleted file mode 100644index d59a85485d..0000000000--- a/backend/base/principal.go+++ /dev/null@@ -1,15 +0,0 @@-package base--// SystemBotID is the ID of the system robot.-const SystemBotID = 1--// AllUsers is the email of the pseudo allUsers account.-const AllUsers = "allUsers"--const (- // PrincipalIDForFirstUser is the principal id for the first user in workspace.- PrincipalIDForFirstUser = 101-- // ServiceAccountAccessKeyPrefix is the prefix for service account access key.- ServiceAccountAccessKeyPrefix = "bbs_"-)diff --git a/backend/base/project.go b/backend/base/project.godeleted file mode 100644index ce2cb204f1..0000000000--- a/backend/base/project.go+++ /dev/null@@ -1,14 +0,0 @@-package base--const (- // DefaultProjectID is the resource ID for the default project.- DefaultProjectID = "default"- // DefaultTestEnvironmentID is the initial resource ID for the test environment.- // 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"- // 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 create- // a prod instance after first signup, so it's safe to refer it.- DefaultProdEnvironmentID = "prod"-)diff --git a/backend/base/webhook.go b/backend/base/webhook.godeleted file mode 100644index d0c379466e..0000000000--- a/backend/base/webhook.go+++ /dev/null@@ -1,16 +0,0 @@-package base--type EventType string--const (- EventTypeIssueCreate = "bb.webhook.event.issue.create"- EventTypeIssueUpdate = "bb.webhook.event.issue.update"- EventTypeIssueStatusUpdate = "bb.webhook.event.issue.status.update"- EventTypeIssueCommentCreate = "bb.webhook.event.issue.comment.create"- EventTypeIssueApprovalCreate = "bb.webhook.event.issue.approval.create"- EventTypeIssueApprovalPass = "bb.webhook.event.issue.approval.pass"- EventTypeIssueRolloutReady = "bb.webhook.event.issue.rollout.ready"-- EventTypeStageStatusUpdate = "bb.webhook.event.stage.status.update"- EventTypeTaskRunStatusUpdate = "bb.webhook.event.taskRun.status.update"-)diff --git a/backend/common/const.go b/backend/common/const.gonew file mode 100644index 0000000000..87c10e200c--- /dev/null+++ b/backend/common/const.go@@ -0,0 +1,57 @@+package common++const (+ WorkspaceAdmin = "workspaceAdmin"+ WorkspaceMember = "workspaceMember"+ ProjectOwner = "projectOwner"+)++const (+ // SystemBotID is the ID of the system robot.+ SystemBotID = 1++ // AllUsers is the email of the pseudo allUsers account.+ AllUsers = "allUsers"++ // PrincipalIDForFirstUser is the principal id for the first user in workspace.+ PrincipalIDForFirstUser = 101++ // ServiceAccountAccessKeyPrefix is the prefix for service account access key.+ ServiceAccountAccessKeyPrefix = "bbs_"+)++// DefaultInstanceMaximumConnections is the maximum number of connections outstanding per instance by default.+const DefaultInstanceMaximumConnections = 10++const (+ // ReservedTagReviewConfig is the tag for review config.+ ReservedTagReviewConfig string = "bb.tag.review_config"+)++const (+ // DefaultProjectID is the resource ID for the default project.+ DefaultProjectID = "default"+ // DefaultTestEnvironmentID is the initial resource ID for the test environment.+ // 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"+ // 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 create+ // a prod instance after first signup, so it's safe to refer it.+ DefaultProdEnvironmentID = "prod"+)++type EventType string++const (+ EventTypeIssueCreate = "bb.webhook.event.issue.create"+ EventTypeIssueUpdate = "bb.webhook.event.issue.update"+ EventTypeIssueStatusUpdate = "bb.webhook.event.issue.status.update"+ EventTypeIssueCommentCreate = "bb.webhook.event.issue.comment.create"+ EventTypeIssueApprovalCreate = "bb.webhook.event.issue.approval.create"+ EventTypeIssueApprovalPass = "bb.webhook.event.issue.approval.pass"+ EventTypeIssueRolloutReady = "bb.webhook.event.issue.rollout.ready"++ EventTypeStageStatusUpdate = "bb.webhook.event.stage.status.update"+ EventTypeTaskRunStatusUpdate = "bb.webhook.event.taskRun.status.update"+)diff --git a/backend/base/engine.go b/backend/common/engine.gosimilarity index 88%rename from backend/base/engine.gorename to backend/common/engine.goindex c6694be1a1..6b4d045998 100644--- a/backend/base/engine.go+++ b/backend/common/engine.go@@ -1,4 +1,4 @@-package base+package commonimport (storepb "github.com/bytebase/bytebase/proto/generated-go/store"@@ -372,3 +372,48 @@ func EngineSupportQuerySpanPlainField(e storepb.Engine) bool {return false}}++func BackupDatabaseNameOfEngine(e storepb.Engine) string {+ //exhaustive:enforce+ switch e {+ case+ storepb.Engine_MYSQL,+ storepb.Engine_TIDB,+ storepb.Engine_MSSQL,+ storepb.Engine_POSTGRES:+ return "bbdataarchive"+ case+ storepb.Engine_ORACLE:+ return "BBDATAARCHIVE"+ case+ storepb.Engine_ENGINE_UNSPECIFIED,+ storepb.Engine_SNOWFLAKE,+ storepb.Engine_CASSANDRA,+ storepb.Engine_SQLITE,+ storepb.Engine_MONGODB,+ storepb.Engine_REDIS,+ storepb.Engine_CLICKHOUSE,+ storepb.Engine_SPANNER,+ storepb.Engine_BIGQUERY,+ storepb.Engine_REDSHIFT,+ storepb.Engine_MARIADB,+ storepb.Engine_OCEANBASE,+ storepb.Engine_OCEANBASE_ORACLE,+ storepb.Engine_DM,+ storepb.Engine_STARROCKS,+ storepb.Engine_RISINGWAVE,+ storepb.Engine_HIVE,+ storepb.Engine_COCKROACHDB,+ storepb.Engine_DORIS,+ storepb.Engine_DYNAMODB,+ storepb.Engine_ELASTICSEARCH,+ storepb.Engine_DATABRICKS,+ storepb.Engine_COSMOSDB,+ storepb.Engine_TRINO:+ // Fallback to the default name for other engines.+ return "bbdataarchive"+ default:+ // Fallback to the default name for other engines.+ return "bbdataarchive"+ }+}diff --git a/backend/component/ghost/config.go b/backend/component/ghost/config.goindex 0c97090d4b..34f8f8bb47 100644--- a/backend/component/ghost/config.go+++ b/backend/component/ghost/config.go@@ -9,7 +9,7 @@ import (ghostsql "github.com/github/gh-ost/go/sql""github.com/pkg/errors"- "github.com/bytebase/bytebase/backend/base"+ "github.com/bytebase/bytebase/backend/common"secretcomp "github.com/bytebase/bytebase/backend/component/secret""github.com/bytebase/bytebase/backend/store"storepb "github.com/bytebase/bytebase/proto/generated-go/store"@@ -233,7 +233,7 @@ func NewMigrationContext(ctx context.Context, taskID int, database *store.DatabamigrationContext.CliPassword = password// GhostDatabaseName is our homemade parameter to allow creating temporary tables under another database.// Use MySQL/TiDB backup database name for gh-ost- migrationContext.GhostDatabaseName = base.BackupDatabaseNameOfEngine(storepb.Engine_MYSQL)+ migrationContext.GhostDatabaseName = common.BackupDatabaseNameOfEngine(storepb.Engine_MYSQL)migrationContext.DatabaseName = database.DatabaseNamemigrationContext.OriginalTableName = tableNamemigrationContext.AlterStatement = strings.Join(strings.Fields(statement), " ")diff --git a/backend/component/iam/manager.go b/backend/component/iam/manager.goindex ffafac92fc..d1b7404ed2 100644--- a/backend/component/iam/manager.go+++ b/backend/component/iam/manager.go@@ -144,7 +144,7 @@ func check(userID int, p Permission, policy *storepb.IamPolicy, rolePermissionscontinue}for _, member := range binding.GetMembers() {- if member == base.AllUsers {+ if member == common.AllUsers {return true}if member == userName {diff --git a/backend/component/iam/manager_test.go b/backend/component/iam/manager_test.goindex ba54461d44..209db679f3 100644--- a/backend/component/iam/manager_test.go+++ b/backend/component/iam/manager_test.go@@ -5,7 +5,6 @@ import ("github.com/stretchr/testify/require"- "github.com/bytebase/bytebase/backend/base""github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/proto/generated-go/store")@@ -71,7 +70,7 @@ func TestCheck(t *testing.T) {Bindings: []*storepb.Binding{{Role: "roles/workspaceAdmin",- Members: []string{"users/321", base.AllUsers},+ Members: []string{"users/321", common.AllUsers},},},},diff --git a/backend/component/webhook/event.go b/backend/component/webhook/event.goindex 75a5bc7ea9..0f61dfa375 100644--- a/backend/component/webhook/event.go+++ b/backend/component/webhook/event.go@@ -1,14 +1,14 @@package webhookimport (- "github.com/bytebase/bytebase/backend/base"+ "github.com/bytebase/bytebase/backend/common""github.com/bytebase/bytebase/backend/store"storepb "github.com/bytebase/bytebase/proto/generated-go/store")type Event struct {Actor *store.UserMessage- Type base.EventType+ Type common.EventTypeComment string// nullableIssue *Issuediff --git a/backend/component/webhook/manager.go b/backend/component/webhook/manager.goindex 2a23497db5..915d039023 100644--- a/backend/component/webhook/manager.go+++ b/backend/component/webhook/manager.go@@ -11,7 +11,6 @@ import ("github.com/gosimple/slug""github.com/nyaruka/phonenumbers"- "github.com/bytebase/bytebase/backend/base""github.com/bytebase/bytebase/backend/common""github.com/bytebase/bytebase/backend/common/log""github.com/bytebase/bytebase/backend/component/iam"@@ -67,7 +66,7 @@ func (m *Manager) CreateEvent(ctx context.Context, e *Event) {go m.postWebhookList(ctx, webhookCtx, webhookList)}-func (m *Manager) getWebhookContextFromEvent(ctx context.Context, e *Event, eventType base.EventType) (*webhook.Context, error) {+func (m *Manager) getWebhookContextFromEvent(ctx context.Context, e *Event, eventType common.EventType) (*webhook.Context, error) {var webhookCtx webhook.Contextvar mentions []stringvar mentionUsers []*store.UserMessage@@ -87,11 +86,11 @@ func (m *Manager) getWebhookContextFromEvent(ctx context.Context, e *Event, evenlink = fmt.Sprintf("%s/projects/%s/rollouts/%d", setting.ExternalUrl, e.Project.ResourceID, e.Rollout.UID)}switch e.Type {- case base.EventTypeIssueCreate:+ case common.EventTypeIssueCreate:title = "Issue created"titleZh = "创建工单"- case base.EventTypeIssueStatusUpdate:+ case common.EventTypeIssueStatusUpdate:switch e.Issue.Status {case "OPEN":title = "Issue reopened"@@ -105,11 +104,11 @@ func (m *Manager) getWebhookContextFromEvent(ctx context.Context, e *Event, eventitleZh = "工单取消"}- case base.EventTypeIssueCommentCreate:+ case common.EventTypeIssueCommentCreate:title = "Comment created"titleZh = "工单新评论"- case base.EventTypeIssueUpdate:+ case common.EventTypeIssueUpdate:update := e.IssueUpdateswitch update.Path {case "description":@@ -123,7 +122,7 @@ func (m *Manager) getWebhookContextFromEvent(ctx context.Context, e *Event, eventitleZh = "工单信息变更"}- case base.EventTypeStageStatusUpdate:+ case common.EventTypeStageStatusUpdate:u := e.StageStatusUpdateif e.Issue != nil {link = fmt.Sprintf("%s/projects/%s/issues/%s-%d?stage=%s", setting.ExternalUrl, e.Project.ResourceID, slug.Make(e.Issue.Title), e.Issue.UID, u.StageID)@@ -131,7 +130,7 @@ func (m *Manager) getWebhookContextFromEvent(ctx context.Context, e *Event, eventitle = "Stage ends"titleZh = "阶段结束"- case base.EventTypeTaskRunStatusUpdate:+ case common.EventTypeTaskRunStatusUpdate:u := e.TaskRunStatusUpdateswitch u.Status {case storepb.TaskRun_PENDING.String():@@ -159,7 +158,7 @@ func (m *Manager) getWebhookContextFromEvent(ctx context.Context, e *Event, eventitleZh = "任务状态变更"}- case base.EventTypeIssueApprovalPass:+ case common.EventTypeIssueApprovalPass:title = "Issue approved"titleZh = "工单审批通过"@@ -171,7 +170,7 @@ func (m *Manager) getWebhookContextFromEvent(ctx context.Context, e *Event, evenmentions = append(mentions, phone)}- case base.EventTypeIssueRolloutReady:+ case common.EventTypeIssueRolloutReady:u := e.IssueRolloutReadytitle = "Issue is waiting for rollout"titleZh = "工单待发布"@@ -180,7 +179,7 @@ func (m *Manager) getWebhookContextFromEvent(ctx context.Context, e *Event, evenusersGetters = append(usersGetters, getUsersFromUsers(e.Issue.Creator))} else {for _, role := range u.RolloutPolicy.GetRoles() {- role := base.Role(strings.TrimPrefix(role, "roles/"))+ role := strings.TrimPrefix(role, "roles/")usersGetters = append(usersGetters, getUsersFromRole(m.store, role, e.Project.ResourceID))}for _, issueRole := range u.RolloutPolicy.GetIssueRoles() {@@ -223,7 +222,7 @@ func (m *Manager) getWebhookContextFromEvent(ctx context.Context, e *Event, even}}- case base.EventTypeIssueApprovalCreate:+ case common.EventTypeIssueApprovalCreate:pendingStep := e.IssueApprovalCreate.ApprovalSteptitle = "Issue approval needed"@@ -238,7 +237,7 @@ func (m *Manager) getWebhookContextFromEvent(ctx context.Context, e *Event, evenvar usersGetter func(ctx context.Context) ([]*store.UserMessage, error)- role := base.Role(strings.TrimPrefix(node.Role, "roles/"))+ role := strings.TrimPrefix(node.Role, "roles/")usersGetter = getUsersFromRole(m.store, role, e.Project.ResourceID)users, err := usersGetter(ctx)@@ -355,7 +354,7 @@ func (m *Manager) postWebhookList(ctx context.Context, webhookCtx *webhook.Conte}}-func getUsersFromRole(s *store.Store, role base.Role, projectID string) func(context.Context) ([]*store.UserMessage, error) {+func getUsersFromRole(s *store.Store, role string, projectID string) func(context.Context) ([]*store.UserMessage, error) {return func(ctx context.Context) ([]*store.UserMessage, error) {projectIAM, err := s.GetProjectIamPolicy(ctx, projectID)if err != nil {@@ -424,7 +423,7 @@ func ChangeIssueStatus(ctx context.Context, stores *store.Store, webhookManager// In the ChangeIssueStatus functionwebhookManager.CreateEvent(ctx, &Event{Actor: updater,- Type: base.EventTypeIssueStatusUpdate,+ Type: common.EventTypeIssueStatusUpdate,Comment: comment,Issue: NewIssue(updatedIssue),Project: NewProject(updatedIssue.Project),diff --git a/backend/plugin/advisor/mssql/advisor_builtin_prior_backup_check.go b/backend/plugin/advisor/mssql/advisor_builtin_prior_backup_check.goindex 18446b1c5e..47b553dd25 100644--- a/backend/plugin/advisor/mssql/advisor_builtin_prior_backup_check.go+++ b/backend/plugin/advisor/mssql/advisor_builtin_prior_backup_check.go@@ -9,7 +9,6 @@ import (parser "github.com/bytebase/tsql-parser""github.com/pkg/errors"- "github.com/bytebase/bytebase/backend/base""github.com/bytebase/bytebase/backend/common""github.com/bytebase/bytebase/backend/plugin/advisor"tsqlparser "github.com/bytebase/bytebase/backend/plugin/parser/tsql"@@ -60,7 +59,7 @@ func (*StatementPriorBackupCheckAdvisor) Check(ctx context.Context, checkCtx adv})}- databaseName := base.BackupDatabaseNameOfEngine(storepb.Engine_MSSQL)+ databaseName := common.BackupDatabaseNameOfEngine(storepb.Engine_MSSQL)if !advisor.DatabaseExists(ctx, checkCtx, databaseName) {adviceList = append(adviceList, &storepb.Advice{Status: level,diff --git a/backend/plugin/advisor/mysql/advisor_builtin_prior_backup_check.go b/backend/plugin/advisor/mysql/advisor_builtin_prior_backup_check.goindex b65e45ae9a..0055c4a754 100644--- a/backend/plugin/advisor/mysql/advisor_builtin_prior_backup_check.go+++ b/backend/plugin/advisor/mysql/advisor_builtin_prior_backup_check.go@@ -7,7 +7,6 @@ import ("github.com/antlr4-go/antlr/v4""github.com/pkg/errors"- "github.com/bytebase/bytebase/backend/base""github.com/bytebase/bytebase/backend/common""github.com/bytebase/bytebase/backend/plugin/advisor"mysqlparser "github.com/bytebase/bytebase/backend/plugin/parser/mysql"@@ -67,7 +66,7 @@ func (*StatementPriorBackupCheckAdvisor) Check(ctx context.Context, checkCtx adv}}- databaseName := base.BackupDatabaseNameOfEngine(storepb.Engine_MYSQL)+ databaseName := common.BackupDatabaseNameOfEngine(storepb.Engine_MYSQL)if !advisor.DatabaseExists(ctx, checkCtx, databaseName) {adviceList = append(adviceList, &storepb.Advice{Status: level,diff --git a/backend/plugin/advisor/mysql/advisor_online_migration.go b/backend/plugin/advisor/mysql/advisor_online_migration.goindex cfdf05d698..cfc3ba4e0d 100644--- a/backend/plugin/advisor/mysql/advisor_online_migration.go+++ b/backend/plugin/advisor/mysql/advisor_online_migration.go@@ -11,7 +11,6 @@ import (mysql "github.com/bytebase/mysql-parser"- "github.com/bytebase/bytebase/backend/base""github.com/bytebase/bytebase/backend/common""github.com/bytebase/bytebase/backend/plugin/advisor"parserbase "github.com/bytebase/bytebase/backend/plugin/parser/base"@@ -55,7 +54,7 @@ func (*OnlineMigrationAdvisor) Check(ctx context.Context, checkCtx advisor.Conte// Check gh-ost database existence first if the change type is gh-ost.if checkCtx.ChangeType == storepb.PlanCheckRunConfig_DDL_GHOST {- ghostDatabaseName := base.BackupDatabaseNameOfEngine(storepb.Engine_MYSQL)+ ghostDatabaseName := common.BackupDatabaseNameOfEngine(storepb.Engine_MYSQL)if !advisor.DatabaseExists(ctx, checkCtx, ghostDatabaseName) {return []*storepb.Advice{{diff --git a/backend/plugin/advisor/oracle/advisor_builtin_prior_backup_check.go b/backend/plugin/advisor/oracle/advisor_builtin_prior_backup_check.goindex f93becaff3..7303dd4bd5 100644--- a/backend/plugin/advisor/oracle/advisor_builtin_prior_backup_check.go+++ b/backend/plugin/advisor/oracle/advisor_builtin_prior_backup_check.go@@ -9,7 +9,6 @@ import (plsql "github.com/bytebase/plsql-parser"- "github.com/bytebase/bytebase/backend/base""github.com/bytebase/bytebase/backend/common""github.com/bytebase/bytebase/backend/plugin/advisor"plsqlparser "github.com/bytebase/bytebase/backend/plugin/parser/plsql"@@ -54,7 +53,7 @@ func (*StatementPriorBackupCheckAdvisor) Check(ctx context.Context, checkCtx adv})}- databaseName := base.BackupDatabaseNameOfEngine(storepb.Engine_ORACLE)+ databaseName := common.BackupDatabaseNameOfEngine(storepb.Engine_ORACLE)if !advisor.DatabaseExists(ctx, checkCtx, databaseName) {adviceList = append(adviceList, &storepb.Advice{Status: level,diff --git a/backend/plugin/advisor/pg/advisor_builtin_prior_backup_check.go b/backend/plugin/advisor/pg/advisor_builtin_prior_backup_check.goindex eef9c748b3..d0516a85e6 100644--- a/backend/plugin/advisor/pg/advisor_builtin_prior_backup_check.go+++ b/backend/plugin/advisor/pg/advisor_builtin_prior_backup_check.go@@ -12,7 +12,6 @@ import (parser "github.com/bytebase/postgresql-parser"- "github.com/bytebase/bytebase/backend/base""github.com/bytebase/bytebase/backend/common""github.com/bytebase/bytebase/backend/common/log""github.com/bytebase/bytebase/backend/plugin/advisor"@@ -66,7 +65,7 @@ func (*BuiltinPriorBackupCheckAdvisor) Check(_ context.Context, checkCtx advisor}}- schemaName := base.BackupDatabaseNameOfEngine(storepb.Engine_POSTGRES)+ schemaName := common.BackupDatabaseNameOfEngine(storepb.Engine_POSTGRES)if !checkCtx.Catalog.Origin.HasSchema(schemaName) {adviceList = append(adviceList, &storepb.Advice{Status: level,diff --git a/backend/plugin/advisor/tidb/advisor_builtin_prior_backup_check.go b/backend/plugin/advisor/tidb/advisor_builtin_prior_backup_check.goindex c8608f3c81..9f6f73aa26 100644--- a/backend/plugin/advisor/tidb/advisor_builtin_prior_backup_check.go+++ b/backend/plugin/advisor/tidb/advisor_builtin_prior_backup_check.go@@ -10,7 +10,6 @@ import ("github.com/pingcap/tidb/pkg/parser/opcode""github.com/pkg/errors"- "github.com/bytebase/bytebase/backend/base""github.com/bytebase/bytebase/backend/common""github.com/bytebase/bytebase/backend/common/log""github.com/bytebase/bytebase/backend/plugin/advisor"@@ -79,7 +78,7 @@ func (*StatementPriorBackupCheckAdvisor) Check(ctx context.Context, checkCtx adv}}- databaseName := base.BackupDatabaseNameOfEngine(storepb.Engine_TIDB)+ databaseName := common.BackupDatabaseNameOfEngine(storepb.Engine_TIDB)if !advisor.DatabaseExists(ctx, checkCtx, databaseName) {adviceList = append(adviceList, &storepb.Advice{Status: level,diff --git a/backend/plugin/schema/pg/get_database_definition.go b/backend/plugin/schema/pg/get_database_definition.goindex 0022953e28..094cb64ef6 100644--- a/backend/plugin/schema/pg/get_database_definition.go+++ b/backend/plugin/schema/pg/get_database_definition.go@@ -6,7 +6,7 @@ import ("github.com/pkg/errors"- "github.com/bytebase/bytebase/backend/base"+ "github.com/bytebase/bytebase/backend/common"parserbase "github.com/bytebase/bytebase/backend/plugin/parser/base""github.com/bytebase/bytebase/backend/plugin/parser/sql/ast"pgrawparser "github.com/bytebase/bytebase/backend/plugin/parser/sql/engine/pg"@@ -512,7 +512,7 @@ func filterBackupSchemaIfNecessary(ctx schema.GetDefinitionContext, metadata *stExtensions: metadata.Extensions,}for _, schema := range metadata.Schemas {- if schema.Name == base.BackupDatabaseNameOfEngine(storepb.Engine_POSTGRES) {+ if schema.Name == common.BackupDatabaseNameOfEngine(storepb.Engine_POSTGRES) {continue}filtered.Schemas = append(filtered.Schemas, schema)diff --git a/backend/runner/approval/runner.go b/backend/runner/approval/runner.goindex d1af791c95..bd6eeba60f 100644--- a/backend/runner/approval/runner.go+++ b/backend/runner/approval/runner.go@@ -238,7 +238,7 @@ func (r *Runner) findApprovalTemplateForIssue(ctx context.Context, issue *store.}r.webhookManager.CreateEvent(ctx, &webhook.Event{Actor: r.store.GetSystemBotUser(ctx),- Type: base.EventTypeIssueRolloutReady,+ Type: common.EventTypeIssueRolloutReady,Comment: "",Issue: webhook.NewIssue(issue),Project: webhook.NewProject(issue.Project),@@ -262,7 +262,7 @@ func (r *Runner) findApprovalTemplateForIssue(ctx context.Context, issue *store.}r.webhookManager.CreateEvent(ctx, &webhook.Event{Actor: r.store.GetSystemBotUser(ctx),- Type: base.EventTypeIssueApprovalCreate,+ Type: common.EventTypeIssueApprovalCreate,Comment: "",Issue: webhook.NewIssue(issue),Project: webhook.NewProject(issue.Project),diff --git a/backend/runner/metricreport/reporter.go b/backend/runner/metricreport/reporter.goindex 637b406d25..4fc21edb79 100644--- a/backend/runner/metricreport/reporter.go+++ b/backend/runner/metricreport/reporter.go@@ -11,6 +11,7 @@ import ("github.com/pkg/errors""github.com/bytebase/bytebase/backend/base"+ "github.com/bytebase/bytebase/backend/common""github.com/bytebase/bytebase/backend/common/log""github.com/bytebase/bytebase/backend/component/config"enterprise "github.com/bytebase/bytebase/backend/enterprise/api"@@ -169,9 +170,9 @@ func (m *Reporter) identify(ctx context.Context) (string, error) {subscriptionEndDate = time.Unix(subscription.ExpiresTS, 0).Format(time.RFC3339)}- user, err := m.store.GetUserByID(ctx, base.PrincipalIDForFirstUser)+ user, err := m.store.GetUserByID(ctx, common.PrincipalIDForFirstUser)if err != nil {- slog.Debug("unable to get the first principal user", slog.Int("id", base.PrincipalIDForFirstUser), log.BBError(err))+ slog.Debug("unable to get the first principal user", slog.Int("id", common.PrincipalIDForFirstUser), log.BBError(err))}email := ""name := ""diff --git a/backend/runner/plancheck/ghost_sync_executor.go b/backend/runner/plancheck/ghost_sync_executor.goindex 16c46c24a5..b3002a881a 100644--- a/backend/runner/plancheck/ghost_sync_executor.go+++ b/backend/runner/plancheck/ghost_sync_executor.go@@ -12,7 +12,6 @@ import (gomysql "github.com/go-sql-driver/mysql""github.com/pkg/errors"- "github.com/bytebase/bytebase/backend/base""github.com/bytebase/bytebase/backend/common""github.com/bytebase/bytebase/backend/common/log""github.com/bytebase/bytebase/backend/component/dbfactory"@@ -130,7 +129,7 @@ func (e *GhostSyncExecutor) Run(ctx context.Context, config *storepb.PlanCheckRudefer driver.Close(ctx)// Use the backup database name of MySQL as the ghost database name.- ghostDBName := base.BackupDatabaseNameOfEngine(storepb.Engine_MYSQL)+ ghostDBName := common.BackupDatabaseNameOfEngine(storepb.Engine_MYSQL)sql := fmt.Sprintf("DROP TABLE IF EXISTS `%s`.`%s`; DROP TABLE IF EXISTS `%s`.`%s`;",ghostDBName,migrationContext.GetGhostTableName(),diff --git a/backend/runner/plancheck/scheduler.go b/backend/runner/plancheck/scheduler.goindex a0e3aa4f34..bc24ff8198 100644--- a/backend/runner/plancheck/scheduler.go+++ b/backend/runner/plancheck/scheduler.go@@ -10,7 +10,7 @@ import ("github.com/pkg/errors"- "github.com/bytebase/bytebase/backend/base"+ "github.com/bytebase/bytebase/backend/common""github.com/bytebase/bytebase/backend/common/log""github.com/bytebase/bytebase/backend/component/state"enterprise "github.com/bytebase/bytebase/backend/enterprise/api"@@ -114,7 +114,7 @@ func (s *Scheduler) runPlanCheckRun(ctx context.Context, planCheckRun *store.PlamaximumConnections := int(instance.Metadata.GetMaximumConnections())if maximumConnections <= 0 {- maximumConnections = base.DefaultInstanceMaximumConnections+ maximumConnections = common.DefaultInstanceMaximumConnections}if s.stateCfg.InstanceOutstandingConnections.Increment(instance.ResourceID, maximumConnections) {returndiff --git a/backend/runner/plancheck/statement_advise_executor.go b/backend/runner/plancheck/statement_advise_executor.goindex 9fcac524cf..d879112a29 100644--- a/backend/runner/plancheck/statement_advise_executor.go+++ b/backend/runner/plancheck/statement_advise_executor.go@@ -100,7 +100,7 @@ func (e *StatementAdviseExecutor) Run(ctx context.Context, config *storepb.PlanCif instance == nil {return nil, errors.Errorf("instance %s not found", config.InstanceId)}- if !base.EngineSupportStatementAdvise(instance.Metadata.GetEngine()) {+ if !common.EngineSupportStatementAdvise(instance.Metadata.GetEngine()) {return []*storepb.PlanCheckRunResult_Result{{Status: storepb.PlanCheckRunResult_Result_SUCCESS,diff --git a/backend/runner/plancheck/statement_report_executor.go b/backend/runner/plancheck/statement_report_executor.goindex d64f961ce2..06665b38e4 100644--- a/backend/runner/plancheck/statement_report_executor.go+++ b/backend/runner/plancheck/statement_report_executor.go@@ -7,7 +7,6 @@ import ("github.com/pkg/errors"- "github.com/bytebase/bytebase/backend/base""github.com/bytebase/bytebase/backend/common""github.com/bytebase/bytebase/backend/common/log""github.com/bytebase/bytebase/backend/component/dbfactory"@@ -79,7 +78,7 @@ func (e *StatementReportExecutor) Run(ctx context.Context, config *storepb.PlanCif instance == nil {return nil, errors.Errorf("instance %s not found", config.InstanceId)}- if !base.EngineSupportStatementReport(instance.Metadata.GetEngine()) {+ if !common.EngineSupportStatementReport(instance.Metadata.GetEngine()) {return []*storepb.PlanCheckRunResult_Result{{Status: storepb.PlanCheckRunResult_Result_SUCCESS,diff --git a/backend/runner/schemasync/syncer.go b/backend/runner/schemasync/syncer.goindex 0b29b9df82..5c8c03c214 100644--- a/backend/runner/schemasync/syncer.go+++ b/backend/runner/schemasync/syncer.go@@ -17,7 +17,6 @@ import ("google.golang.org/protobuf/proto""google.golang.org/protobuf/types/known/timestamppb"- "github.com/bytebase/bytebase/backend/base""github.com/bytebase/bytebase/backend/common""github.com/bytebase/bytebase/backend/common/log""github.com/bytebase/bytebase/backend/component/config"@@ -112,7 +111,7 @@ func (s *Syncer) Run(ctx context.Context, wg *sync.WaitGroup) {}maximumConnections := int(instance.Metadata.GetMaximumConnections())if maximumConnections <= 0 {- maximumConnections = base.DefaultInstanceMaximumConnections+ maximumConnections = common.DefaultInstanceMaximumConnections}if s.stateCfg.InstanceOutstandingConnections.Increment(instance.ResourceID, maximumConnections) {return true@@ -324,7 +323,7 @@ func (s *Syncer) SyncInstance(ctx context.Context, instance *store.InstanceMessanewDatabase, err := s.store.CreateDatabaseDefault(ctx, &store.DatabaseMessage{InstanceID: instance.ResourceID,DatabaseName: databaseMetadata.Name,- ProjectID: base.DefaultProjectID,+ ProjectID: common.DefaultProjectID,})if err != nil {return nil, nil, nil, errors.Wrapf(err, "failed to create instance %q database %q in sync runner", instance.ResourceID, databaseMetadata.Name)@@ -586,7 +585,7 @@ func (s *Syncer) getSchemaDrifted(ctx context.Context, instance *store.InstanceM}func (s *Syncer) databaseBackupAvailable(ctx context.Context, instance *store.InstanceMessage, dbSchema *storepb.DatabaseSchemaMetadata) bool {- if !base.EngineSupportPriorBackup(instance.Metadata.GetEngine()) {+ if !common.EngineSupportPriorBackup(instance.Metadata.GetEngine()) {return false}switch instance.Metadata.GetEngine() {@@ -595,12 +594,12 @@ func (s *Syncer) databaseBackupAvailable(ctx context.Context, instance *store.Inreturn false}for _, schema := range dbSchema.Schemas {- if schema.GetName() == base.BackupDatabaseNameOfEngine(storepb.Engine_POSTGRES) {+ if schema.GetName() == common.BackupDatabaseNameOfEngine(storepb.Engine_POSTGRES) {return true}}case storepb.Engine_MYSQL, storepb.Engine_MSSQL, storepb.Engine_TIDB:- dbName := base.BackupDatabaseNameOfEngine(instance.Metadata.GetEngine())+ dbName := common.BackupDatabaseNameOfEngine(instance.Metadata.GetEngine())backupDB, err := s.store.GetDatabaseV2(ctx, &store.FindDatabaseMessage{InstanceID: &instance.ResourceID,DatabaseName: &dbName,@@ -611,7 +610,7 @@ func (s *Syncer) databaseBackupAvailable(ctx context.Context, instance *store.In}return backupDB != nilcase storepb.Engine_ORACLE:- dbName := base.BackupDatabaseNameOfEngine(storepb.Engine_ORACLE)+ dbName := common.BackupDatabaseNameOfEngine(storepb.Engine_ORACLE)backupDB, err := s.store.GetDatabaseV2(ctx, &store.FindDatabaseMessage{InstanceID: &instance.ResourceID,DatabaseName: &dbName,diff --git a/backend/runner/taskrun/data_update_executor.go b/backend/runner/taskrun/data_update_executor.goindex 7bae1cafde..7c65225ab0 100644--- a/backend/runner/taskrun/data_update_executor.go+++ b/backend/runner/taskrun/data_update_executor.go@@ -18,7 +18,6 @@ import (enterprise "github.com/bytebase/bytebase/backend/enterprise/api""github.com/bytebase/bytebase/backend/runner/schemasync"- "github.com/bytebase/bytebase/backend/base""github.com/bytebase/bytebase/backend/plugin/db""github.com/bytebase/bytebase/backend/plugin/db/oracle"parserbase "github.com/bytebase/bytebase/backend/plugin/parser/base"@@ -84,7 +83,7 @@ func (exec *DataUpdateExecutor) RunOnce(ctx context.Context, driverCtx context.Cvar priorBackupDetail *storepb.PriorBackupDetail// Check if we should skip backup or not.- if base.EngineSupportPriorBackup(instance.Metadata.GetEngine()) {+ if common.EngineSupportPriorBackup(instance.Metadata.GetEngine()) {var backupErr errorpriorBackupDetail, backupErr = exec.backupData(ctx, driverCtx, statement, task.Payload, task, issueN, instance, database)if backupErr != nil {@@ -106,7 +105,7 @@ func (exec *DataUpdateExecutor) RunOnce(ctx context.Context, driverCtx context.C},},},- }, base.SystemBotID); err != nil {+ }, common.SystemBotID); err != nil {slog.Warn("failed to create issue comment", "task", task.ID, log.BBError(err), "backup error", backupErr)}}@@ -170,7 +169,7 @@ func (exec *DataUpdateExecutor) backupData(sourceDatabaseName := common.FormatDatabase(database.InstanceID, database.DatabaseName)// Format: instances/{instance}/databases/{database}- backupDBName := base.BackupDatabaseNameOfEngine(instance.Metadata.GetEngine())+ backupDBName := common.BackupDatabaseNameOfEngine(instance.Metadata.GetEngine())targetDatabaseName := common.FormatDatabase(database.InstanceID, backupDBName)var backupDatabase *store.DatabaseMessagevar backupDriver db.Driver@@ -323,7 +322,7 @@ func (exec *DataUpdateExecutor) backupData(},},},- }, base.SystemBotID); err != nil {+ }, common.SystemBotID); err != nil {slog.Warn("failed to create issue comment", "task", task.ID, log.BBError(err))}}diff --git a/backend/runner/taskrun/database_create_executor.go b/backend/runner/taskrun/database_create_executor.goindex 733762bf21..6b084804a4 100644--- a/backend/runner/taskrun/database_create_executor.go+++ b/backend/runner/taskrun/database_create_executor.go@@ -8,7 +8,7 @@ import ("github.com/pkg/errors"- "github.com/bytebase/bytebase/backend/base"+ "github.com/bytebase/bytebase/backend/common""github.com/bytebase/bytebase/backend/common/log""github.com/bytebase/bytebase/backend/component/config""github.com/bytebase/bytebase/backend/component/dbfactory"@@ -64,7 +64,7 @@ func (exec *DatabaseCreateExecutor) RunOnce(ctx context.Context, driverCtx contereturn true, nil, err}- if !base.EngineSupportCreateDatabase(instance.Metadata.GetEngine()) {+ if !common.EngineSupportCreateDatabase(instance.Metadata.GetEngine()) {return true, nil, errors.Errorf("creating database is not supported for engine %v", instance.Metadata.GetEngine().String())}diff --git a/backend/runner/taskrun/schedulerv2.go b/backend/runner/taskrun/schedulerv2.goindex 887ac84125..8f42aa01e8 100644--- a/backend/runner/taskrun/schedulerv2.go+++ b/backend/runner/taskrun/schedulerv2.go@@ -12,7 +12,6 @@ import ("google.golang.org/protobuf/encoding/protojson""google.golang.org/protobuf/types/known/timestamppb"- "github.com/bytebase/bytebase/backend/base""github.com/bytebase/bytebase/backend/common""github.com/bytebase/bytebase/backend/common/log""github.com/bytebase/bytebase/backend/component/config"@@ -230,7 +229,7 @@ func (s *SchedulerV2) scheduleAutoRolloutTask(ctx context.Context, taskUID int)}create := &store.TaskRunMessage{- CreatorID: base.SystemBotID,+ CreatorID: common.SystemBotID,TaskUID: task.ID,}if task.Payload.GetSheetId() != 0 {@@ -244,13 +243,13 @@ func (s *SchedulerV2) scheduleAutoRolloutTask(ctx context.Context, taskUID int)if issue != nil {tasks := []string{common.FormatTask(issue.Project.ResourceID, task.PipelineID, task.Environment, taskUID)}- if err := s.store.CreateIssueCommentTaskUpdateStatus(ctx, issue.UID, tasks, storepb.IssueCommentPayload_TaskUpdate_PENDING, base.SystemBotID, ""); err != nil {+ if err := s.store.CreateIssueCommentTaskUpdateStatus(ctx, issue.UID, tasks, storepb.IssueCommentPayload_TaskUpdate_PENDING, common.SystemBotID, ""); err != nil {slog.Warn("failed to create issue comment", "issueUID", issue.UID, log.BBError(err))}}s.webhookManager.CreateEvent(ctx, &webhook.Event{Actor: s.store.GetSystemBotUser(ctx),- Type: base.EventTypeTaskRunStatusUpdate,+ Type: common.EventTypeTaskRunStatusUpdate,Comment: "",Issue: webhook.NewIssue(issue),Rollout: webhook.NewRollout(pipeline),@@ -331,7 +330,7 @@ func (s *SchedulerV2) schedulePendingTaskRun(ctx context.Context, taskRun *storeif _, err := s.store.UpdateTaskRunStatus(ctx, &store.TaskRunStatusPatch{ID: taskRun.ID,- UpdaterID: base.SystemBotID,+ UpdaterID: common.SystemBotID,Status: storepb.TaskRun_RUNNING,}); err != nil {return errors.Wrapf(err, "failed to update task run status to running")@@ -440,7 +439,7 @@ func (s *SchedulerV2) scheduleRunningTaskRun(ctx context.Context, taskRun *store// Check max connections per instance.maximumConnections := int(instance.Metadata.GetMaximumConnections())if maximumConnections <= 0 {- maximumConnections = base.DefaultInstanceMaximumConnections+ maximumConnections = common.DefaultInstanceMaximumConnections}if s.stateCfg.InstanceOutstandingConnections.Increment(task.InstanceID, maximumConnections) {s.stateCfg.TaskRunSchedulerInfo.Store(taskRun.ID, &storepb.SchedulerInfo{@@ -588,7 +587,7 @@ func (s *SchedulerV2) runTaskRunOnce(ctx context.Context, taskRun *store.TaskRunresult := string(resultBytes)taskRunStatusPatch := &store.TaskRunStatusPatch{ID: taskRun.ID,- UpdaterID: base.SystemBotID,+ UpdaterID: common.SystemBotID,Status: storepb.TaskRun_CANCELED,Code: &code,Result: &result,@@ -636,7 +635,7 @@ func (s *SchedulerV2) runTaskRunOnce(ctx context.Context, taskRun *store.TaskRunresult := string(resultBytes)taskRunStatusPatch := &store.TaskRunStatusPatch{ID: taskRun.ID,- UpdaterID: base.SystemBotID,+ UpdaterID: common.SystemBotID,Status: storepb.TaskRun_FAILED,Code: &code,Result: &result,@@ -661,7 +660,7 @@ func (s *SchedulerV2) runTaskRunOnce(ctx context.Context, taskRun *store.TaskRunreturn nil}tasks := []string{common.FormatTask(issue.Project.ResourceID, task.PipelineID, task.Environment, task.ID)}- return s.store.CreateIssueCommentTaskUpdateStatus(ctx, issue.UID, tasks, storepb.IssueCommentPayload_TaskUpdate_FAILED, base.SystemBotID, "")+ return s.store.CreateIssueCommentTaskUpdateStatus(ctx, issue.UID, tasks, storepb.IssueCommentPayload_TaskUpdate_FAILED, common.SystemBotID, "")}(); err != nil {slog.Warn("failed to create issue comment", log.BBError(err))}@@ -684,7 +683,7 @@ func (s *SchedulerV2) runTaskRunOnce(ctx context.Context, taskRun *store.TaskRunresult := string(resultBytes)taskRunStatusPatch := &store.TaskRunStatusPatch{ID: taskRun.ID,- UpdaterID: base.SystemBotID,+ UpdaterID: common.SystemBotID,Status: storepb.TaskRun_DONE,Code: &code,Result: &result,@@ -708,7 +707,7 @@ func (s *SchedulerV2) runTaskRunOnce(ctx context.Context, taskRun *store.TaskRunreturn nil}tasks := []string{common.FormatTask(issue.Project.ResourceID, task.PipelineID, task.Environment, task.ID)}- return s.store.CreateIssueCommentTaskUpdateStatus(ctx, issue.UID, tasks, storepb.IssueCommentPayload_TaskUpdate_DONE, base.SystemBotID, "")+ return s.store.CreateIssueCommentTaskUpdateStatus(ctx, issue.UID, tasks, storepb.IssueCommentPayload_TaskUpdate_DONE, common.SystemBotID, "")}(); err != nil {slog.Warn("failed to create issue comment", log.BBError(err))}@@ -818,7 +817,7 @@ func (s *SchedulerV2) ListenTaskSkippedOrDone(ctx context.Context) {}s.webhookManager.CreateEvent(ctx, &webhook.Event{Actor: s.store.GetSystemBotUser(ctx),- Type: base.EventTypeStageStatusUpdate,+ Type: common.EventTypeStageStatusUpdate,Comment: "",Issue: webhook.NewIssue(issue),Rollout: webhook.NewRollout(pipeline),@@ -844,7 +843,7 @@ func (s *SchedulerV2) ListenTaskSkippedOrDone(ctx context.Context) {_, err := s.store.CreateIssueComment(ctx, &store.IssueCommentMessage{IssueUID: issue.UID,Payload: p,- }, base.SystemBotID)+ }, common.SystemBotID)return err}(); err != nil {slog.Warn("failed to create issue comment", log.BBError(err))@@ -861,7 +860,7 @@ func (s *SchedulerV2) ListenTaskSkippedOrDone(ctx context.Context) {}s.webhookManager.CreateEvent(ctx, &webhook.Event{Actor: s.store.GetSystemBotUser(ctx),- Type: base.EventTypeIssueRolloutReady,+ Type: common.EventTypeIssueRolloutReady,Comment: "",Issue: webhook.NewIssue(issue),Project: webhook.NewProject(issue.Project),@@ -901,13 +900,13 @@ func (s *SchedulerV2) ListenTaskSkippedOrDone(ctx context.Context) {},},},- }, base.SystemBotID); err != nil {+ }, common.SystemBotID); err != nil {return errors.Wrapf(err, "failed to create issue comment after changing the issue status")}s.webhookManager.CreateEvent(ctx, &webhook.Event{Actor: s.store.GetSystemBotUser(ctx),- Type: base.EventTypeIssueStatusUpdate,+ Type: common.EventTypeIssueStatusUpdate,Comment: "",Issue: webhook.NewIssue(updatedIssue),Project: webhook.NewProject(updatedIssue.Project),@@ -952,7 +951,7 @@ func (s *SchedulerV2) createActivityForTaskRunStatusUpdate(ctx context.Context,}s.webhookManager.CreateEvent(ctx, &webhook.Event{Actor: s.store.GetSystemBotUser(ctx),- Type: base.EventTypeTaskRunStatusUpdate,+ Type: common.EventTypeTaskRunStatusUpdate,Comment: "",Issue: webhook.NewIssue(issue),Rollout: webhook.NewRollout(rollout),diff --git a/backend/runner/taskrun/schema_update_ghost_executor.go b/backend/runner/taskrun/schema_update_ghost_executor.goindex 8e5c45f94d..9cae02063e 100644--- a/backend/runner/taskrun/schema_update_ghost_executor.go+++ b/backend/runner/taskrun/schema_update_ghost_executor.go@@ -11,7 +11,6 @@ import (gomysql "github.com/go-sql-driver/mysql""github.com/pkg/errors"- "github.com/bytebase/bytebase/backend/base""github.com/bytebase/bytebase/backend/common""github.com/bytebase/bytebase/backend/common/log""github.com/bytebase/bytebase/backend/component/config"@@ -112,7 +111,7 @@ func (exec *SchemaUpdateGhostExecutor) RunOnce(ctx context.Context, driverCtx codefer driver.Close(ctx)// Use the backup database name of MySQL as the ghost database name.- ghostDBName := base.BackupDatabaseNameOfEngine(storepb.Engine_MYSQL)+ ghostDBName := common.BackupDatabaseNameOfEngine(storepb.Engine_MYSQL)sql := fmt.Sprintf("DROP TABLE IF EXISTS `%s`.`%s`; DROP TABLE IF EXISTS `%s`.`%s`;",ghostDBName,migrationContext.GetGhostTableName(),diff --git a/backend/server/init.go b/backend/server/init.goindex d9d649543c..b0a9ee3535 100644--- a/backend/server/init.go+++ b/backend/server/init.go@@ -7,7 +7,6 @@ import ("github.com/pkg/errors""google.golang.org/protobuf/encoding/protojson"- "github.com/bytebase/bytebase/backend/base""github.com/bytebase/bytebase/backend/common""github.com/bytebase/bytebase/backend/metric"metriccollector "github.com/bytebase/bytebase/backend/metric/collector"@@ -181,9 +180,9 @@ func (s *Server) initializeSetting(ctx context.Context) error {if firstTimeOnboarding {// Only grant workspace member role to allUsers at the first time.if _, err := s.store.PatchWorkspaceIamPolicy(ctx, &store.PatchIamPolicyMessage{- Member: base.AllUsers,+ Member: common.AllUsers,Roles: []string{- common.FormatRole(base.WorkspaceMember.String()),+ common.FormatRole(common.WorkspaceMember),},}); err != nil {return errdiff --git a/backend/store/policy.go b/backend/store/policy.goindex 9d30752eab..71fd806249 100644--- a/backend/store/policy.go+++ b/backend/store/policy.go@@ -13,7 +13,6 @@ import ("google.golang.org/protobuf/encoding/protojson""google.golang.org/protobuf/types/known/durationpb"- "github.com/bytebase/bytebase/backend/base""github.com/bytebase/bytebase/backend/common""github.com/bytebase/bytebase/backend/common/log"storepb "github.com/bytebase/bytebase/proto/generated-go/store"@@ -257,7 +256,7 @@ func (s *Store) getReviewConfigByResource(ctx context.Context, resourceType storreturn nil, errors.Wrapf(err, "failed to unmarshal tag policy payload")}- reviewConfigName, ok := payload.Tags[string(base.ReservedTagReviewConfig)]+ reviewConfigName, ok := payload.Tags[string(common.ReservedTagReviewConfig)]if !ok {return nil, &common.Error{Code: common.NotFound, Err: errors.Errorf("review config tag for resource %v/%s not found", resourceType, resource)}}diff --git a/backend/store/principal.go b/backend/store/principal.goindex c5e74342d2..57e1a5a118 100644--- a/backend/store/principal.go+++ b/backend/store/principal.go@@ -12,14 +12,13 @@ import ("google.golang.org/protobuf/encoding/protojson""google.golang.org/protobuf/types/known/timestamppb"- "github.com/bytebase/bytebase/backend/base""github.com/bytebase/bytebase/backend/common""github.com/bytebase/bytebase/backend/common/log"storepb "github.com/bytebase/bytebase/proto/generated-go/store")var systemBotUser = &UserMessage{- ID: base.SystemBotID,+ ID: common.SystemBotID,Name: "Bytebase",Email: "[email protected]",Type: storepb.PrincipalType_SYSTEM_BOT,@@ -73,9 +72,9 @@ type UserStat struct {// GetSystemBotUser gets the system bot.func (s *Store) GetSystemBotUser(ctx context.Context) *UserMessage {- user, err := s.GetUserByID(ctx, base.SystemBotID)+ user, err := s.GetUserByID(ctx, common.SystemBotID)if err != nil {- slog.Error("failed to find system bot", slog.Int("id", base.SystemBotID), log.BBError(err))+ slog.Error("failed to find system bot", slog.Int("id", common.SystemBotID), log.BBError(err))return systemBotUser}if user == nil {@@ -209,7 +208,7 @@ func listUserImpl(ctx context.Context, txn *sql.Tx, find *FindUserMessage) ([]*Uwhere, args = append(where, fmt.Sprintf("principal.id = $%d", len(args)+1)), append(args, *v)}if v := find.Email; v != nil {- if *v == base.AllUsers {+ if *v == common.AllUsers {where, args = append(where, fmt.Sprintf("principal.email = $%d", len(args)+1)), append(args, *v)} else {where, args = append(where, fmt.Sprintf("principal.email = $%d", len(args)+1)), append(args, strings.ToLower(*v))@@ -234,7 +233,7 @@ func listUserImpl(ctx context.Context, txn *sql.Tx, find *FindUserMessage) ([]*Uproject_members AS (SELECT ARRAY_AGG(member) AS members FROM all_members WHERE role LIKE 'roles/project%')`- join = `INNER JOIN project_members ON (CONCAT('users/', principal.id) = ANY(project_members.members) OR '` + base.AllUsers + `' = ANY(project_members.members))`+ join = `INNER JOIN project_members ON (CONCAT('users/', principal.id) = ANY(project_members.members) OR '` + common.AllUsers + `' = ANY(project_members.members))`}query := with + `@@ -373,7 +372,7 @@ func (s *Store) CreateUser(ctx context.Context, create *UserMessage) (*UserMessa// UpdateUser updates a user.func (s *Store) UpdateUser(ctx context.Context, currentUser *UserMessage, patch *UpdateUserMessage) (*UserMessage, error) {- if currentUser.ID == base.SystemBotID {+ if currentUser.ID == common.SystemBotID {return nil, errors.Errorf("cannot update system bot")}diff --git a/backend/store/project.go b/backend/store/project.goindex ffe5bd737c..ec3efb0cd3 100644--- a/backend/store/project.go+++ b/backend/store/project.go@@ -10,7 +10,6 @@ import ("google.golang.org/genproto/googleapis/type/expr""google.golang.org/protobuf/encoding/protojson"- "github.com/bytebase/bytebase/backend/base""github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/proto/generated-go/store")@@ -154,7 +153,7 @@ func (s *Store) CreateProjectV2(ctx context.Context, create *ProjectMessage, crepolicy := &storepb.IamPolicy{Bindings: []*storepb.Binding{{- Role: common.FormatRole(base.ProjectOwner.String()),+ Role: common.FormatRole(common.ProjectOwner),Members: []string{common.FormatUserUID(user.ID),},diff --git a/backend/store/project_webhook.go b/backend/store/project_webhook.goindex f55389bee0..c0c4c3776f 100644--- a/backend/store/project_webhook.go+++ b/backend/store/project_webhook.go@@ -10,7 +10,6 @@ import ("github.com/pkg/errors""google.golang.org/protobuf/encoding/protojson"- "github.com/bytebase/bytebase/backend/base""github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/proto/generated-go/store")@@ -50,7 +49,7 @@ type FindProjectWebhookMessage struct {ID *intProjectID *stringURL *string- EventType *base.EventType+ EventType *common.EventType}// CreateProjectWebhookV2 creates an instance of ProjectWebhook.@@ -302,7 +301,7 @@ func (*Store) findProjectWebhookImplV2(ctx context.Context, txn *sql.Tx, find *Fif v := find.EventType; v != nil {for _, activity := range projectWebhook.Events {- if base.EventType(activity) == *v {+ if common.EventType(activity) == *v {projectWebhooks = append(projectWebhooks, &projectWebhook)break}diff --git a/backend/tests/ghost_test.go b/backend/tests/ghost_test.goindex fb44b541c3..986c8d29a7 100644--- a/backend/tests/ghost_test.go+++ b/backend/tests/ghost_test.go@@ -6,7 +6,7 @@ import ("fmt""testing"- "github.com/bytebase/bytebase/backend/base"+ "github.com/bytebase/bytebase/backend/common"storepb "github.com/bytebase/bytebase/proto/generated-go/store"v1pb "github.com/bytebase/bytebase/proto/generated-go/v1"@@ -77,7 +77,7 @@ func TestGhostSchemaUpdate(t *testing.T) {a.NoError(err)// Create backup database for MySQL.- backupDBName := base.BackupDatabaseNameOfEngine(storepb.Engine_MYSQL)+ backupDBName := common.BackupDatabaseNameOfEngine(storepb.Engine_MYSQL)err = ctl.createDatabaseV2(ctx, ctl.project, instance, nil /* environment */, backupDBName, "")a.NoError(err)diff --git a/backend/tests/sql_review_test.go b/backend/tests/sql_review_test.goindex d7be7daf31..eb5b367eab 100644--- a/backend/tests/sql_review_test.go+++ b/backend/tests/sql_review_test.go@@ -21,7 +21,6 @@ import ("google.golang.org/protobuf/types/known/fieldmaskpb""gopkg.in/yaml.v3"- "github.com/bytebase/bytebase/backend/base""github.com/bytebase/bytebase/backend/common""github.com/bytebase/bytebase/backend/plugin/advisor"storepb "github.com/bytebase/bytebase/proto/generated-go/store"@@ -117,7 +116,7 @@ func TestSQLReviewForPostgreSQL(t *testing.T) {Policy: &v1pb.Policy_TagPolicy{TagPolicy: &v1pb.TagPolicy{Tags: map[string]string{- string(base.ReservedTagReviewConfig): createdConfig.Name,+ string(common.ReservedTagReviewConfig): createdConfig.Name,},},},@@ -287,7 +286,7 @@ func TestSQLReviewForMySQL(t *testing.T) {Policy: &v1pb.Policy_TagPolicy{TagPolicy: &v1pb.TagPolicy{Tags: map[string]string{- string(base.ReservedTagReviewConfig): createdConfig.Name,+ string(common.ReservedTagReviewConfig): createdConfig.Name,},},},diff --git a/backend/tests/user_test.go b/backend/tests/user_test.goindex 8f2b0769c9..1409c75dd8 100644--- a/backend/tests/user_test.go+++ b/backend/tests/user_test.go@@ -8,7 +8,7 @@ import ("github.com/stretchr/testify/require""google.golang.org/grpc/metadata"- "github.com/bytebase/bytebase/backend/base"+ "github.com/bytebase/bytebase/backend/common"v1pb "github.com/bytebase/bytebase/proto/generated-go/v1")@@ -114,7 +114,7 @@ func TestDeleteUser(t *testing.T) {// Test: check allUser in the bindingfor _, binding := range newPolicy.Bindings {if binding.Role == "roles/workspaceAdmin" {- binding.Members = []string{base.AllUsers}+ binding.Members = []string{common.AllUsers}break}}diff --git a/backend/utils/member.go b/backend/utils/member.goindex b21cd3a9f5..bf8ec1b872 100644--- a/backend/utils/member.go+++ b/backend/utils/member.go@@ -6,7 +6,6 @@ import ("strings""time"- "github.com/bytebase/bytebase/backend/base""github.com/bytebase/bytebase/backend/common""github.com/bytebase/bytebase/backend/common/log""github.com/bytebase/bytebase/backend/store"@@ -23,8 +22,8 @@ func validateIAMBinding(binding *storepb.Binding) bool {}// GetUsersByRoleInIAMPolicy gets users in the iam policy.-func GetUsersByRoleInIAMPolicy(ctx context.Context, stores *store.Store, role base.Role, policies ...*storepb.IamPolicy) []*store.UserMessage {- roleFullName := common.FormatRole(role.String())+func GetUsersByRoleInIAMPolicy(ctx context.Context, stores *store.Store, role string, policies ...*storepb.IamPolicy) []*store.UserMessage {+ roleFullName := common.FormatRole(role)var users []*store.UserMessageseen := map[string]bool{}@@ -39,13 +38,13 @@ func GetUsersByRoleInIAMPolicy(ctx context.Context, stores *store.Store, role ba}for _, member := range binding.Members {- if member == base.AllUsers {+ if member == common.AllUsers {// TODO(d): make it more efficient.allUsers, err := stores.ListUsers(ctx, &store.FindUserMessage{ShowDeleted: false,})if err != nil {- slog.Error("failed to list all users for role", slog.String("role", role.String()), log.BBError(err))+ slog.Error("failed to list all users for role", slog.String("role", role), log.BBError(err))continue}return allUsers@@ -130,7 +129,7 @@ func GetUserIAMPolicyBindings(ctx context.Context, stores *store.Store, user *sthasUser := falsefor _, member := range binding.Members {- if member == base.AllUsers {+ if member == common.AllUsers {hasUser = truebreak}