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: linter warning part 2 (#8997)
Danny Xu2f67a9e6fd76
diff --git a/backend/api/auth/auth.go b/backend/api/auth/auth.goindex a32776e659..ae5ba86e1b 100644--- a/backend/api/auth/auth.go+++ b/backend/api/auth/auth.go@@ -20,7 +20,7 @@ import ("github.com/bytebase/bytebase/backend/common""github.com/bytebase/bytebase/backend/component/state"- enterpriseAPI "github.com/bytebase/bytebase/backend/enterprise/api"+ enterprise "github.com/bytebase/bytebase/backend/enterprise/api""github.com/bytebase/bytebase/backend/store")@@ -53,13 +53,13 @@ type APIAuthInterceptor struct {store *store.Storesecret stringtokenDuration time.Duration- licenseService enterpriseAPI.LicenseService+ licenseService enterprise.LicenseServicestateCfg *state.Statemode common.ReleaseMode}// New returns a new API auth interceptor.-func New(store *store.Store, secret string, tokenDuration time.Duration, licenseService enterpriseAPI.LicenseService, stateCfg *state.State, mode common.ReleaseMode) *APIAuthInterceptor {+func New(store *store.Store, secret string, tokenDuration time.Duration, licenseService enterprise.LicenseService, stateCfg *state.State, mode common.ReleaseMode) *APIAuthInterceptor {return &APIAuthInterceptor{store: store,secret: secret,diff --git a/backend/api/gitops/gitops.go b/backend/api/gitops/gitops.goindex b1bd314919..43f6414a73 100644--- a/backend/api/gitops/gitops.go+++ b/backend/api/gitops/gitops.go@@ -6,7 +6,7 @@ import ("github.com/bytebase/bytebase/backend/component/activity""github.com/bytebase/bytebase/backend/component/dbfactory""github.com/bytebase/bytebase/backend/component/state"- enterpriseAPI "github.com/bytebase/bytebase/backend/enterprise/api"+ enterprise "github.com/bytebase/bytebase/backend/enterprise/api""github.com/bytebase/bytebase/backend/store")@@ -16,7 +16,7 @@ type Service struct {dbFactory *dbfactory.DBFactoryactivityManager *activity.ManagerstateCfg *state.State- licenseService enterpriseAPI.LicenseService+ licenseService enterprise.LicenseServicerolloutService *v1pb.RolloutServiceissueService *v1pb.IssueService}@@ -27,7 +27,7 @@ func NewService(dbFactory *dbfactory.DBFactory,activityManager *activity.Manager,stateCfg *state.State,- licenseService enterpriseAPI.LicenseService,+ licenseService enterprise.LicenseService,rolloutService *v1pb.RolloutService,issueService *v1pb.IssueService,) *Service {diff --git a/backend/api/v1/acl.go b/backend/api/v1/acl.goindex 01ebe8586a..b4a2556018 100644--- a/backend/api/v1/acl.go+++ b/backend/api/v1/acl.go@@ -12,7 +12,7 @@ import ("github.com/bytebase/bytebase/backend/api/auth""github.com/bytebase/bytebase/backend/common"- enterpriseAPI "github.com/bytebase/bytebase/backend/enterprise/api"+ enterprise "github.com/bytebase/bytebase/backend/enterprise/api"api "github.com/bytebase/bytebase/backend/legacyapi""github.com/bytebase/bytebase/backend/store"v1pb "github.com/bytebase/bytebase/proto/generated-go/v1"@@ -22,12 +22,12 @@ import (type ACLInterceptor struct {store *store.Storesecret string- licenseService enterpriseAPI.LicenseService+ licenseService enterprise.LicenseServicemode common.ReleaseMode}// NewACLInterceptor returns a new v1 API ACL interceptor.-func NewACLInterceptor(store *store.Store, secret string, licenseService enterpriseAPI.LicenseService, mode common.ReleaseMode) *ACLInterceptor {+func NewACLInterceptor(store *store.Store, secret string, licenseService enterprise.LicenseService, mode common.ReleaseMode) *ACLInterceptor {return &ACLInterceptor{store: store,secret: secret,@@ -149,7 +149,10 @@ func (in *ACLInterceptor) getUser(ctx context.Context) (*store.UserMessage, erroif principalPtr == nil {return nil, nil}- principalID := principalPtr.(int)+ principalID, ok := principalPtr.(int)+ if !ok {+ return nil, status.Errorf(codes.Internal, "principal ID not found")+ }user, err := in.store.GetUserByID(ctx, principalID)if err != nil {return nil, status.Errorf(codes.PermissionDenied, "failed to get member for user %v in processing authorize request.", principalID)diff --git a/backend/api/v1/auth_service.go b/backend/api/v1/auth_service.goindex 795a6e3864..5296cd449e 100644--- a/backend/api/v1/auth_service.go+++ b/backend/api/v1/auth_service.go@@ -24,7 +24,7 @@ import ("github.com/bytebase/bytebase/backend/common""github.com/bytebase/bytebase/backend/component/config""github.com/bytebase/bytebase/backend/component/state"- enterpriseAPI "github.com/bytebase/bytebase/backend/enterprise/api"+ enterprise "github.com/bytebase/bytebase/backend/enterprise/api"api "github.com/bytebase/bytebase/backend/legacyapi"metricAPI "github.com/bytebase/bytebase/backend/metric""github.com/bytebase/bytebase/backend/plugin/idp/ldap"@@ -49,7 +49,7 @@ type AuthService struct {store *store.Storesecret stringtokenDuration time.Duration- licenseService enterpriseAPI.LicenseService+ licenseService enterprise.LicenseServicemetricReporter *metricreport.Reporterprofile *config.ProfilestateCfg *state.State@@ -57,7 +57,7 @@ type AuthService struct {}// NewAuthService creates a new AuthService.-func NewAuthService(store *store.Store, secret string, tokenDuration time.Duration, licenseService enterpriseAPI.LicenseService, metricReporter *metricreport.Reporter, profile *config.Profile, stateCfg *state.State, postCreateUser func(ctx context.Context, user *store.UserMessage, firstEndUser bool) error) (*AuthService, error) {+func NewAuthService(store *store.Store, secret string, tokenDuration time.Duration, licenseService enterprise.LicenseService, metricReporter *metricreport.Reporter, profile *config.Profile, stateCfg *state.State, postCreateUser func(ctx context.Context, user *store.UserMessage, firstEndUser bool) error) (*AuthService, error) {return &AuthService{store: store,secret: secret,@@ -273,7 +273,10 @@ func (s *AuthService) UpdateUser(ctx context.Context, request *v1pb.UpdateUserRereturn nil, status.Errorf(codes.NotFound, "user %q has been deleted", userID)}- role := ctx.Value(common.RoleContextKey).(api.Role)+ role, ok := ctx.Value(common.RoleContextKey).(api.Role)+ if !ok {+ return nil, status.Errorf(codes.Internal, "role not found")+ }if principalID != userID && role != api.Owner {return nil, status.Errorf(codes.PermissionDenied, "only workspace owner or user itself can update the user %d", userID)}@@ -435,7 +438,10 @@ func (s *AuthService) DeleteUser(ctx context.Context, request *v1pb.DeleteUserRereturn nil, status.Errorf(codes.NotFound, "user %q has been deleted", userID)}- role := ctx.Value(common.RoleContextKey).(api.Role)+ role, ok := ctx.Value(common.RoleContextKey).(api.Role)+ if !ok {+ return nil, status.Errorf(codes.Internal, "role not found")+ }if role != api.Owner {return nil, status.Errorf(codes.PermissionDenied, "only workspace owner can delete the user %d", userID)}@@ -471,7 +477,10 @@ func (s *AuthService) UndeleteUser(ctx context.Context, request *v1pb.UndeleteUsreturn nil, status.Errorf(codes.InvalidArgument, "user %q is already active", userID)}- role := ctx.Value(common.RoleContextKey).(api.Role)+ role, ok := ctx.Value(common.RoleContextKey).(api.Role)+ if !ok {+ return nil, status.Errorf(codes.Internal, "role not found")+ }if role != api.Owner {return nil, status.Errorf(codes.PermissionDenied, "only workspace owner can undelete the user %d", userID)}@@ -934,7 +943,7 @@ func generateRecoveryCodes(n int) ([]string, error) {}func (s *AuthService) userCountGuard(ctx context.Context) error {- userLimit := s.licenseService.GetPlanLimitValue(ctx, enterpriseAPI.PlanLimitMaximumUser)+ userLimit := s.licenseService.GetPlanLimitValue(ctx, enterprise.PlanLimitMaximumUser)count, err := s.store.CountActiveUsers(ctx)if err != nil {diff --git a/backend/api/v1/database_service.go b/backend/api/v1/database_service.goindex 8d6c34ad65..1115e00d88 100644--- a/backend/api/v1/database_service.go+++ b/backend/api/v1/database_service.go@@ -29,7 +29,7 @@ import ("github.com/bytebase/bytebase/backend/common""github.com/bytebase/bytebase/backend/common/log""github.com/bytebase/bytebase/backend/component/config"- enterpriseAPI "github.com/bytebase/bytebase/backend/enterprise/api"+ enterprise "github.com/bytebase/bytebase/backend/enterprise/api"api "github.com/bytebase/bytebase/backend/legacyapi""github.com/bytebase/bytebase/backend/plugin/db""github.com/bytebase/bytebase/backend/plugin/parser/base"@@ -66,12 +66,12 @@ type DatabaseService struct {store *store.StorebackupRunner *backuprun.RunnerschemaSyncer *schemasync.Syncer- licenseService enterpriseAPI.LicenseService+ licenseService enterprise.LicenseServiceprofile *config.Profile}// NewDatabaseService creates a new DatabaseService.-func NewDatabaseService(store *store.Store, br *backuprun.Runner, schemaSyncer *schemasync.Syncer, licenseService enterpriseAPI.LicenseService, profile *config.Profile) *DatabaseService {+func NewDatabaseService(store *store.Store, br *backuprun.Runner, schemaSyncer *schemasync.Syncer, licenseService enterprise.LicenseService, profile *config.Profile) *DatabaseService {return &DatabaseService{store: store,backupRunner: br,@@ -1539,7 +1539,10 @@ func (s *DatabaseService) DeleteSecret(ctx context.Context, request *v1pb.Delete}func (s *DatabaseService) checkDatabasePermission(ctx context.Context, projectID string, permission api.ProjectPermissionType) error {- role := ctx.Value(common.RoleContextKey).(api.Role)+ role, ok := ctx.Value(common.RoleContextKey).(api.Role)+ if !ok {+ return status.Errorf(codes.Internal, "role not found")+ }if isOwnerOrDBA(role) {return nil}diff --git a/backend/api/v1/debug_interceptor.go b/backend/api/v1/debug_interceptor.goindex eac0260c2b..04d12f4e6b 100644--- a/backend/api/v1/debug_interceptor.go+++ b/backend/api/v1/debug_interceptor.go@@ -17,7 +17,7 @@ import ("github.com/bytebase/bytebase/backend/component/config"api "github.com/bytebase/bytebase/backend/legacyapi""github.com/bytebase/bytebase/backend/metric"- metricPlugin "github.com/bytebase/bytebase/backend/plugin/metric"+ metricplugin "github.com/bytebase/bytebase/backend/plugin/metric""github.com/bytebase/bytebase/backend/runner/metricreport"v1pb "github.com/bytebase/bytebase/proto/generated-go/v1")@@ -106,7 +106,7 @@ func (in *DebugInterceptor) debugInterceptorDo(ctx context.Context, fullMethod s// Only update for authorized request.in.profile.LastActiveTs = time.Now().Unix()}- in.metricReporter.Report(ctx, &metricPlugin.Metric{+ in.metricReporter.Report(ctx, &metricplugin.Metric{Name: metric.APIRequestMetricName,Value: 1,Labels: map[string]any{diff --git a/backend/api/v1/environment_service.go b/backend/api/v1/environment_service.goindex 374662f7ee..f37b50eead 100644--- a/backend/api/v1/environment_service.go+++ b/backend/api/v1/environment_service.go@@ -9,7 +9,7 @@ import ("google.golang.org/protobuf/types/known/emptypb""github.com/bytebase/bytebase/backend/common"- enterpriseAPI "github.com/bytebase/bytebase/backend/enterprise/api"+ enterprise "github.com/bytebase/bytebase/backend/enterprise/api"api "github.com/bytebase/bytebase/backend/legacyapi""github.com/bytebase/bytebase/backend/store"v1pb "github.com/bytebase/bytebase/proto/generated-go/v1"@@ -19,11 +19,11 @@ import (type EnvironmentService struct {v1pb.UnimplementedEnvironmentServiceServerstore *store.Store- licenseService enterpriseAPI.LicenseService+ licenseService enterprise.LicenseService}// NewEnvironmentService creates a new EnvironmentService.-func NewEnvironmentService(store *store.Store, licenseService enterpriseAPI.LicenseService) *EnvironmentService {+func NewEnvironmentService(store *store.Store, licenseService enterprise.LicenseService) *EnvironmentService {return &EnvironmentService{store: store,licenseService: licenseService,@@ -74,7 +74,7 @@ func (s *EnvironmentService) CreateEnvironment(ctx context.Context, request *v1pif err != nil {return nil, status.Errorf(codes.Internal, err.Error())}- maximumEnvironmentLimit := s.licenseService.GetPlanLimitValue(ctx, enterpriseAPI.PlanLimitMaximumEnvironment)+ maximumEnvironmentLimit := s.licenseService.GetPlanLimitValue(ctx, enterprise.PlanLimitMaximumEnvironment)if int64(len(environments)) >= maximumEnvironmentLimit {return nil, status.Errorf(codes.ResourceExhausted, "current plan can create up to %d environments.", maximumEnvironmentLimit)}diff --git a/backend/api/v1/idp_service.go b/backend/api/v1/idp_service.goindex 2df1657bba..e3a9b05f2f 100644--- a/backend/api/v1/idp_service.go+++ b/backend/api/v1/idp_service.go@@ -11,7 +11,7 @@ import ("google.golang.org/protobuf/types/known/emptypb""github.com/bytebase/bytebase/backend/common"- enterpriseAPI "github.com/bytebase/bytebase/backend/enterprise/api"+ enterprise "github.com/bytebase/bytebase/backend/enterprise/api""github.com/bytebase/bytebase/backend/plugin/idp/ldap""github.com/bytebase/bytebase/backend/plugin/idp/oauth2""github.com/bytebase/bytebase/backend/plugin/idp/oidc"@@ -24,11 +24,11 @@ import (type IdentityProviderService struct {v1pb.UnimplementedIdentityProviderServiceServerstore *store.Store- licenseService enterpriseAPI.LicenseService+ licenseService enterprise.LicenseService}// NewIdentityProviderService creates a new IdentityProviderService.-func NewIdentityProviderService(store *store.Store, licenseService enterpriseAPI.LicenseService) *IdentityProviderService {+func NewIdentityProviderService(store *store.Store, licenseService enterprise.LicenseService) *IdentityProviderService {return &IdentityProviderService{store: store,licenseService: licenseService,@@ -486,9 +486,8 @@ func convertIdentityProviderConfigToStore(identityProviderConfig *v1pb.IdentityP},},}- } else {- return nil}+ return nil}// validIdentityProviderConfig validates the identity provider's config is a valid JSON.@@ -505,8 +504,6 @@ func validIdentityProviderConfig(identityProviderType v1pb.IdentityProviderType,if identityProviderConfig.GetLdapConfig() == nil {return errors.Errorf("unexpected provider config value")}- } else {- return errors.Errorf("unexpected provider type %s", identityProviderType)}- return nil+ return errors.Errorf("unexpected provider type %s", identityProviderType)}diff --git a/backend/api/v1/instance_service.go b/backend/api/v1/instance_service.goindex de490f920b..4cbecd7d2b 100644--- a/backend/api/v1/instance_service.go+++ b/backend/api/v1/instance_service.go@@ -17,7 +17,7 @@ import ("github.com/bytebase/bytebase/backend/component/dbfactory""github.com/bytebase/bytebase/backend/component/secret""github.com/bytebase/bytebase/backend/component/state"- enterpriseAPI "github.com/bytebase/bytebase/backend/enterprise/api"+ enterprise "github.com/bytebase/bytebase/backend/enterprise/api"api "github.com/bytebase/bytebase/backend/legacyapi"metricAPI "github.com/bytebase/bytebase/backend/metric""github.com/bytebase/bytebase/backend/plugin/metric"@@ -33,7 +33,7 @@ import (type InstanceService struct {v1pb.UnimplementedInstanceServiceServerstore *store.Store- licenseService enterpriseAPI.LicenseService+ licenseService enterprise.LicenseServicemetricReporter *metricreport.Reportersecret stringstateCfg *state.State@@ -42,7 +42,7 @@ type InstanceService struct {}// NewInstanceService creates a new InstanceService.-func NewInstanceService(store *store.Store, licenseService enterpriseAPI.LicenseService, metricReporter *metricreport.Reporter, secret string, stateCfg *state.State, dbFactory *dbfactory.DBFactory, schemaSyncer *schemasync.Syncer) *InstanceService {+func NewInstanceService(store *store.Store, licenseService enterprise.LicenseService, metricReporter *metricreport.Reporter, secret string, stateCfg *state.State, dbFactory *dbfactory.DBFactory, schemaSyncer *schemasync.Syncer) *InstanceService {return &InstanceService{store: store,licenseService: licenseService,@@ -992,7 +992,7 @@ func (s *InstanceService) convertToDataSourceMessage(dataSource *v1pb.DataSource}func (s *InstanceService) instanceCountGuard(ctx context.Context) error {- instanceLimit := s.licenseService.GetPlanLimitValue(ctx, enterpriseAPI.PlanLimitMaximumInstance)+ instanceLimit := s.licenseService.GetPlanLimitValue(ctx, enterprise.PlanLimitMaximumInstance)count, err := s.store.CountInstance(ctx, &store.CountInstanceMessage{})if err != nil {diff --git a/backend/api/v1/issue_service.go b/backend/api/v1/issue_service.goindex 15cd87a6f4..865b383554 100644--- a/backend/api/v1/issue_service.go+++ b/backend/api/v1/issue_service.go@@ -21,7 +21,7 @@ import ("github.com/bytebase/bytebase/backend/common/log""github.com/bytebase/bytebase/backend/component/activity""github.com/bytebase/bytebase/backend/component/state"- enterpriseAPI "github.com/bytebase/bytebase/backend/enterprise/api"+ enterprise "github.com/bytebase/bytebase/backend/enterprise/api"api "github.com/bytebase/bytebase/backend/legacyapi"metricAPI "github.com/bytebase/bytebase/backend/metric""github.com/bytebase/bytebase/backend/plugin/metric"@@ -40,7 +40,7 @@ type IssueService struct {activityManager *activity.ManagerrelayRunner *relay.RunnerstateCfg *state.State- licenseService enterpriseAPI.LicenseService+ licenseService enterprise.LicenseServicemetricReporter *metricreport.Reporter}@@ -50,7 +50,7 @@ func NewIssueService(activityManager *activity.Manager,relayRunner *relay.Runner,stateCfg *state.State,- licenseService enterpriseAPI.LicenseService,+ licenseService enterprise.LicenseService,metricReporter *metricreport.Reporter,) *IssueService {return &IssueService{@@ -1886,7 +1886,10 @@ func getProjectIDsFilter(ctx context.Context, s *store.Store, requestProjectID sif !ok {return nil, status.Errorf(codes.Internal, "principal ID not found")}- role := ctx.Value(common.RoleContextKey).(api.Role)+ role, ok := ctx.Value(common.RoleContextKey).(api.Role)+ if !ok {+ return nil, status.Errorf(codes.Internal, "role not found")+ }if isOwnerOrDBA(role) {if requestProjectID == "-" {diff --git a/backend/api/v1/masking_evaluator_test.go b/backend/api/v1/masking_evaluator_test.goindex 1bfc56ed3b..154bbd4d82 100644--- a/backend/api/v1/masking_evaluator_test.go+++ b/backend/api/v1/masking_evaluator_test.go@@ -4,7 +4,7 @@ import ("testing""github.com/stretchr/testify/require"- expr "google.golang.org/genproto/googleapis/type/expr"+ "google.golang.org/genproto/googleapis/type/expr""github.com/bytebase/bytebase/backend/store"diff --git a/backend/api/v1/org_policy_service.go b/backend/api/v1/org_policy_service.goindex 7c28376835..8b6df7b2e7 100644--- a/backend/api/v1/org_policy_service.go+++ b/backend/api/v1/org_policy_service.go@@ -8,7 +8,7 @@ import ("github.com/google/cel-go/cel""github.com/pkg/errors"- expr "google.golang.org/genproto/googleapis/type/expr"+ "google.golang.org/genproto/googleapis/type/expr""google.golang.org/grpc/codes""google.golang.org/grpc/status""google.golang.org/protobuf/encoding/protojson"@@ -17,7 +17,7 @@ import ("github.com/bytebase/bytebase/backend/common""github.com/bytebase/bytebase/backend/common/log"- enterpriseAPI "github.com/bytebase/bytebase/backend/enterprise/api"+ enterprise "github.com/bytebase/bytebase/backend/enterprise/api"api "github.com/bytebase/bytebase/backend/legacyapi""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/store"@@ -32,11 +32,11 @@ var defaultWorkspaceResourceID = 1type OrgPolicyService struct {v1pb.UnimplementedOrgPolicyServiceServerstore *store.Store- licenseService enterpriseAPI.LicenseService+ licenseService enterprise.LicenseService}// NewOrgPolicyService creates a new OrgPolicyService.-func NewOrgPolicyService(store *store.Store, licenseService enterpriseAPI.LicenseService) *OrgPolicyService {+func NewOrgPolicyService(store *store.Store, licenseService enterprise.LicenseService) *OrgPolicyService {return &OrgPolicyService{store: store,licenseService: licenseService,diff --git a/backend/api/v1/project_service.go b/backend/api/v1/project_service.goindex 460f1499f0..d45cc1cd7c 100644--- a/backend/api/v1/project_service.go+++ b/backend/api/v1/project_service.go@@ -22,14 +22,14 @@ import ("github.com/bytebase/bytebase/backend/common""github.com/bytebase/bytebase/backend/common/log""github.com/bytebase/bytebase/backend/component/activity"- enterpriseAPI "github.com/bytebase/bytebase/backend/enterprise/api"+ enterprise "github.com/bytebase/bytebase/backend/enterprise/api"api "github.com/bytebase/bytebase/backend/legacyapi"- vcsPlugin "github.com/bytebase/bytebase/backend/plugin/vcs"+ vcsplugin "github.com/bytebase/bytebase/backend/plugin/vcs""github.com/bytebase/bytebase/backend/plugin/vcs/azure""github.com/bytebase/bytebase/backend/plugin/vcs/bitbucket""github.com/bytebase/bytebase/backend/plugin/vcs/github""github.com/bytebase/bytebase/backend/plugin/vcs/gitlab"- webhookPlugin "github.com/bytebase/bytebase/backend/plugin/webhook"+ webhookplugin "github.com/bytebase/bytebase/backend/plugin/webhook""github.com/bytebase/bytebase/backend/store""github.com/bytebase/bytebase/backend/utils"storepb "github.com/bytebase/bytebase/proto/generated-go/store"@@ -46,11 +46,11 @@ type ProjectService struct {v1pb.UnimplementedProjectServiceServerstore *store.StoreactivityManager *activity.Manager- licenseService enterpriseAPI.LicenseService+ licenseService enterprise.LicenseService}// NewProjectService creates a new ProjectService.-func NewProjectService(store *store.Store, activityManager *activity.Manager, licenseService enterpriseAPI.LicenseService) *ProjectService {+func NewProjectService(store *store.Store, activityManager *activity.Manager, licenseService enterprise.LicenseService) *ProjectService {return &ProjectService{store: store,activityManager: activityManager,@@ -272,7 +272,10 @@ func (s *ProjectService) SearchProjects(ctx context.Context, _ *v1pb.SearchProjeif !ok {return nil, status.Errorf(codes.Internal, "principal ID not found")}- role := ctx.Value(common.RoleContextKey).(api.Role)+ role, ok := ctx.Value(common.RoleContextKey).(api.Role)+ if !ok {+ return nil, status.Errorf(codes.Internal, "role not found")+ }projects, err := s.store.ListProjectV2(ctx, &store.FindProjectMessage{})if err != nil {@@ -477,7 +480,7 @@ func (s *ProjectService) UpdateProjectGitOpsInfo(ctx context.Context, request *v}baseDir := request.ProjectGitopsInfo.BaseDirectory// Azure DevOps base directory should start with /.- if storeVCS.Type == vcsPlugin.AzureDevOps {+ if storeVCS.Type == vcsplugin.AzureDevOps {if !strings.HasPrefix(baseDir, "/") {baseDir = "/" + request.ProjectGitopsInfo.BaseDirectory}@@ -547,7 +550,7 @@ func (s *ProjectService) UpdateProjectGitOpsInfo(ctx context.Context, request *vnewFilePathTemplate = *patch.FilePathTemplate}- if err := vcsPlugin.IsAsterisksInTemplateValid(path.Join(newBaseDirectory, newFilePathTemplate)); err != nil {+ if err := vcsplugin.IsAsterisksInTemplateValid(path.Join(newBaseDirectory, newFilePathTemplate)); err != nil {return nil, status.Errorf(codes.InvalidArgument, "invalid base directory and filepath template combination: %v", err.Error())}@@ -653,7 +656,7 @@ func (s *ProjectService) UnsetProjectGitOpsInfo(ctx context.Context, request *v1// Delete the webhook after we successfully delete the repository.// This is because in case the webhook deletion fails, we can still have a cleanup process to cleanup the orphaned webhook.// If we delete it before we delete the repository, then if the repository deletion fails, we will have a broken repository with no webhook.- if err = vcsPlugin.Get(vcs.Type, vcsPlugin.ProviderConfig{}).DeleteWebhook(+ if err = vcsplugin.Get(vcs.Type, vcsplugin.ProviderConfig{}).DeleteWebhook(ctx,// Need to get ApplicationID, Secret from vcs instead of repository.vcs since the latter is not composed.common.OauthContext{@@ -979,11 +982,11 @@ func (s *ProjectService) TestWebhook(ctx context.Context, request *v1pb.TestWebh}resp := &v1pb.TestWebhookResponse{}- err = webhookPlugin.Post(+ err = webhookplugin.Post(webhook.Type,- webhookPlugin.Context{+ webhookplugin.Context{URL: webhook.URL,- Level: webhookPlugin.WebhookInfo,+ Level: webhookplugin.WebhookInfo,ActivityType: string(api.ActivityIssueCreate),Title: fmt.Sprintf("Test webhook %q", webhook.Title),Description: "This is a test",@@ -992,7 +995,7 @@ func (s *ProjectService) TestWebhook(ctx context.Context, request *v1pb.TestWebhCreatorName: "Bytebase",CreatorEmail: api.SystemBotEmail,CreatedTs: time.Now().Unix(),- Project: &webhookPlugin.Project{Name: project.Title},+ Project: &webhookplugin.Project{Name: project.Title},},)if err != nil {@@ -1047,7 +1050,7 @@ func (s *ProjectService) createProjectGitOpsInfo(ctx context.Context, request *vbaseDir := request.ProjectGitopsInfo.BaseDirectory// Azure DevOps base directory should start with /.- if storeVCS.Type == vcsPlugin.AzureDevOps {+ if storeVCS.Type == vcsplugin.AzureDevOps {if !strings.HasPrefix(baseDir, "/") {baseDir = "/" + request.ProjectGitopsInfo.BaseDirectory}@@ -1086,7 +1089,7 @@ func (s *ProjectService) createProjectGitOpsInfo(ctx context.Context, request *v// We need to check the FilePathTemplate in create repository request.// This avoids to a certain extent that the creation succeeds but does not work.- if err := vcsPlugin.IsAsterisksInTemplateValid(path.Join(repositoryCreate.BaseDirectory, repositoryCreate.FilePathTemplate)); err != nil {+ if err := vcsplugin.IsAsterisksInTemplateValid(path.Join(repositoryCreate.BaseDirectory, repositoryCreate.FilePathTemplate)); err != nil {return nil, status.Errorf(codes.InvalidArgument, "invalid base directory and filepath template combination: %v", err.Error())}@@ -1180,7 +1183,7 @@ func (s *ProjectService) createProjectGitOpsInfo(ctx context.Context, request *vreturn convertToProjectGitOpsInfo(repository), nil}-func (s *ProjectService) setupVCSSQLReviewCI(ctx context.Context, repository *store.RepositoryMessage, vcs *store.ExternalVersionControlMessage) (*vcsPlugin.PullRequest, error) {+func (s *ProjectService) setupVCSSQLReviewCI(ctx context.Context, repository *store.RepositoryMessage, vcs *store.ExternalVersionControlMessage) (*vcsplugin.PullRequest, error) {setting, err := s.store.GetWorkspaceGeneralSetting(ctx)if err != nil {return nil, err@@ -1195,7 +1198,7 @@ func (s *ProjectService) setupVCSSQLReviewCI(ctx context.Context, repository *streturn nil, err}- if err := vcsPlugin.Get(vcs.Type, vcsPlugin.ProviderConfig{}).UpsertEnvironmentVariable(+ if err := vcsplugin.Get(vcs.Type, vcsplugin.ProviderConfig{}).UpsertEnvironmentVariable(ctx,common.OauthContext{ClientID: vcs.ApplicationID,@@ -1207,7 +1210,7 @@ func (s *ProjectService) setupVCSSQLReviewCI(ctx context.Context, repository *st},vcs.InstanceURL,repository.ExternalID,- vcsPlugin.SQLReviewAPISecretName,+ vcsplugin.SQLReviewAPISecretName,repository.WebhookSecretToken,); err != nil {return nil, err@@ -1220,21 +1223,21 @@ func (s *ProjectService) setupVCSSQLReviewCI(ctx context.Context, repository *stsqlReviewEndpoint := fmt.Sprintf("%s/hook/sql-review/%s", endpoint, repository.WebhookEndpointID)switch vcs.Type {- case vcsPlugin.GitHub:+ case vcsplugin.GitHub:if err := s.setupVCSSQLReviewCIForGitHub(ctx, repository, vcs, branch, sqlReviewEndpoint); err != nil {return nil, err}- case vcsPlugin.GitLab:+ case vcsplugin.GitLab:if err := s.setupVCSSQLReviewCIForGitLab(ctx, repository, vcs, branch, sqlReviewEndpoint); err != nil {return nil, err}- case vcsPlugin.AzureDevOps:+ case vcsplugin.AzureDevOps:if err := s.setupVCSSQLReviewCIForAzureDevOps(ctx, repository, vcs, branch, sqlReviewEndpoint); err != nil {return nil, err}}- return vcsPlugin.Get(vcs.Type, vcsPlugin.ProviderConfig{}).CreatePullRequest(+ return vcsplugin.Get(vcs.Type, vcsplugin.ProviderConfig{}).CreatePullRequest(ctx,common.OauthContext{ClientID: vcs.ApplicationID,@@ -1246,7 +1249,7 @@ func (s *ProjectService) setupVCSSQLReviewCI(ctx context.Context, repository *st},vcs.InstanceURL,repository.ExternalID,- &vcsPlugin.PullRequestCreate{+ &vcsplugin.PullRequestCreate{Title: sqlReviewInVCSPRTitle,Body: "This pull request is auto-generated by Bytebase for GitOps workflow.",Head: branch.Name,@@ -1257,7 +1260,7 @@ func (s *ProjectService) setupVCSSQLReviewCI(ctx context.Context, repository *st}// setupVCSSQLReviewBranch will create a new branch to setup SQL review CI.-func (s *ProjectService) setupVCSSQLReviewBranch(ctx context.Context, repository *store.RepositoryMessage, vcs *store.ExternalVersionControlMessage) (*vcsPlugin.BranchInfo, error) {+func (s *ProjectService) setupVCSSQLReviewBranch(ctx context.Context, repository *store.RepositoryMessage, vcs *store.ExternalVersionControlMessage) (*vcsplugin.BranchInfo, error) {setting, err := s.store.GetWorkspaceGeneralSetting(ctx)if err != nil {return nil, status.Errorf(codes.Internal, "failed to find workspace setting with error: %v", err.Error())@@ -1265,7 +1268,7 @@ func (s *ProjectService) setupVCSSQLReviewBranch(ctx context.Context, repositoryif setting.ExternalUrl == "" {return nil, status.Errorf(codes.FailedPrecondition, "external url is required")}- branch, err := vcsPlugin.Get(vcs.Type, vcsPlugin.ProviderConfig{}).GetBranch(+ branch, err := vcsplugin.Get(vcs.Type, vcsplugin.ProviderConfig{}).GetBranch(ctx,common.OauthContext{ClientID: vcs.ApplicationID,@@ -1284,11 +1287,11 @@ func (s *ProjectService) setupVCSSQLReviewBranch(ctx context.Context, repository}slog.Debug("VCS target branch info", slog.String("last_commit", branch.LastCommitID), slog.String("name", branch.Name))- branchCreate := &vcsPlugin.BranchInfo{+ branchCreate := &vcsplugin.BranchInfo{Name: fmt.Sprintf("bytebase-vcs-%d", time.Now().Unix()),LastCommitID: branch.LastCommitID,}- if err := vcsPlugin.Get(vcs.Type, vcsPlugin.ProviderConfig{}).CreateBranch(+ if err := vcsplugin.Get(vcs.Type, vcsplugin.ProviderConfig{}).CreateBranch(ctx,common.OauthContext{ClientID: vcs.ApplicationID,@@ -1313,7 +1316,7 @@ func (s *ProjectService) setupVCSSQLReviewCIForGitHub(ctx context.Context,repository *store.RepositoryMessage,vcs *store.ExternalVersionControlMessage,- branch *vcsPlugin.BranchInfo,+ branch *vcsplugin.BranchInfo,sqlReviewEndpoint string,) error {sqlReviewConfig := github.SetupSQLReviewCI(sqlReviewEndpoint)@@ -1328,7 +1331,7 @@ func (s *ProjectService) setupVCSSQLReviewCIForGitHub(return status.Errorf(codes.FailedPrecondition, "external url is required")}- fileMeta, err := vcsPlugin.Get(vcs.Type, vcsPlugin.ProviderConfig{}).ReadFileMeta(+ fileMeta, err := vcsplugin.Get(vcs.Type, vcsplugin.ProviderConfig{}).ReadFileMeta(ctx,common.OauthContext{ClientID: vcs.ApplicationID,@@ -1341,8 +1344,8 @@ func (s *ProjectService) setupVCSSQLReviewCIForGitHub(vcs.InstanceURL,repository.ExternalID,github.SQLReviewActionFilePath,- vcsPlugin.RefInfo{- RefType: vcsPlugin.RefTypeBranch,+ vcsplugin.RefInfo{+ RefType: vcsplugin.RefTypeBranch,RefName: branch.Name,},)@@ -1359,7 +1362,7 @@ func (s *ProjectService) setupVCSSQLReviewCIForGitHub(fileSHA = fileMeta.SHA}- return vcsPlugin.Get(vcs.Type, vcsPlugin.ProviderConfig{}).CreateFile(+ return vcsplugin.Get(vcs.Type, vcsplugin.ProviderConfig{}).CreateFile(ctx,common.OauthContext{ClientID: vcs.ApplicationID,@@ -1372,7 +1375,7 @@ func (s *ProjectService) setupVCSSQLReviewCIForGitHub(vcs.InstanceURL,repository.ExternalID,github.SQLReviewActionFilePath,- vcsPlugin.FileCommitCreate{+ vcsplugin.FileCommitCreate{Branch: branch.Name,CommitMessage: sqlReviewInVCSPRTitle,Content: sqlReviewConfig,@@ -1387,7 +1390,7 @@ func (s *ProjectService) setupVCSSQLReviewCIForGitLab(ctx context.Context,repository *store.RepositoryMessage,vcs *store.ExternalVersionControlMessage,- branch *vcsPlugin.BranchInfo,+ branch *vcsplugin.BranchInfo,sqlReviewEndpoint string,) error {setting, err := s.store.GetWorkspaceGeneralSetting(ctx)@@ -1398,11 +1401,11 @@ func (s *ProjectService) setupVCSSQLReviewCIForGitLab(return status.Errorf(codes.FailedPrecondition, "external url is required")}// create or update the .gitlab-ci.yml- if err := s.createOrUpdateVCSSQLReviewFileForGitLab(ctx, repository, vcs, branch, gitlab.CIFilePath, func(fileMeta *vcsPlugin.FileMeta) (string, error) {+ if err := s.createOrUpdateVCSSQLReviewFileForGitLab(ctx, repository, vcs, branch, gitlab.CIFilePath, func(fileMeta *vcsplugin.FileMeta) (string, error) {content := make(map[string]any)if fileMeta != nil {- ciFileContent, err := vcsPlugin.Get(vcs.Type, vcsPlugin.ProviderConfig{}).ReadFileContent(+ ciFileContent, err := vcsplugin.Get(vcs.Type, vcsplugin.ProviderConfig{}).ReadFileContent(ctx,common.OauthContext{ClientID: vcs.ApplicationID,@@ -1415,8 +1418,8 @@ func (s *ProjectService) setupVCSSQLReviewCIForGitLab(vcs.InstanceURL,repository.ExternalID,gitlab.CIFilePath,- vcsPlugin.RefInfo{- RefType: vcsPlugin.RefTypeCommit,+ vcsplugin.RefInfo{+ RefType: vcsplugin.RefTypeCommit,RefName: fileMeta.LastCommitID,},)@@ -1439,7 +1442,7 @@ func (s *ProjectService) setupVCSSQLReviewCIForGitLab(}// create or update the SQL review CI.- return s.createOrUpdateVCSSQLReviewFileForGitLab(ctx, repository, vcs, branch, gitlab.SQLReviewCIFilePath, func(_ *vcsPlugin.FileMeta) (string, error) {+ return s.createOrUpdateVCSSQLReviewFileForGitLab(ctx, repository, vcs, branch, gitlab.SQLReviewCIFilePath, func(_ *vcsplugin.FileMeta) (string, error) {return gitlab.SetupSQLReviewCI(sqlReviewEndpoint), nil})}@@ -1449,7 +1452,7 @@ func (s *ProjectService) setupVCSSQLReviewCIForAzureDevOps(ctx context.Context,repository *store.RepositoryMessage,vcs *store.ExternalVersionControlMessage,- branch *vcsPlugin.BranchInfo,+ branch *vcsplugin.BranchInfo,sqlReviewEndpoint string,) error {sqlReviewConfig := azure.SetupSQLReviewCI(sqlReviewEndpoint, repository.BranchFilter)@@ -1464,7 +1467,7 @@ func (s *ProjectService) setupVCSSQLReviewCIForAzureDevOps(return status.Errorf(codes.FailedPrecondition, "external url is required")}- fileMeta, err := vcsPlugin.Get(vcs.Type, vcsPlugin.ProviderConfig{}).ReadFileMeta(+ fileMeta, err := vcsplugin.Get(vcs.Type, vcsplugin.ProviderConfig{}).ReadFileMeta(ctx,common.OauthContext{ClientID: vcs.ApplicationID,@@ -1477,8 +1480,8 @@ func (s *ProjectService) setupVCSSQLReviewCIForAzureDevOps(vcs.InstanceURL,repository.ExternalID,azure.SQLReviewPipelineFilePath,- vcsPlugin.RefInfo{- RefType: vcsPlugin.RefTypeBranch,+ vcsplugin.RefInfo{+ RefType: vcsplugin.RefTypeBranch,RefName: branch.Name,},)@@ -1495,7 +1498,7 @@ func (s *ProjectService) setupVCSSQLReviewCIForAzureDevOps(fileSHA = fileMeta.SHA}- return vcsPlugin.Get(vcs.Type, vcsPlugin.ProviderConfig{}).OverwriteFile(+ return vcsplugin.Get(vcs.Type, vcsplugin.ProviderConfig{}).OverwriteFile(ctx,common.OauthContext{ClientID: vcs.ApplicationID,@@ -1508,7 +1511,7 @@ func (s *ProjectService) setupVCSSQLReviewCIForAzureDevOps(vcs.InstanceURL,repository.ExternalID,azure.SQLReviewPipelineFilePath,- vcsPlugin.FileCommitCreate{+ vcsplugin.FileCommitCreate{Branch: branch.Name,CommitMessage: sqlReviewInVCSPRTitle,Content: sqlReviewConfig,@@ -1523,9 +1526,9 @@ func (s *ProjectService) createOrUpdateVCSSQLReviewFileForGitLab(ctx context.Context,repository *store.RepositoryMessage,vcs *store.ExternalVersionControlMessage,- branch *vcsPlugin.BranchInfo,+ branch *vcsplugin.BranchInfo,fileName string,- getNewContent func(meta *vcsPlugin.FileMeta) (string, error),+ getNewContent func(meta *vcsplugin.FileMeta) (string, error),) error {setting, err := s.store.GetWorkspaceGeneralSetting(ctx)if err != nil {@@ -1535,7 +1538,7 @@ func (s *ProjectService) createOrUpdateVCSSQLReviewFileForGitLab(return status.Errorf(codes.FailedPrecondition, "external url is required")}fileExisted := true- fileMeta, err := vcsPlugin.Get(vcs.Type, vcsPlugin.ProviderConfig{}).ReadFileMeta(+ fileMeta, err := vcsplugin.Get(vcs.Type, vcsplugin.ProviderConfig{}).ReadFileMeta(ctx,common.OauthContext{ClientID: vcs.ApplicationID,@@ -1548,8 +1551,8 @@ func (s *ProjectService) createOrUpdateVCSSQLReviewFileForGitLab(vcs.InstanceURL,repository.ExternalID,fileName,- vcsPlugin.RefInfo{- RefType: vcsPlugin.RefTypeBranch,+ vcsplugin.RefInfo{+ RefType: vcsplugin.RefTypeBranch,RefName: branch.Name,},)@@ -1573,7 +1576,7 @@ func (s *ProjectService) createOrUpdateVCSSQLReviewFileForGitLab(}if fileExisted {- return vcsPlugin.Get(vcs.Type, vcsPlugin.ProviderConfig{}).OverwriteFile(+ return vcsplugin.Get(vcs.Type, vcsplugin.ProviderConfig{}).OverwriteFile(ctx,common.OauthContext{ClientID: vcs.ApplicationID,@@ -1586,7 +1589,7 @@ func (s *ProjectService) createOrUpdateVCSSQLReviewFileForGitLab(vcs.InstanceURL,repository.ExternalID,fileName,- vcsPlugin.FileCommitCreate{+ vcsplugin.FileCommitCreate{Branch: branch.Name,CommitMessage: sqlReviewInVCSPRTitle,Content: newContent,@@ -1596,7 +1599,7 @@ func (s *ProjectService) createOrUpdateVCSSQLReviewFileForGitLab()}- return vcsPlugin.Get(vcs.Type, vcsPlugin.ProviderConfig{}).CreateFile(+ return vcsplugin.Get(vcs.Type, vcsplugin.ProviderConfig{}).CreateFile(ctx,common.OauthContext{ClientID: vcs.ApplicationID,@@ -1609,7 +1612,7 @@ func (s *ProjectService) createOrUpdateVCSSQLReviewFileForGitLab(vcs.InstanceURL,repository.ExternalID,fileName,- vcsPlugin.FileCommitCreate{+ vcsplugin.FileCommitCreate{Branch: branch.Name,CommitMessage: sqlReviewInVCSPRTitle,Content: newContent,@@ -3050,7 +3053,7 @@ func isBranchNotFound(store *store.Store,webURL, accessToken, refreshToken, externalID, branch, externalURL string,) (bool, error) {- _, err := vcsPlugin.Get(vcs.Type, vcsPlugin.ProviderConfig{}).GetBranch(ctx,+ _, err := vcsplugin.Get(vcs.Type, vcsplugin.ProviderConfig{}).GetBranch(ctx,common.OauthContext{ClientID: vcs.ApplicationID,ClientSecret: vcs.Secret,@@ -3067,12 +3070,12 @@ func isBranchNotFound(return false, err}-func createVCSWebhook(ctx context.Context, vcsType vcsPlugin.Type, webhookEndpointID, secretToken, accessToken, instanceURL, externalRepoID, gitopsWebhookURL string) (string, error) {+func createVCSWebhook(ctx context.Context, vcsType vcsplugin.Type, webhookEndpointID, secretToken, accessToken, instanceURL, externalRepoID, gitopsWebhookURL string) (string, error) {// Create a new webhook and retrieve the created webhook IDvar webhookCreatePayload []bytevar err errorswitch vcsType {- case vcsPlugin.GitLab:+ case vcsplugin.GitLab:webhookCreate := gitlab.WebhookCreate{URL: fmt.Sprintf("%s/hook/gitlab/%s", gitopsWebhookURL, webhookEndpointID),SecretToken: secretToken,@@ -3083,7 +3086,7 @@ func createVCSWebhook(ctx context.Context, vcsType vcsPlugin.Type, webhookEndpoiif err != nil {return "", errors.Wrap(err, "failed to marshal request body for creating webhook")}- case vcsPlugin.GitHub:+ case vcsplugin.GitHub:webhookPost := github.WebhookCreateOrUpdate{Config: github.WebhookConfig{URL: fmt.Sprintf("%s/hook/github/%s", gitopsWebhookURL, webhookEndpointID),@@ -3097,7 +3100,7 @@ func createVCSWebhook(ctx context.Context, vcsType vcsPlugin.Type, webhookEndpoiif err != nil {return "", errors.Wrap(err, "failed to marshal request body for creating webhook")}- case vcsPlugin.Bitbucket:+ case vcsplugin.Bitbucket:webhookPost := bitbucket.WebhookCreateOrUpdate{Description: "Bytebase GitOps",URL: fmt.Sprintf("%s/hook/bitbucket/%s", gitopsWebhookURL, webhookEndpointID),@@ -3108,7 +3111,7 @@ func createVCSWebhook(ctx context.Context, vcsType vcsPlugin.Type, webhookEndpoiif err != nil {return "", errors.Wrap(err, "failed to marshal request body for creating webhook")}- case vcsPlugin.AzureDevOps:+ case vcsplugin.AzureDevOps:part := strings.Split(externalRepoID, "/")if len(part) != 3 {return "", errors.Errorf("invalid external repo id %q", externalRepoID)@@ -3136,7 +3139,7 @@ func createVCSWebhook(ctx context.Context, vcsType vcsPlugin.Type, webhookEndpoireturn "", errors.Wrap(err, "failed to marshal request body for creating webhook")}}- webhookID, err := vcsPlugin.Get(vcsType, vcsPlugin.ProviderConfig{}).CreateWebhook(+ webhookID, err := vcsplugin.Get(vcsType, vcsplugin.ProviderConfig{}).CreateWebhook(ctx,common.OauthContext{AccessToken: accessToken,diff --git a/backend/api/v1/risk_service.go b/backend/api/v1/risk_service.goindex 47bce4e40e..ee8327761c 100644--- a/backend/api/v1/risk_service.go+++ b/backend/api/v1/risk_service.go@@ -9,7 +9,7 @@ import ("google.golang.org/protobuf/types/known/emptypb""github.com/bytebase/bytebase/backend/common"- enterpriseAPI "github.com/bytebase/bytebase/backend/enterprise/api"+ enterprise "github.com/bytebase/bytebase/backend/enterprise/api"api "github.com/bytebase/bytebase/backend/legacyapi""github.com/bytebase/bytebase/backend/store"v1pb "github.com/bytebase/bytebase/proto/generated-go/v1"@@ -19,11 +19,11 @@ import (type RiskService struct {v1pb.UnimplementedRiskServiceServerstore *store.Store- licenseService enterpriseAPI.LicenseService+ licenseService enterprise.LicenseService}// NewRiskService creates a new RiskService.-func NewRiskService(store *store.Store, licenseService enterpriseAPI.LicenseService) *RiskService {+func NewRiskService(store *store.Store, licenseService enterprise.LicenseService) *RiskService {return &RiskService{store: store,licenseService: licenseService,diff --git a/backend/api/v1/role_service.go b/backend/api/v1/role_service.goindex 2a8c533043..3f5a2cfc7f 100644--- a/backend/api/v1/role_service.go+++ b/backend/api/v1/role_service.go@@ -9,7 +9,7 @@ import ("google.golang.org/protobuf/types/known/emptypb""github.com/bytebase/bytebase/backend/common"- enterpriseAPI "github.com/bytebase/bytebase/backend/enterprise/api"+ enterprise "github.com/bytebase/bytebase/backend/enterprise/api"api "github.com/bytebase/bytebase/backend/legacyapi""github.com/bytebase/bytebase/backend/store"v1pb "github.com/bytebase/bytebase/proto/generated-go/v1"@@ -19,11 +19,11 @@ import (type RoleService struct {v1pb.UnimplementedRoleServiceServerstore *store.Store- licenseService enterpriseAPI.LicenseService+ licenseService enterprise.LicenseService}// NewRoleService returns a new instance of the role service.-func NewRoleService(store *store.Store, licenseService enterpriseAPI.LicenseService) *RoleService {+func NewRoleService(store *store.Store, licenseService enterprise.LicenseService) *RoleService {return &RoleService{store: store,licenseService: licenseService,diff --git a/backend/api/v1/rollout_service.go b/backend/api/v1/rollout_service.goindex 570b568937..d8cf678a1f 100644--- a/backend/api/v1/rollout_service.go+++ b/backend/api/v1/rollout_service.go@@ -20,7 +20,7 @@ import ("github.com/bytebase/bytebase/backend/component/activity""github.com/bytebase/bytebase/backend/component/dbfactory""github.com/bytebase/bytebase/backend/component/state"- enterpriseAPI "github.com/bytebase/bytebase/backend/enterprise/api"+ enterprise "github.com/bytebase/bytebase/backend/enterprise/api"api "github.com/bytebase/bytebase/backend/legacyapi""github.com/bytebase/bytebase/backend/runner/plancheck""github.com/bytebase/bytebase/backend/store"@@ -33,7 +33,7 @@ import (type RolloutService struct {v1pb.UnimplementedRolloutServiceServerstore *store.Store- licenseService enterpriseAPI.LicenseService+ licenseService enterprise.LicenseServicedbFactory *dbfactory.DBFactoryplanCheckScheduler *plancheck.SchedulerstateCfg *state.State@@ -41,7 +41,7 @@ type RolloutService struct {}// NewRolloutService returns a rollout service instance.-func NewRolloutService(store *store.Store, licenseService enterpriseAPI.LicenseService, dbFactory *dbfactory.DBFactory, planCheckScheduler *plancheck.Scheduler, stateCfg *state.State, activityManager *activity.Manager) *RolloutService {+func NewRolloutService(store *store.Store, licenseService enterprise.LicenseService, dbFactory *dbfactory.DBFactory, planCheckScheduler *plancheck.Scheduler, stateCfg *state.State, activityManager *activity.Manager) *RolloutService {return &RolloutService{store: store,licenseService: licenseService,@@ -1125,7 +1125,7 @@ func validateSteps(steps []*v1pb.Plan_Step) error {}// GetPipelineCreate gets a pipeline create message from a plan.-func GetPipelineCreate(ctx context.Context, s *store.Store, licenseService enterpriseAPI.LicenseService, dbFactory *dbfactory.DBFactory, steps []*storepb.PlanConfig_Step, project *store.ProjectMessage) (*store.PipelineMessage, error) {+func GetPipelineCreate(ctx context.Context, s *store.Store, licenseService enterprise.LicenseService, dbFactory *dbfactory.DBFactory, steps []*storepb.PlanConfig_Step, project *store.ProjectMessage) (*store.PipelineMessage, error) {pipelineCreate := &store.PipelineMessage{Name: "Rollout Pipeline",}diff --git a/backend/api/v1/rollout_service_converter.go b/backend/api/v1/rollout_service_converter.goindex 4a338b0c50..a4e7372669 100644--- a/backend/api/v1/rollout_service_converter.go+++ b/backend/api/v1/rollout_service_converter.go@@ -473,9 +473,10 @@ func convertToTaskRun(stateCfg *state.State, taskRun *store.TaskRunMessage) *v1p}if v, ok := stateCfg.TaskRunExecutionStatuses.Load(taskRun.ID); ok {- s := v.(state.TaskRunExecutionStatus)- t.ExecutionStatus = s.ExecutionStatus- t.ExecutionStatusUpdateTime = timestamppb.New(s.UpdateTime)+ if s, ok := v.(state.TaskRunExecutionStatus); ok {+ t.ExecutionStatus = s.ExecutionStatus+ t.ExecutionStatusUpdateTime = timestamppb.New(s.UpdateTime)+ }}return tdiff --git a/backend/api/v1/rollout_service_task.go b/backend/api/v1/rollout_service_task.goindex 189d0a5362..7ba1408a8f 100644--- a/backend/api/v1/rollout_service_task.go+++ b/backend/api/v1/rollout_service_task.go@@ -13,7 +13,7 @@ import ("github.com/bytebase/bytebase/backend/common""github.com/bytebase/bytebase/backend/common/log""github.com/bytebase/bytebase/backend/component/dbfactory"- enterpriseAPI "github.com/bytebase/bytebase/backend/enterprise/api"+ enterprise "github.com/bytebase/bytebase/backend/enterprise/api"api "github.com/bytebase/bytebase/backend/legacyapi""github.com/bytebase/bytebase/backend/store""github.com/bytebase/bytebase/backend/utils"@@ -88,7 +88,7 @@ func transformDeploymentConfigTargetToSteps(ctx context.Context, s *store.Store,return steps, nil}-func getTaskCreatesFromSpec(ctx context.Context, s *store.Store, licenseService enterpriseAPI.LicenseService, dbFactory *dbfactory.DBFactory, spec *storepb.PlanConfig_Spec, project *store.ProjectMessage, registerEnvironmentID func(string) error) ([]*store.TaskMessage, []store.TaskIndexDAG, error) {+func getTaskCreatesFromSpec(ctx context.Context, s *store.Store, licenseService enterprise.LicenseService, dbFactory *dbfactory.DBFactory, spec *storepb.PlanConfig_Spec, project *store.ProjectMessage, registerEnvironmentID func(string) error) ([]*store.TaskMessage, []store.TaskIndexDAG, error) {if licenseService.IsFeatureEnabled(api.FeatureTaskScheduleTime) != nil {if spec.EarliestAllowedTime != nil && !spec.EarliestAllowedTime.AsTime().IsZero() {return nil, nil, errors.Errorf(api.FeatureTaskScheduleTime.AccessErrorMessage())@@ -107,7 +107,7 @@ func getTaskCreatesFromSpec(ctx context.Context, s *store.Store, licenseServicereturn nil, nil, errors.Errorf("invalid spec config type %T", spec.Config)}-func getTaskCreatesFromCreateDatabaseConfig(ctx context.Context, s *store.Store, licenseService enterpriseAPI.LicenseService, dbFactory *dbfactory.DBFactory, spec *storepb.PlanConfig_Spec, c *storepb.PlanConfig_CreateDatabaseConfig, project *store.ProjectMessage, registerEnvironmentID func(string) error) ([]*store.TaskMessage, []store.TaskIndexDAG, error) {+func getTaskCreatesFromCreateDatabaseConfig(ctx context.Context, s *store.Store, licenseService enterprise.LicenseService, dbFactory *dbfactory.DBFactory, spec *storepb.PlanConfig_Spec, c *storepb.PlanConfig_CreateDatabaseConfig, project *store.ProjectMessage, registerEnvironmentID func(string) error) ([]*store.TaskMessage, []store.TaskIndexDAG, error) {if c.Database == "" {return nil, nil, errors.Errorf("database name is required")}@@ -659,7 +659,7 @@ func getTaskCreatesFromChangeDatabaseConfigDatabaseGroupStatements(db *store.Datreturn creates, nil}-func getTaskCreatesFromRestoreDatabaseConfig(ctx context.Context, s *store.Store, licenseService enterpriseAPI.LicenseService, dbFactory *dbfactory.DBFactory, spec *storepb.PlanConfig_Spec, c *storepb.PlanConfig_RestoreDatabaseConfig, project *store.ProjectMessage, registerEnvironmentID func(string) error) ([]*store.TaskMessage, []store.TaskIndexDAG, error) {+func getTaskCreatesFromRestoreDatabaseConfig(ctx context.Context, s *store.Store, licenseService enterprise.LicenseService, dbFactory *dbfactory.DBFactory, spec *storepb.PlanConfig_Spec, c *storepb.PlanConfig_RestoreDatabaseConfig, project *store.ProjectMessage, registerEnvironmentID func(string) error) ([]*store.TaskMessage, []store.TaskIndexDAG, error) {if c.Source == nil {return nil, nil, errors.Errorf("missing source in restore database config")}diff --git a/backend/api/v1/schema_design_service.go b/backend/api/v1/schema_design_service.goindex 18fd308fd6..09697d0526 100644--- a/backend/api/v1/schema_design_service.go+++ b/backend/api/v1/schema_design_service.go@@ -13,7 +13,7 @@ import ("google.golang.org/protobuf/types/known/timestamppb""github.com/bytebase/bytebase/backend/common"- enterpriseAPI "github.com/bytebase/bytebase/backend/enterprise/api"+ enterprise "github.com/bytebase/bytebase/backend/enterprise/api""github.com/bytebase/bytebase/backend/plugin/parser/base""github.com/bytebase/bytebase/backend/store"storepb "github.com/bytebase/bytebase/proto/generated-go/store"@@ -24,11 +24,11 @@ import (type SchemaDesignService struct {v1pb.UnimplementedSchemaDesignServiceServerstore *store.Store- licenseService enterpriseAPI.LicenseService+ licenseService enterprise.LicenseService}// NewSchemaDesignService creates a new SchemaDesignService.-func NewSchemaDesignService(store *store.Store, licenseService enterpriseAPI.LicenseService) *SchemaDesignService {+func NewSchemaDesignService(store *store.Store, licenseService enterprise.LicenseService) *SchemaDesignService {return &SchemaDesignService{store: store,licenseService: licenseService,diff --git a/backend/api/v1/schema_design_transformer.go b/backend/api/v1/schema_design_transformer.goindex 3b551d4981..aaf99de370 100644--- a/backend/api/v1/schema_design_transformer.go+++ b/backend/api/v1/schema_design_transformer.go@@ -14,7 +14,7 @@ import (mysqlparser "github.com/bytebase/bytebase/backend/plugin/parser/mysql"pgrawparser "github.com/bytebase/bytebase/backend/plugin/parser/sql/engine/pg"- pgSchemaEngine "github.com/bytebase/bytebase/backend/plugin/schema-engine/pg"+ pgse "github.com/bytebase/bytebase/backend/plugin/schema-engine/pg"v1pb "github.com/bytebase/bytebase/proto/generated-go/v1")@@ -25,7 +25,7 @@ func transformDatabaseMetadataToSchemaString(engine v1pb.Engine, database *v1pb.case v1pb.Engine_TIDB:return getTiDBDesignSchema("", database)case v1pb.Engine_POSTGRES:- return pgSchemaEngine.GetDesignSchema("", database)+ return pgse.GetDesignSchema("", database)default:return "", status.Errorf(codes.InvalidArgument, fmt.Sprintf("unsupported engine: %v", engine))}@@ -37,7 +37,7 @@ func transformSchemaStringToDatabaseMetadata(engine v1pb.Engine, schema string)case v1pb.Engine_MYSQL:return parseMySQLSchemaStringToDatabaseMetadata(schema)case v1pb.Engine_POSTGRES:- return pgSchemaEngine.ParseToMetadata(schema)+ return pgse.ParseToMetadata(schema)case v1pb.Engine_TIDB:return parseTiDBSchemaStringToDatabaseMetadata(schema)default:@@ -799,7 +799,7 @@ func getDesignSchema(engine v1pb.Engine, baselineSchema string, to *v1pb.Databas}return result, nilcase v1pb.Engine_POSTGRES:- result, err := pgSchemaEngine.GetDesignSchema(baselineSchema, to)+ result, err := pgse.GetDesignSchema(baselineSchema, to)if err != nil {return "", status.Errorf(codes.Internal, "failed to generate postgres design schema: %v", err)}diff --git a/backend/api/v1/setting_service.go b/backend/api/v1/setting_service.goindex 06cdcf97d8..b842a8b57d 100644--- a/backend/api/v1/setting_service.go+++ b/backend/api/v1/setting_service.go@@ -21,7 +21,7 @@ import ("github.com/bytebase/bytebase/backend/common""github.com/bytebase/bytebase/backend/component/config""github.com/bytebase/bytebase/backend/component/state"- enterpriseAPI "github.com/bytebase/bytebase/backend/enterprise/api"+ enterprise "github.com/bytebase/bytebase/backend/enterprise/api"api "github.com/bytebase/bytebase/backend/legacyapi""github.com/bytebase/bytebase/backend/plugin/mail""github.com/bytebase/bytebase/backend/store"@@ -34,7 +34,7 @@ type SettingService struct {v1pb.UnimplementedSettingServiceServerstore *store.Storeprofile *config.Profile- licenseService enterpriseAPI.LicenseService+ licenseService enterprise.LicenseServicestateCfg *state.State}@@ -42,7 +42,7 @@ type SettingService struct {func NewSettingService(store *store.Store,profile *config.Profile,- licenseService enterpriseAPI.LicenseService,+ licenseService enterprise.LicenseService,stateCfg *state.State,) *SettingService {return &SettingService{diff --git a/backend/api/v1/sheet_service.go b/backend/api/v1/sheet_service.goindex 1bfe8e68a4..7eeb177d7e 100644--- a/backend/api/v1/sheet_service.go+++ b/backend/api/v1/sheet_service.go@@ -18,9 +18,9 @@ import ("github.com/bytebase/bytebase/backend/common""github.com/bytebase/bytebase/backend/common/log"- enterpriseAPI "github.com/bytebase/bytebase/backend/enterprise/api"+ enterprise "github.com/bytebase/bytebase/backend/enterprise/api"api "github.com/bytebase/bytebase/backend/legacyapi"- vcsPlugin "github.com/bytebase/bytebase/backend/plugin/vcs"+ vcsplugin "github.com/bytebase/bytebase/backend/plugin/vcs""github.com/bytebase/bytebase/backend/store""github.com/bytebase/bytebase/backend/utils"storepb "github.com/bytebase/bytebase/proto/generated-go/store"@@ -31,11 +31,11 @@ import (type SheetService struct {v1pb.UnimplementedSheetServiceServerstore *store.Store- licenseService enterpriseAPI.LicenseService+ licenseService enterprise.LicenseService}// NewSheetService creates a new SheetService.-func NewSheetService(store *store.Store, licenseService enterpriseAPI.LicenseService) *SheetService {+func NewSheetService(store *store.Store, licenseService enterprise.LicenseService) *SheetService {return &SheetService{store: store,licenseService: licenseService,@@ -499,7 +499,7 @@ func (s *SheetService) SyncSheets(ctx context.Context, request *v1pb.SyncSheetsRbasePath := filepath.Dir(repo.SheetPathTemplate)// TODO(Steven): The repo.branchFilter could be `test/*` which cannot be the ref value.// TODO(zp): We may need a need VCS interface to get fetch repository file list for a branch instead of a SHA1.- fileList, err := vcsPlugin.Get(vcs.Type, vcsPlugin.ProviderConfig{}).FetchRepositoryFileList(ctx,+ fileList, err := vcsplugin.Get(vcs.Type, vcsplugin.ProviderConfig{}).FetchRepositoryFileList(ctx,common.OauthContext{ClientID: vcs.ApplicationID,ClientSecret: vcs.Secret,@@ -526,7 +526,7 @@ func (s *SheetService) SyncSheets(ctx context.Context, request *v1pb.SyncSheetsRreturn nil, status.Errorf(codes.InvalidArgument, fmt.Sprintf("sheet name cannot be empty from sheet path %s with template %s", file.Path, repo.SheetPathTemplate))}- fileContent, err := vcsPlugin.Get(vcs.Type, vcsPlugin.ProviderConfig{}).ReadFileContent(ctx,+ fileContent, err := vcsplugin.Get(vcs.Type, vcsplugin.ProviderConfig{}).ReadFileContent(ctx,common.OauthContext{ClientID: vcs.ApplicationID,ClientSecret: vcs.Secret,@@ -538,8 +538,8 @@ func (s *SheetService) SyncSheets(ctx context.Context, request *v1pb.SyncSheetsRvcs.InstanceURL,repo.ExternalID,file.Path,- vcsPlugin.RefInfo{- RefType: vcsPlugin.RefTypeBranch,+ vcsplugin.RefInfo{+ RefType: vcsplugin.RefTypeBranch,RefName: repo.BranchFilter,},)@@ -547,7 +547,7 @@ func (s *SheetService) SyncSheets(ctx context.Context, request *v1pb.SyncSheetsRreturn nil, status.Errorf(codes.Internal, fmt.Sprintf("Failed to fetch file content from VCS, instance URL: %s, repo ID: %s, file path: %s, branch: %s", vcs.InstanceURL, repo.ExternalID, file.Path, repo.BranchFilter))}- fileMeta, err := vcsPlugin.Get(vcs.Type, vcsPlugin.ProviderConfig{}).ReadFileMeta(ctx,+ fileMeta, err := vcsplugin.Get(vcs.Type, vcsplugin.ProviderConfig{}).ReadFileMeta(ctx,common.OauthContext{ClientID: vcs.ApplicationID,ClientSecret: vcs.Secret,@@ -559,8 +559,8 @@ func (s *SheetService) SyncSheets(ctx context.Context, request *v1pb.SyncSheetsRvcs.InstanceURL,repo.ExternalID,file.Path,- vcsPlugin.RefInfo{- RefType: vcsPlugin.RefTypeBranch,+ vcsplugin.RefInfo{+ RefType: vcsplugin.RefTypeBranch,RefName: repo.BranchFilter,},)@@ -568,7 +568,7 @@ func (s *SheetService) SyncSheets(ctx context.Context, request *v1pb.SyncSheetsRreturn nil, status.Errorf(codes.Internal, fmt.Sprintf("Failed to fetch file meta from VCS, instance URL: %s, repo ID: %s, file path: %s, branch: %s", vcs.InstanceURL, repo.ExternalID, file.Path, repo.BranchFilter))}- lastCommit, err := vcsPlugin.Get(vcs.Type, vcsPlugin.ProviderConfig{}).FetchCommitByID(ctx,+ lastCommit, err := vcsplugin.Get(vcs.Type, vcsplugin.ProviderConfig{}).FetchCommitByID(ctx,common.OauthContext{ClientID: vcs.ApplicationID,ClientSecret: vcs.Secret,@@ -631,11 +631,11 @@ func (s *SheetService) SyncSheets(ctx context.Context, request *v1pb.SyncSheetsRvar sheetSource store.SheetSourceswitch vcs.Type {- case vcsPlugin.GitLab:+ case vcsplugin.GitLab:sheetSource = store.SheetFromGitLab- case vcsPlugin.GitHub:+ case vcsplugin.GitHub:sheetSource = store.SheetFromGitHub- case vcsPlugin.Bitbucket:+ case vcsplugin.Bitbucket:sheetSource = store.SheetFromBitbucket}vscSheetType := store.SheetForSQL@@ -796,7 +796,10 @@ func (s *SheetService) canReadSheet(ctx context.Context, sheet *store.SheetMessaif !ok {return false, status.Errorf(codes.Internal, "principal ID not found")}- role := ctx.Value(common.RoleContextKey).(api.Role)+ role, ok := ctx.Value(common.RoleContextKey).(api.Role)+ if !ok {+ return false, status.Errorf(codes.Internal, "role not found")+ }switch sheet.Visibility {case store.PrivateSheet:diff --git a/backend/api/v1/sql_service.go b/backend/api/v1/sql_service.goindex 91b18a6a55..06814b59cb 100644--- a/backend/api/v1/sql_service.go+++ b/backend/api/v1/sql_service.go@@ -29,7 +29,7 @@ import ("github.com/bytebase/bytebase/backend/common/log""github.com/bytebase/bytebase/backend/component/activity""github.com/bytebase/bytebase/backend/component/dbfactory"- enterpriseAPI "github.com/bytebase/bytebase/backend/enterprise/api"+ enterprise "github.com/bytebase/bytebase/backend/enterprise/api"api "github.com/bytebase/bytebase/backend/legacyapi""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/advisor/catalog"@@ -59,7 +59,7 @@ type SQLService struct {schemaSyncer *schemasync.SyncerdbFactory *dbfactory.DBFactoryactivityManager *activity.Manager- licenseService enterpriseAPI.LicenseService+ licenseService enterprise.LicenseService}// NewSQLService creates a SQLService.@@ -68,7 +68,7 @@ func NewSQLService(schemaSyncer *schemasync.Syncer,dbFactory *dbfactory.DBFactory,activityManager *activity.Manager,- licenseService enterpriseAPI.LicenseService,+ licenseService enterprise.LicenseService,) *SQLService {return &SQLService{store: store,@@ -2347,7 +2347,10 @@ func (s *SQLService) getUser(ctx context.Context) (*store.UserMessage, error) {if principalPtr == nil {return nil, nil}- principalID := principalPtr.(int)+ principalID, ok := principalPtr.(int)+ if !ok {+ return nil, status.Errorf(codes.Internal, "principal ID not found")+ }user, err := s.store.GetUserByID(ctx, principalID)if err != nil {return nil, status.Errorf(codes.PermissionDenied, "failed to get member for user %v in processing authorize request.", principalID)diff --git a/backend/api/v1/subscription_service.go b/backend/api/v1/subscription_service.goindex acc84d5309..7bc0bb86fe 100644--- a/backend/api/v1/subscription_service.go+++ b/backend/api/v1/subscription_service.go@@ -12,7 +12,7 @@ import ("github.com/bytebase/bytebase/backend/common""github.com/bytebase/bytebase/backend/component/config"- enterpriseAPI "github.com/bytebase/bytebase/backend/enterprise/api"+ enterprise "github.com/bytebase/bytebase/backend/enterprise/api"api "github.com/bytebase/bytebase/backend/legacyapi"metricAPI "github.com/bytebase/bytebase/backend/metric""github.com/bytebase/bytebase/backend/plugin/metric"@@ -27,7 +27,7 @@ type SubscriptionService struct {store *store.Storeprofile *config.ProfilemetricReporter *metricreport.Reporter- licenseService enterpriseAPI.LicenseService+ licenseService enterprise.LicenseService}// NewSubscriptionService creates a new SubscriptionService.@@ -35,7 +35,7 @@ func NewSubscriptionService(store *store.Store,profile *config.Profile,metricReporter *metricreport.Reporter,- licenseService enterpriseAPI.LicenseService) *SubscriptionService {+ licenseService enterprise.LicenseService) *SubscriptionService {return &SubscriptionService{store: store,profile: profile,@@ -80,7 +80,7 @@ func (s *SubscriptionService) UpdateSubscription(ctx context.Context, request *vif !ok {return nil, status.Errorf(codes.Internal, "principal ID not found")}- if err := s.licenseService.StoreLicense(ctx, &enterpriseAPI.SubscriptionPatch{+ if err := s.licenseService.StoreLicense(ctx, &enterprise.SubscriptionPatch{UpdaterID: principalID,License: request.Patch.License,}); err != nil {@@ -108,9 +108,9 @@ func (s *SubscriptionService) TrialSubscription(ctx context.Context, request *v1return nil, status.Errorf(codes.Internal, err.Error())}- license := &enterpriseAPI.License{- InstanceCount: enterpriseAPI.InstanceLimitForTrial,- ExpiresTs: time.Now().AddDate(0, 0, enterpriseAPI.TrialDaysLimit).Unix(),+ license := &enterprise.License{+ InstanceCount: enterprise.InstanceLimitForTrial,+ ExpiresTs: time.Now().AddDate(0, 0, enterprise.TrialDaysLimit).Unix(),IssuedTs: time.Now().Unix(),Plan: planType,// the subject format for license should be {org id in hub}.{subscription id in hub}@@ -153,7 +153,7 @@ func (s *SubscriptionService) TrialSubscription(ctx context.Context, request *v1}// we need to override the SettingEnterpriseLicense with an empty value to get the valid free trial.- if err := s.licenseService.StoreLicense(ctx, &enterpriseAPI.SubscriptionPatch{+ if err := s.licenseService.StoreLicense(ctx, &enterprise.SubscriptionPatch{UpdaterID: principalID,License: "",}); err != nil {diff --git a/backend/common/convert.go b/backend/common/convert.goindex 9f7db9b209..4d560a1e6f 100644--- a/backend/common/convert.go+++ b/backend/common/convert.go@@ -5,7 +5,7 @@ import ("github.com/google/cel-go/cel""github.com/pkg/errors"- v1alpha1 "google.golang.org/genproto/googleapis/api/expr/v1alpha1"+ exprproto "google.golang.org/genproto/googleapis/api/expr/v1alpha1""google.golang.org/genproto/googleapis/type/expr""google.golang.org/grpc/codes""google.golang.org/grpc/status"@@ -85,7 +85,7 @@ var ProjectMemberCELAttributes = []cel.EnvOption{}// ConvertParsedRisk converts parsed risk to unparsed format.-func ConvertParsedRisk(expression *v1alpha1.ParsedExpr) (*expr.Expr, error) {+func ConvertParsedRisk(expression *exprproto.ParsedExpr) (*expr.Expr, error) {if expression == nil || expression.Expr == nil {return nil, nil}@@ -100,7 +100,7 @@ func ConvertParsedRisk(expression *v1alpha1.ParsedExpr) (*expr.Expr, error) {}// ConvertUnparsedRisk converts unparsed risk to parsed format.-func ConvertUnparsedRisk(expression *expr.Expr) (*v1alpha1.ParsedExpr, error) {+func ConvertUnparsedRisk(expression *expr.Expr) (*exprproto.ParsedExpr, error) {if expression == nil || expression.Expression == "" {return nil, nil}@@ -121,7 +121,7 @@ func ConvertUnparsedRisk(expression *expr.Expr) (*v1alpha1.ParsedExpr, error) {}// ConvertParsedApproval converts parsed approval to unparsed format.-func ConvertParsedApproval(expression *v1alpha1.ParsedExpr) (*expr.Expr, error) {+func ConvertParsedApproval(expression *exprproto.ParsedExpr) (*expr.Expr, error) {if expression == nil || expression.Expr == nil {return nil, nil}@@ -136,7 +136,7 @@ func ConvertParsedApproval(expression *v1alpha1.ParsedExpr) (*expr.Expr, error)}// ConvertUnparsedApproval converts unparsed approval to parsed format.-func ConvertUnparsedApproval(expression *expr.Expr) (*v1alpha1.ParsedExpr, error) {+func ConvertUnparsedApproval(expression *expr.Expr) (*exprproto.ParsedExpr, error) {if expression == nil || expression.Expression == "" {return nil, nil}@@ -262,7 +262,7 @@ func GetQueryExportFactors(expression string) (*QueryExportFactors, error) {return factors, nil}-func findField(callExpr *v1alpha1.Expr_Call, factors *QueryExportFactors) {+func findField(callExpr *exprproto.Expr_Call, factors *QueryExportFactors) {if callExpr == nil {return}diff --git a/backend/enterprise/service/license.go b/backend/enterprise/service/license.goindex beea75d816..f4f20ce02e 100644--- a/backend/enterprise/service/license.go+++ b/backend/enterprise/service/license.go@@ -13,7 +13,7 @@ import ("github.com/bytebase/bytebase/backend/common""github.com/bytebase/bytebase/backend/common/log"- enterpriseAPI "github.com/bytebase/bytebase/backend/enterprise/api"+ enterprise "github.com/bytebase/bytebase/backend/enterprise/api""github.com/bytebase/bytebase/backend/enterprise/config"api "github.com/bytebase/bytebase/backend/legacyapi""github.com/bytebase/bytebase/backend/store"@@ -24,7 +24,7 @@ type LicenseService struct {config *config.Configstore *store.Storeprovider *LicenseProvider- cachedSubscription *enterpriseAPI.Subscription+ cachedSubscription *enterprise.Subscription}// Claims creates a struct that will be encoded to a JWT.@@ -52,7 +52,7 @@ func NewLicenseService(mode common.ReleaseMode, store *store.Store) (*LicenseSer}// StoreLicense will store license into file.-func (s *LicenseService) StoreLicense(ctx context.Context, patch *enterpriseAPI.SubscriptionPatch) error {+func (s *LicenseService) StoreLicense(ctx context.Context, patch *enterprise.SubscriptionPatch) error {if patch.License != "" {if _, err := s.parseLicense(patch.License); err != nil {return err@@ -70,7 +70,7 @@ func (s *LicenseService) StoreLicense(ctx context.Context, patch *enterpriseAPI.}// LoadSubscription will load subscription.-func (s *LicenseService) LoadSubscription(ctx context.Context) enterpriseAPI.Subscription {+func (s *LicenseService) LoadSubscription(ctx context.Context) enterprise.Subscription {if s.cachedSubscription != nil && s.cachedSubscription.IsExpired() {// refresh expired subscriptions.cachedSubscription = nil@@ -82,7 +82,7 @@ func (s *LicenseService) LoadSubscription(ctx context.Context) enterpriseAPI.Sublicense := s.loadLicense(ctx)if license == nil {s.store.RefreshSwap(false)- return enterpriseAPI.Subscription{+ return enterprise.Subscription{Plan: api.FREE,// -1 means not expire, just for free planExpiresTs: -1,@@ -92,7 +92,7 @@ func (s *LicenseService) LoadSubscription(ctx context.Context) enterpriseAPI.Sub}// Cache the subscription.- s.cachedSubscription = &enterpriseAPI.Subscription{+ s.cachedSubscription = &enterprise.Subscription{Plan: license.Plan,ExpiresTs: license.ExpiresTs,StartedTs: license.IssuedTs,@@ -155,8 +155,8 @@ func (s *LicenseService) GetEffectivePlan() api.PlanType {}// GetPlanLimitValue gets the limit value for the plan.-func (s *LicenseService) GetPlanLimitValue(ctx context.Context, name enterpriseAPI.PlanLimit) int64 {- v, ok := enterpriseAPI.PlanLimitValues[name]+func (s *LicenseService) GetPlanLimitValue(ctx context.Context, name enterprise.PlanLimit) int64 {+ v, ok := enterprise.PlanLimitValues[name]if !ok {return 0}@@ -180,7 +180,7 @@ func (s *LicenseService) RefreshCache(ctx context.Context) {s.LoadSubscription(ctx)}-func (s *LicenseService) fetchLicense(ctx context.Context) (*enterpriseAPI.License, error) {+func (s *LicenseService) fetchLicense(ctx context.Context) (*enterprise.License, error) {license, err := s.provider.FetchLicense(ctx)if err != nil {return nil, err@@ -206,7 +206,7 @@ func (s *LicenseService) fetchLicense(ctx context.Context) (*enterpriseAPI.Licen}// loadLicense will load license and validate it.-func (s *LicenseService) loadLicense(ctx context.Context) *enterpriseAPI.License {+func (s *LicenseService) loadLicense(ctx context.Context) *enterprise.License {license, err := s.findEnterpriseLicense(ctx)if err != nil {slog.Debug("failed to load enterprise license", log.BBError(err))@@ -235,7 +235,7 @@ func (s *LicenseService) loadLicense(ctx context.Context) *enterpriseAPI.Licensereturn license}-func (s *LicenseService) parseLicense(license string) (*enterpriseAPI.License, error) {+func (s *LicenseService) parseLicense(license string) (*enterprise.License, error) {claims := &Claims{}if err := parseJWTToken(license, s.config.Version, s.config.PublicKey, claims); err != nil {return nil, common.Wrap(err, common.Invalid)@@ -244,7 +244,7 @@ func (s *LicenseService) parseLicense(license string) (*enterpriseAPI.License, ereturn s.parseClaims(claims)}-func (s *LicenseService) findEnterpriseLicense(ctx context.Context) (*enterpriseAPI.License, error) {+func (s *LicenseService) findEnterpriseLicense(ctx context.Context) (*enterprise.License, error) {// Find enterprise license.settingName := api.SettingEnterpriseLicensesetting, err := s.store.GetSettingV2(ctx, &store.FindSettingMessage{@@ -272,7 +272,7 @@ func (s *LicenseService) findEnterpriseLicense(ctx context.Context) (*enterprisereturn nil, nil}-func (s *LicenseService) findTrialingLicense(ctx context.Context) (*enterpriseAPI.License, error) {+func (s *LicenseService) findTrialingLicense(ctx context.Context) (*enterprise.License, error) {settingName := api.SettingEnterpriseTrialsetting, err := s.store.GetSettingV2(ctx, &store.FindSettingMessage{Name: &settingName,@@ -281,12 +281,12 @@ func (s *LicenseService) findTrialingLicense(ctx context.Context) (*enterpriseAPreturn nil, errors.Wrapf(err, "failed to load trial license from settings")}if setting != nil && setting.Value != "" {- var data enterpriseAPI.License+ var data enterprise.Licenseif err := json.Unmarshal([]byte(setting.Value), &data); err != nil {return nil, errors.Wrapf(err, "failed to parse trial license")}- data.InstanceCount = enterpriseAPI.InstanceLimitForTrial- if time.Now().AddDate(0, 0, -enterpriseAPI.TrialDaysLimit).Unix() >= setting.CreatedTs {+ data.InstanceCount = enterprise.InstanceLimitForTrial+ if time.Now().AddDate(0, 0, -enterprise.TrialDaysLimit).Unix() >= setting.CreatedTs {return nil, nil}return &data, nil@@ -296,7 +296,7 @@ func (s *LicenseService) findTrialingLicense(ctx context.Context) (*enterpriseAP}// parseClaims will valid and parse JWT claims to license instance.-func (s *LicenseService) parseClaims(claims *Claims) (*enterpriseAPI.License, error) {+func (s *LicenseService) parseClaims(claims *Claims) (*enterprise.License, error) {verifyIssuer := claims.VerifyIssuer(s.config.Issuer, true)if !verifyIssuer {return nil, common.Errorf(common.Invalid, "iss is not valid, expect %s but found '%v'", s.config.Issuer, claims.Issuer)@@ -312,7 +312,7 @@ func (s *LicenseService) parseClaims(claims *Claims) (*enterpriseAPI.License, erreturn nil, common.Errorf(common.Invalid, "plan type %q is not valid", planType)}- license := &enterpriseAPI.License{+ license := &enterprise.License{InstanceCount: claims.InstanceCount,ExpiresTs: claims.ExpiresAt.Unix(),IssuedTs: claims.IssuedAt.Unix(),diff --git a/backend/runner/approval/runner.go b/backend/runner/approval/runner.goindex 9649d31dfe..0684700762 100644--- a/backend/runner/approval/runner.go+++ b/backend/runner/approval/runner.go@@ -25,7 +25,7 @@ import ("github.com/bytebase/bytebase/backend/component/activity""github.com/bytebase/bytebase/backend/component/dbfactory""github.com/bytebase/bytebase/backend/component/state"- enterpriseAPI "github.com/bytebase/bytebase/backend/enterprise/api"+ enterprise "github.com/bytebase/bytebase/backend/enterprise/api"api "github.com/bytebase/bytebase/backend/legacyapi""github.com/bytebase/bytebase/backend/runner/relay""github.com/bytebase/bytebase/backend/utils"@@ -43,11 +43,11 @@ type Runner struct {stateCfg *state.StateactivityManager *activity.ManagerrelayRunner *relay.Runner- licenseService enterpriseAPI.LicenseService+ licenseService enterprise.LicenseService}// NewRunner creates a new runner.-func NewRunner(store *store.Store, dbFactory *dbfactory.DBFactory, stateCfg *state.State, activityManager *activity.Manager, relayRunner *relay.Runner, licenseService enterpriseAPI.LicenseService) *Runner {+func NewRunner(store *store.Store, dbFactory *dbfactory.DBFactory, stateCfg *state.State, activityManager *activity.Manager, relayRunner *relay.Runner, licenseService enterprise.LicenseService) *Runner {return &Runner{store: store,dbFactory: dbFactory,@@ -323,7 +323,7 @@ func getApprovalTemplate(approvalSetting *storepb.WorkspaceApprovalSetting, riskreturn nil, nil}-func getIssueRisk(ctx context.Context, s *store.Store, licenseService enterpriseAPI.LicenseService, dbFactory *dbfactory.DBFactory, issue *store.IssueMessage, risks []*store.RiskMessage) (int64, store.RiskSource, bool, error) {+func getIssueRisk(ctx context.Context, s *store.Store, licenseService enterprise.LicenseService, dbFactory *dbfactory.DBFactory, issue *store.IssueMessage, risks []*store.RiskMessage) (int64, store.RiskSource, bool, error) {switch issue.Type {case api.IssueGrantRequest:return getGrantRequestIssueRisk(ctx, s, issue, risks)@@ -334,7 +334,7 @@ func getIssueRisk(ctx context.Context, s *store.Store, licenseService enterprise}}-func getDatabaseGeneralIssueRisk(ctx context.Context, s *store.Store, licenseService enterpriseAPI.LicenseService, dbFactory *dbfactory.DBFactory, issue *store.IssueMessage, risks []*store.RiskMessage) (int64, store.RiskSource, bool, error) {+func getDatabaseGeneralIssueRisk(ctx context.Context, s *store.Store, licenseService enterprise.LicenseService, dbFactory *dbfactory.DBFactory, issue *store.IssueMessage, risks []*store.RiskMessage) (int64, store.RiskSource, bool, error) {if issue.PlanUID == nil {return 0, store.RiskSourceUnknown, false, errors.Errorf("expected plan UID in issue %v", issue.UID)}diff --git a/backend/runner/metricreport/reporter.go b/backend/runner/metricreport/reporter.goindex a74ef15236..eb8b51b6df 100644--- a/backend/runner/metricreport/reporter.go+++ b/backend/runner/metricreport/reporter.go@@ -12,7 +12,7 @@ import ("github.com/bytebase/bytebase/backend/common/log""github.com/bytebase/bytebase/backend/component/config"- enterpriseAPI "github.com/bytebase/bytebase/backend/enterprise/api"+ enterprise "github.com/bytebase/bytebase/backend/enterprise/api"api "github.com/bytebase/bytebase/backend/legacyapi""github.com/bytebase/bytebase/backend/plugin/metric""github.com/bytebase/bytebase/backend/plugin/metric/segment"@@ -47,7 +47,7 @@ const (// Reporter is the metric reporter.type Reporter struct {- licenseService enterpriseAPI.LicenseService+ licenseService enterprise.LicenseServiceprofile *config.Profilereporter metric.Reportercollectors map[string]metric.Collector@@ -55,7 +55,7 @@ type Reporter struct {}// NewReporter creates a new metric scheduler.-func NewReporter(store *store.Store, licenseService enterpriseAPI.LicenseService, profile *config.Profile, enabled bool) *Reporter {+func NewReporter(store *store.Store, licenseService enterprise.LicenseService, profile *config.Profile, enabled bool) *Reporter {var r metric.Reporterif enabled {r = segment.NewReporter(profile.MetricConnectionKey)diff --git a/backend/runner/plancheck/scheduler.go b/backend/runner/plancheck/scheduler.goindex 8afed85295..91cc0fbd81 100644--- a/backend/runner/plancheck/scheduler.go+++ b/backend/runner/plancheck/scheduler.go@@ -12,7 +12,7 @@ import ("github.com/bytebase/bytebase/backend/common/log""github.com/bytebase/bytebase/backend/component/state"- enterpriseAPI "github.com/bytebase/bytebase/backend/enterprise/api"+ enterprise "github.com/bytebase/bytebase/backend/enterprise/api"api "github.com/bytebase/bytebase/backend/legacyapi""github.com/bytebase/bytebase/backend/store"storepb "github.com/bytebase/bytebase/proto/generated-go/store"@@ -23,7 +23,7 @@ const ()// NewScheduler creates a new plan check scheduler.-func NewScheduler(s *store.Store, licenseService enterpriseAPI.LicenseService, stateCfg *state.State) *Scheduler {+func NewScheduler(s *store.Store, licenseService enterprise.LicenseService, stateCfg *state.State) *Scheduler {return &Scheduler{store: s,licenseService: licenseService,@@ -35,7 +35,7 @@ func NewScheduler(s *store.Store, licenseService enterpriseAPI.LicenseService, s// Scheduler is the plan check run scheduler.type Scheduler struct {store *store.Store- licenseService enterpriseAPI.LicenseService+ licenseService enterprise.LicenseServicestateCfg *state.Stateexecutors map[store.PlanCheckRunType]Executor}diff --git a/backend/runner/plancheck/statement_advise_executor.go b/backend/runner/plancheck/statement_advise_executor.goindex 4fca4c5a90..e9d77c54bb 100644--- a/backend/runner/plancheck/statement_advise_executor.go+++ b/backend/runner/plancheck/statement_advise_executor.go@@ -8,7 +8,7 @@ import ("github.com/bytebase/bytebase/backend/common""github.com/bytebase/bytebase/backend/component/dbfactory"- enterpriseAPI "github.com/bytebase/bytebase/backend/enterprise/api"+ enterprise "github.com/bytebase/bytebase/backend/enterprise/api"api "github.com/bytebase/bytebase/backend/legacyapi""github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/store"@@ -20,7 +20,7 @@ import (func NewStatementAdviseExecutor(store *store.Store,dbFactory *dbfactory.DBFactory,- licenseService enterpriseAPI.LicenseService,+ licenseService enterprise.LicenseService,) Executor {return &StatementAdviseExecutor{store: store,@@ -33,7 +33,7 @@ func NewStatementAdviseExecutor(type StatementAdviseExecutor struct {store *store.StoredbFactory *dbfactory.DBFactory- licenseService enterpriseAPI.LicenseService+ licenseService enterprise.LicenseService}// Run will run the plan check statement advise executor once, and run its sub-advisors one-by-one.diff --git a/backend/runner/schemasync/syncer.go b/backend/runner/schemasync/syncer.goindex efe84e7cad..4975d08995 100644--- a/backend/runner/schemasync/syncer.go+++ b/backend/runner/schemasync/syncer.go@@ -20,7 +20,7 @@ import ("github.com/bytebase/bytebase/backend/component/config""github.com/bytebase/bytebase/backend/component/dbfactory""github.com/bytebase/bytebase/backend/component/state"- enterpriseAPI "github.com/bytebase/bytebase/backend/enterprise/api"+ enterprise "github.com/bytebase/bytebase/backend/enterprise/api"api "github.com/bytebase/bytebase/backend/legacyapi""github.com/bytebase/bytebase/backend/store""github.com/bytebase/bytebase/backend/store/model"@@ -35,7 +35,7 @@ const ()// NewSyncer creates a schema syncer.-func NewSyncer(store *store.Store, dbFactory *dbfactory.DBFactory, stateCfg *state.State, profile config.Profile, licenseService enterpriseAPI.LicenseService) *Syncer {+func NewSyncer(store *store.Store, dbFactory *dbfactory.DBFactory, stateCfg *state.State, profile config.Profile, licenseService enterprise.LicenseService) *Syncer {return &Syncer{store: store,dbFactory: dbFactory,@@ -51,7 +51,7 @@ type Syncer struct {dbFactory *dbfactory.DBFactorystateCfg *state.Stateprofile config.Profile- licenseService enterpriseAPI.LicenseService+ licenseService enterprise.LicenseService}// Run will run the schema syncer once.diff --git a/backend/runner/taskrun/data_update_executor.go b/backend/runner/taskrun/data_update_executor.goindex 91a1022e6f..1a473c24f0 100644--- a/backend/runner/taskrun/data_update_executor.go+++ b/backend/runner/taskrun/data_update_executor.go@@ -13,7 +13,7 @@ import ("github.com/bytebase/bytebase/backend/component/config""github.com/bytebase/bytebase/backend/component/dbfactory""github.com/bytebase/bytebase/backend/component/state"- enterpriseAPI "github.com/bytebase/bytebase/backend/enterprise/api"+ enterprise "github.com/bytebase/bytebase/backend/enterprise/api"api "github.com/bytebase/bytebase/backend/legacyapi""github.com/bytebase/bytebase/backend/plugin/db"@@ -22,7 +22,7 @@ import ()// NewDataUpdateExecutor creates a data update (DML) task executor.-func NewDataUpdateExecutor(store *store.Store, dbFactory *dbfactory.DBFactory, activityManager *activity.Manager, license enterpriseAPI.LicenseService, stateCfg *state.State, profile config.Profile) Executor {+func NewDataUpdateExecutor(store *store.Store, dbFactory *dbfactory.DBFactory, activityManager *activity.Manager, license enterprise.LicenseService, stateCfg *state.State, profile config.Profile) Executor {return &DataUpdateExecutor{store: store,dbFactory: dbFactory,@@ -38,7 +38,7 @@ type DataUpdateExecutor struct {store *store.StoredbFactory *dbfactory.DBFactoryactivityManager *activity.Manager- license enterpriseAPI.LicenseService+ license enterprise.LicenseServicestateCfg *state.Stateprofile config.Profile}diff --git a/backend/runner/taskrun/executor.go b/backend/runner/taskrun/executor.goindex cd7f13463c..7855110e31 100644--- a/backend/runner/taskrun/executor.go+++ b/backend/runner/taskrun/executor.go@@ -19,7 +19,7 @@ import ("github.com/bytebase/bytebase/backend/component/config""github.com/bytebase/bytebase/backend/component/dbfactory""github.com/bytebase/bytebase/backend/component/state"- enterpriseAPI "github.com/bytebase/bytebase/backend/enterprise/api"+ enterprise "github.com/bytebase/bytebase/backend/enterprise/api"api "github.com/bytebase/bytebase/backend/legacyapi""github.com/bytebase/bytebase/backend/plugin/db""github.com/bytebase/bytebase/backend/plugin/db/mysql"@@ -386,7 +386,7 @@ func setMigrationIDAndEndBinlogCoordinate(ctx context.Context, conn *sql.Conn, treturn updatedTask, nil}-func postMigration(ctx context.Context, stores *store.Store, activityManager *activity.Manager, license enterpriseAPI.LicenseService, task *store.TaskMessage, mi *db.MigrationInfo, migrationID string, schema string, sheetID *int) (bool, *api.TaskRunResultPayload, error) {+func postMigration(ctx context.Context, stores *store.Store, activityManager *activity.Manager, license enterprise.LicenseService, task *store.TaskMessage, mi *db.MigrationInfo, migrationID string, schema string, sheetID *int) (bool, *api.TaskRunResultPayload, error) {instance, err := stores.GetInstanceV2(ctx, &store.FindInstanceMessage{UID: &task.InstanceID})if err != nil {return true, nil, err@@ -570,7 +570,7 @@ func postMigration(ctx context.Context, stores *store.Store, activityManager *ac}, nil}-func isWriteBack(ctx context.Context, stores *store.Store, license enterpriseAPI.LicenseService, project *store.ProjectMessage, repo *store.RepositoryMessage, task *store.TaskMessage) (string, error) {+func isWriteBack(ctx context.Context, stores *store.Store, license enterprise.LicenseService, project *store.ProjectMessage, repo *store.RepositoryMessage, task *store.TaskMessage) (string, error) {if task.Type != api.TaskDatabaseSchemaBaseline && task.Type != api.TaskDatabaseSchemaUpdate && task.Type != api.TaskDatabaseSchemaUpdateGhostCutover {return "", nil}@@ -633,7 +633,7 @@ func isWriteBack(ctx context.Context, stores *store.Store, license enterpriseAPIreturn branch, nil}-func runMigration(ctx context.Context, driverCtx context.Context, store *store.Store, dbFactory *dbfactory.DBFactory, activityManager *activity.Manager, license enterpriseAPI.LicenseService, stateCfg *state.State, profile config.Profile, task *store.TaskMessage, taskRunUID int, migrationType db.MigrationType, statement string, schemaVersion model.Version, sheetID *int) (terminated bool, result *api.TaskRunResultPayload, err error) {+func runMigration(ctx context.Context, driverCtx context.Context, store *store.Store, dbFactory *dbfactory.DBFactory, activityManager *activity.Manager, license enterprise.LicenseService, stateCfg *state.State, profile config.Profile, task *store.TaskMessage, taskRunUID int, migrationType db.MigrationType, statement string, schemaVersion model.Version, sheetID *int) (terminated bool, result *api.TaskRunResultPayload, err error) {mi, err := getMigrationInfo(ctx, store, profile, task, migrationType, statement, schemaVersion)if err != nil {return true, nil, errdiff --git a/backend/runner/taskrun/schema_baseline_executor.go b/backend/runner/taskrun/schema_baseline_executor.goindex 33d8050c64..4146647257 100644--- a/backend/runner/taskrun/schema_baseline_executor.go+++ b/backend/runner/taskrun/schema_baseline_executor.go@@ -13,7 +13,7 @@ import ("github.com/bytebase/bytebase/backend/component/config""github.com/bytebase/bytebase/backend/component/dbfactory""github.com/bytebase/bytebase/backend/component/state"- enterpriseAPI "github.com/bytebase/bytebase/backend/enterprise/api"+ enterprise "github.com/bytebase/bytebase/backend/enterprise/api"api "github.com/bytebase/bytebase/backend/legacyapi""github.com/bytebase/bytebase/backend/plugin/db""github.com/bytebase/bytebase/backend/runner/schemasync"@@ -23,7 +23,7 @@ import ()// NewSchemaBaselineExecutor creates a schema baseline task executor.-func NewSchemaBaselineExecutor(store *store.Store, dbFactory *dbfactory.DBFactory, activityManager *activity.Manager, license enterpriseAPI.LicenseService, stateCfg *state.State, schemaSyncer *schemasync.Syncer, profile config.Profile) Executor {+func NewSchemaBaselineExecutor(store *store.Store, dbFactory *dbfactory.DBFactory, activityManager *activity.Manager, license enterprise.LicenseService, stateCfg *state.State, schemaSyncer *schemasync.Syncer, profile config.Profile) Executor {return &SchemaBaselineExecutor{store: store,dbFactory: dbFactory,@@ -40,7 +40,7 @@ type SchemaBaselineExecutor struct {store *store.StoredbFactory *dbfactory.DBFactoryactivityManager *activity.Manager- license enterpriseAPI.LicenseService+ license enterprise.LicenseServicestateCfg *state.StateschemaSyncer *schemasync.Syncerprofile config.Profilediff --git a/backend/runner/taskrun/schema_update_executor.go b/backend/runner/taskrun/schema_update_executor.goindex d0f9bc139f..8b39795113 100644--- a/backend/runner/taskrun/schema_update_executor.go+++ b/backend/runner/taskrun/schema_update_executor.go@@ -13,7 +13,7 @@ import ("github.com/bytebase/bytebase/backend/component/config""github.com/bytebase/bytebase/backend/component/dbfactory""github.com/bytebase/bytebase/backend/component/state"- enterpriseAPI "github.com/bytebase/bytebase/backend/enterprise/api"+ enterprise "github.com/bytebase/bytebase/backend/enterprise/api"api "github.com/bytebase/bytebase/backend/legacyapi""github.com/bytebase/bytebase/backend/plugin/db""github.com/bytebase/bytebase/backend/runner/schemasync"@@ -23,7 +23,7 @@ import ()// NewSchemaUpdateExecutor creates a schema update (DDL) task executor.-func NewSchemaUpdateExecutor(store *store.Store, dbFactory *dbfactory.DBFactory, activityManager *activity.Manager, license enterpriseAPI.LicenseService, stateCfg *state.State, schemaSyncer *schemasync.Syncer, profile config.Profile) Executor {+func NewSchemaUpdateExecutor(store *store.Store, dbFactory *dbfactory.DBFactory, activityManager *activity.Manager, license enterprise.LicenseService, stateCfg *state.State, schemaSyncer *schemasync.Syncer, profile config.Profile) Executor {return &SchemaUpdateExecutor{store: store,dbFactory: dbFactory,@@ -40,7 +40,7 @@ type SchemaUpdateExecutor struct {store *store.StoredbFactory *dbfactory.DBFactoryactivityManager *activity.Manager- license enterpriseAPI.LicenseService+ license enterprise.LicenseServicestateCfg *state.StateschemaSyncer *schemasync.Syncerprofile config.Profilediff --git a/backend/runner/taskrun/schema_update_ghost_cutover_executor.go b/backend/runner/taskrun/schema_update_ghost_cutover_executor.goindex 18a2973e92..7c8b17927c 100644--- a/backend/runner/taskrun/schema_update_ghost_cutover_executor.go+++ b/backend/runner/taskrun/schema_update_ghost_cutover_executor.go@@ -18,7 +18,7 @@ import ("github.com/bytebase/bytebase/backend/component/config""github.com/bytebase/bytebase/backend/component/dbfactory""github.com/bytebase/bytebase/backend/component/state"- enterpriseAPI "github.com/bytebase/bytebase/backend/enterprise/api"+ enterprise "github.com/bytebase/bytebase/backend/enterprise/api"api "github.com/bytebase/bytebase/backend/legacyapi""github.com/bytebase/bytebase/backend/plugin/db""github.com/bytebase/bytebase/backend/runner/schemasync"@@ -29,7 +29,7 @@ import ()// NewSchemaUpdateGhostCutoverExecutor creates a schema update (gh-ost) cutover task executor.-func NewSchemaUpdateGhostCutoverExecutor(store *store.Store, dbFactory *dbfactory.DBFactory, activityManager *activity.Manager, license enterpriseAPI.LicenseService, stateCfg *state.State, schemaSyncer *schemasync.Syncer, profile config.Profile) Executor {+func NewSchemaUpdateGhostCutoverExecutor(store *store.Store, dbFactory *dbfactory.DBFactory, activityManager *activity.Manager, license enterprise.LicenseService, stateCfg *state.State, schemaSyncer *schemasync.Syncer, profile config.Profile) Executor {return &SchemaUpdateGhostCutoverExecutor{store: store,dbFactory: dbFactory,@@ -46,7 +46,7 @@ type SchemaUpdateGhostCutoverExecutor struct {store *store.StoredbFactory *dbfactory.DBFactoryactivityManager *activity.Manager- license enterpriseAPI.LicenseService+ license enterprise.LicenseServicestateCfg *state.StateschemaSyncer *schemasync.Syncerprofile config.Profile@@ -119,7 +119,7 @@ func (e *SchemaUpdateGhostCutoverExecutor) RunOnce(ctx context.Context, _ contexreturn terminated, result, err}-func cutover(ctx context.Context, stores *store.Store, dbFactory *dbfactory.DBFactory, activityManager *activity.Manager, stateCfg *state.State, license enterpriseAPI.LicenseService, profile config.Profile, task *store.TaskMessage, taskRunUID int, statement string, sheetID int, schemaVersion model.Version, postponeFilename string, migrationContext *base.MigrationContext, errCh <-chan error) (terminated bool, result *api.TaskRunResultPayload, err error) {+func cutover(ctx context.Context, stores *store.Store, dbFactory *dbfactory.DBFactory, activityManager *activity.Manager, stateCfg *state.State, license enterprise.LicenseService, profile config.Profile, task *store.TaskMessage, taskRunUID int, statement string, sheetID int, schemaVersion model.Version, postponeFilename string, migrationContext *base.MigrationContext, errCh <-chan error) (terminated bool, result *api.TaskRunResultPayload, err error) {statement = strings.TrimSpace(statement)instance, err := stores.GetInstanceV2(ctx, &store.FindInstanceMessage{UID: &task.InstanceID})if err != nil {diff --git a/backend/runner/taskrun/schema_update_sdl_executor.go b/backend/runner/taskrun/schema_update_sdl_executor.goindex ceda0722fa..d24077d1af 100644--- a/backend/runner/taskrun/schema_update_sdl_executor.go+++ b/backend/runner/taskrun/schema_update_sdl_executor.go@@ -13,7 +13,7 @@ import ("github.com/bytebase/bytebase/backend/component/config""github.com/bytebase/bytebase/backend/component/dbfactory""github.com/bytebase/bytebase/backend/component/state"- enterpriseAPI "github.com/bytebase/bytebase/backend/enterprise/api"+ enterprise "github.com/bytebase/bytebase/backend/enterprise/api"api "github.com/bytebase/bytebase/backend/legacyapi""github.com/bytebase/bytebase/backend/plugin/db""github.com/bytebase/bytebase/backend/runner/schemasync"@@ -25,7 +25,7 @@ import ()// NewSchemaUpdateSDLExecutor creates a schema update (SDL) task executor.-func NewSchemaUpdateSDLExecutor(store *store.Store, dbFactory *dbfactory.DBFactory, activityManager *activity.Manager, license enterpriseAPI.LicenseService, stateCfg *state.State, schemaSyncer *schemasync.Syncer, profile config.Profile) Executor {+func NewSchemaUpdateSDLExecutor(store *store.Store, dbFactory *dbfactory.DBFactory, activityManager *activity.Manager, license enterprise.LicenseService, stateCfg *state.State, schemaSyncer *schemasync.Syncer, profile config.Profile) Executor {return &SchemaUpdateSDLExecutor{store: store,dbFactory: dbFactory,@@ -42,7 +42,7 @@ type SchemaUpdateSDLExecutor struct {store *store.StoredbFactory *dbfactory.DBFactoryactivityManager *activity.Manager- license enterpriseAPI.LicenseService+ license enterprise.LicenseServicestateCfg *state.StateschemaSyncer *schemasync.Syncerprofile config.Profilediff --git a/backend/server/grpc_routes.go b/backend/server/grpc_routes.goindex 26aeb99503..c6f24d8cc5 100644--- a/backend/server/grpc_routes.go+++ b/backend/server/grpc_routes.go@@ -8,14 +8,14 @@ import ("google.golang.org/grpc""google.golang.org/grpc/credentials/insecure"- grpcRuntime "github.com/grpc-ecosystem/grpc-gateway/v2/runtime"+ grpcruntime "github.com/grpc-ecosystem/grpc-gateway/v2/runtime"- v1 "github.com/bytebase/bytebase/backend/api/v1"+ apiv1 "github.com/bytebase/bytebase/backend/api/v1""github.com/bytebase/bytebase/backend/component/activity""github.com/bytebase/bytebase/backend/component/config""github.com/bytebase/bytebase/backend/component/dbfactory""github.com/bytebase/bytebase/backend/component/state"- enterpriseAPI "github.com/bytebase/bytebase/backend/enterprise/api"+ enterprise "github.com/bytebase/bytebase/backend/enterprise/api"api "github.com/bytebase/bytebase/backend/legacyapi""github.com/bytebase/bytebase/backend/runner/backuprun""github.com/bytebase/bytebase/backend/runner/metricreport"@@ -28,11 +28,11 @@ import (func configureGrpcRouters(ctx context.Context,- mux *grpcRuntime.ServeMux,+ mux *grpcruntime.ServeMux,grpcServer *grpc.Server,stores *store.Store,dbFactory *dbfactory.DBFactory,- licenseService enterpriseAPI.LicenseService,+ licenseService enterprise.LicenseService,profile *config.Profile,metricReporter *metricreport.Reporter,stateCfg *state.State,@@ -41,24 +41,24 @@ func configureGrpcRouters(backupRunner *backuprun.Runner,relayRunner *relay.Runner,planCheckScheduler *plancheck.Scheduler,- postCreateUser v1.CreateUserFunc,+ postCreateUser apiv1.CreateUserFunc,secret string,errorRecordRing *api.ErrorRecordRing,- tokenDuration time.Duration) (*v1.RolloutService, *v1.IssueService, error) {+ tokenDuration time.Duration) (*apiv1.RolloutService, *apiv1.IssueService, error) {// Register services.- authService, err := v1.NewAuthService(stores, secret, tokenDuration, licenseService, metricReporter, profile, stateCfg, postCreateUser)+ authService, err := apiv1.NewAuthService(stores, secret, tokenDuration, licenseService, metricReporter, profile, stateCfg, postCreateUser)if err != nil {return nil, nil, err}v1pb.RegisterAuthServiceServer(grpcServer, authService)- v1pb.RegisterActuatorServiceServer(grpcServer, v1.NewActuatorService(stores, profile, errorRecordRing))- v1pb.RegisterSubscriptionServiceServer(grpcServer, v1.NewSubscriptionService(+ v1pb.RegisterActuatorServiceServer(grpcServer, apiv1.NewActuatorService(stores, profile, errorRecordRing))+ v1pb.RegisterSubscriptionServiceServer(grpcServer, apiv1.NewSubscriptionService(stores,profile,metricReporter,licenseService))- v1pb.RegisterEnvironmentServiceServer(grpcServer, v1.NewEnvironmentService(stores, licenseService))- v1pb.RegisterInstanceServiceServer(grpcServer, v1.NewInstanceService(+ v1pb.RegisterEnvironmentServiceServer(grpcServer, apiv1.NewEnvironmentService(stores, licenseService))+ v1pb.RegisterInstanceServiceServer(grpcServer, apiv1.NewInstanceService(stores,licenseService,metricReporter,@@ -66,28 +66,28 @@ func configureGrpcRouters(stateCfg,dbFactory,schemaSyncer))- v1pb.RegisterProjectServiceServer(grpcServer, v1.NewProjectService(stores, activityManager, licenseService))- v1pb.RegisterDatabaseServiceServer(grpcServer, v1.NewDatabaseService(stores, backupRunner, schemaSyncer, licenseService, profile))- v1pb.RegisterInstanceRoleServiceServer(grpcServer, v1.NewInstanceRoleService(stores, dbFactory))- v1pb.RegisterOrgPolicyServiceServer(grpcServer, v1.NewOrgPolicyService(stores, licenseService))- v1pb.RegisterIdentityProviderServiceServer(grpcServer, v1.NewIdentityProviderService(stores, licenseService))- v1pb.RegisterSettingServiceServer(grpcServer, v1.NewSettingService(stores, profile, licenseService, stateCfg))- v1pb.RegisterAnomalyServiceServer(grpcServer, v1.NewAnomalyService(stores))- v1pb.RegisterSQLServiceServer(grpcServer, v1.NewSQLService(stores, schemaSyncer, dbFactory, activityManager, licenseService))- v1pb.RegisterExternalVersionControlServiceServer(grpcServer, v1.NewExternalVersionControlService(stores))- v1pb.RegisterRiskServiceServer(grpcServer, v1.NewRiskService(stores, licenseService))- issueService := v1.NewIssueService(stores, activityManager, relayRunner, stateCfg, licenseService, metricReporter)+ v1pb.RegisterProjectServiceServer(grpcServer, apiv1.NewProjectService(stores, activityManager, licenseService))+ v1pb.RegisterDatabaseServiceServer(grpcServer, apiv1.NewDatabaseService(stores, backupRunner, schemaSyncer, licenseService, profile))+ v1pb.RegisterInstanceRoleServiceServer(grpcServer, apiv1.NewInstanceRoleService(stores, dbFactory))+ v1pb.RegisterOrgPolicyServiceServer(grpcServer, apiv1.NewOrgPolicyService(stores, licenseService))+ v1pb.RegisterIdentityProviderServiceServer(grpcServer, apiv1.NewIdentityProviderService(stores, licenseService))+ v1pb.RegisterSettingServiceServer(grpcServer, apiv1.NewSettingService(stores, profile, licenseService, stateCfg))+ v1pb.RegisterAnomalyServiceServer(grpcServer, apiv1.NewAnomalyService(stores))+ v1pb.RegisterSQLServiceServer(grpcServer, apiv1.NewSQLService(stores, schemaSyncer, dbFactory, activityManager, licenseService))+ v1pb.RegisterExternalVersionControlServiceServer(grpcServer, apiv1.NewExternalVersionControlService(stores))+ v1pb.RegisterRiskServiceServer(grpcServer, apiv1.NewRiskService(stores, licenseService))+ issueService := apiv1.NewIssueService(stores, activityManager, relayRunner, stateCfg, licenseService, metricReporter)v1pb.RegisterIssueServiceServer(grpcServer, issueService)- rolloutService := v1.NewRolloutService(stores, licenseService, dbFactory, planCheckScheduler, stateCfg, activityManager)+ rolloutService := apiv1.NewRolloutService(stores, licenseService, dbFactory, planCheckScheduler, stateCfg, activityManager)v1pb.RegisterRolloutServiceServer(grpcServer, rolloutService)- v1pb.RegisterRoleServiceServer(grpcServer, v1.NewRoleService(stores, licenseService))- v1pb.RegisterSheetServiceServer(grpcServer, v1.NewSheetService(stores, licenseService))- v1pb.RegisterSchemaDesignServiceServer(grpcServer, v1.NewSchemaDesignService(stores, licenseService))- v1pb.RegisterCelServiceServer(grpcServer, v1.NewCelService())- v1pb.RegisterLoggingServiceServer(grpcServer, v1.NewLoggingService(stores))- v1pb.RegisterBookmarkServiceServer(grpcServer, v1.NewBookmarkService(stores))- v1pb.RegisterInboxServiceServer(grpcServer, v1.NewInboxService(stores))- v1pb.RegisterChangelistServiceServer(grpcServer, v1.NewChangelistService(stores))+ v1pb.RegisterRoleServiceServer(grpcServer, apiv1.NewRoleService(stores, licenseService))+ v1pb.RegisterSheetServiceServer(grpcServer, apiv1.NewSheetService(stores, licenseService))+ v1pb.RegisterSchemaDesignServiceServer(grpcServer, apiv1.NewSchemaDesignService(stores, licenseService))+ v1pb.RegisterCelServiceServer(grpcServer, apiv1.NewCelService())+ v1pb.RegisterLoggingServiceServer(grpcServer, apiv1.NewLoggingService(stores))+ v1pb.RegisterBookmarkServiceServer(grpcServer, apiv1.NewBookmarkService(stores))+ v1pb.RegisterInboxServiceServer(grpcServer, apiv1.NewInboxService(stores))+ v1pb.RegisterChangelistServiceServer(grpcServer, apiv1.NewChangelistService(stores))// REST gateway proxy.grpcEndpoint := fmt.Sprintf(":%d", profile.GrpcPort)diff --git a/backend/server/init.go b/backend/server/init.goindex 6865168170..5ae79d5d66 100644--- a/backend/server/init.go+++ b/backend/server/init.go@@ -12,7 +12,7 @@ import ("github.com/bytebase/bytebase/backend/common"api "github.com/bytebase/bytebase/backend/legacyapi""github.com/bytebase/bytebase/backend/metric"- metricCollector "github.com/bytebase/bytebase/backend/metric/collector"+ metriccollector "github.com/bytebase/bytebase/backend/metric/collector""github.com/bytebase/bytebase/backend/runner/metricreport""github.com/bytebase/bytebase/backend/store"storepb "github.com/bytebase/bytebase/proto/generated-go/store"@@ -214,13 +214,13 @@ func (s *Server) getInitSetting(ctx context.Context, datastore *store.Store) (st// initMetricReporter will initial the metric scheduler.func (s *Server) initMetricReporter() {metricReporter := metricreport.NewReporter(s.store, s.licenseService, &s.profile, s.profile.EnableMetric)- metricReporter.Register(metric.InstanceCountMetricName, metricCollector.NewInstanceCountCollector(s.store))- metricReporter.Register(metric.IssueCountMetricName, metricCollector.NewIssueCountCollector(s.store))- metricReporter.Register(metric.ProjectCountMetricName, metricCollector.NewProjectCountCollector(s.store))- metricReporter.Register(metric.PolicyCountMetricName, metricCollector.NewPolicyCountCollector(s.store))- metricReporter.Register(metric.TaskCountMetricName, metricCollector.NewTaskCountCollector(s.store))- metricReporter.Register(metric.DatabaseCountMetricName, metricCollector.NewDatabaseCountCollector(s.store))- metricReporter.Register(metric.SheetCountMetricName, metricCollector.NewSheetCountCollector(s.store))- metricReporter.Register(metric.MemberCountMetricName, metricCollector.NewMemberCountCollector(s.store))+ metricReporter.Register(metric.InstanceCountMetricName, metriccollector.NewInstanceCountCollector(s.store))+ metricReporter.Register(metric.IssueCountMetricName, metriccollector.NewIssueCountCollector(s.store))+ metricReporter.Register(metric.ProjectCountMetricName, metriccollector.NewProjectCountCollector(s.store))+ metricReporter.Register(metric.PolicyCountMetricName, metriccollector.NewPolicyCountCollector(s.store))+ metricReporter.Register(metric.TaskCountMetricName, metriccollector.NewTaskCountCollector(s.store))+ metricReporter.Register(metric.DatabaseCountMetricName, metriccollector.NewDatabaseCountCollector(s.store))+ metricReporter.Register(metric.SheetCountMetricName, metriccollector.NewSheetCountCollector(s.store))+ metricReporter.Register(metric.MemberCountMetricName, metriccollector.NewMemberCountCollector(s.store))s.metricReporter = metricReporter}diff --git a/backend/server/routers.go b/backend/server/routers.goindex 8bb40777b7..1cc551335b 100644--- a/backend/server/routers.go+++ b/backend/server/routers.go@@ -6,7 +6,7 @@ import ("strings""time"- grpcRuntime "github.com/grpc-ecosystem/grpc-gateway/v2/runtime"+ grpcruntime "github.com/grpc-ecosystem/grpc-gateway/v2/runtime""github.com/improbable-eng/grpc-web/go/grpcweb""github.com/labstack/echo-contrib/pprof""github.com/labstack/echo-contrib/prometheus"@@ -19,7 +19,7 @@ import ("github.com/bytebase/bytebase/backend/common/log")-func configureEchoRouters(e *echo.Echo, grpcServer *grpc.Server, mux *grpcRuntime.ServeMux) {+func configureEchoRouters(e *echo.Echo, grpcServer *grpc.Server, mux *grpcruntime.ServeMux) {// Embed frontend.embedFrontend(e)diff --git a/backend/server/server.go b/backend/server/server.goindex 0bf1b567a6..62ce4c3e4a 100644--- a/backend/server/server.go+++ b/backend/server/server.go@@ -9,7 +9,7 @@ import ("sync""time"- grpcRuntime "github.com/grpc-ecosystem/grpc-gateway/v2/runtime"+ grpcruntime "github.com/grpc-ecosystem/grpc-gateway/v2/runtime""github.com/labstack/echo/v4""github.com/pkg/errors""google.golang.org/grpc"@@ -21,15 +21,15 @@ import ("github.com/bytebase/bytebase/backend/api/auth""github.com/bytebase/bytebase/backend/api/gitops"- v1 "github.com/bytebase/bytebase/backend/api/v1"+ apiv1 "github.com/bytebase/bytebase/backend/api/v1""github.com/bytebase/bytebase/backend/common/log""github.com/bytebase/bytebase/backend/common/stacktrace""github.com/bytebase/bytebase/backend/component/activity""github.com/bytebase/bytebase/backend/component/config""github.com/bytebase/bytebase/backend/component/dbfactory""github.com/bytebase/bytebase/backend/component/state"- enterpriseAPI "github.com/bytebase/bytebase/backend/enterprise/api"- enterpriseService "github.com/bytebase/bytebase/backend/enterprise/service"+ enterprise "github.com/bytebase/bytebase/backend/enterprise/api"+ enterprisesvc "github.com/bytebase/bytebase/backend/enterprise/service"api "github.com/bytebase/bytebase/backend/legacyapi""github.com/bytebase/bytebase/backend/migrator"dbdriver "github.com/bytebase/bytebase/backend/plugin/db"@@ -75,7 +75,7 @@ type Server struct {activityManager *activity.Manager- licenseService enterpriseAPI.LicenseService+ licenseService enterprise.LicenseServiceprofile config.Profilee *echo.Echo@@ -87,8 +87,8 @@ type Server struct {errorRecordRing api.ErrorRecordRing// Stubs.- rolloutService *v1.RolloutService- issueService *v1.IssueService+ rolloutService *apiv1.RolloutService+ issueService *apiv1.IssueService// MySQL utility binariesmysqlBinDir string@@ -213,7 +213,7 @@ func NewServer(ctx context.Context, profile config.Profile) (*Server, error) {slog.Warn("failed to backfill issue ts vector", log.BBError(err))}- s.licenseService, err = enterpriseService.NewLicenseService(profile.Mode, storeInstance)+ s.licenseService, err = enterprisesvc.NewLicenseService(profile.Mode, storeInstance)if err != nil {return nil, errors.Wrap(err, "failed to create license service")}@@ -234,7 +234,7 @@ func NewServer(ctx context.Context, profile config.Profile) (*Server, error) {// Note: the gateway response modifier takes the external url on server startup. If the external URL is changed,// the user has to restart the server to take the latest value.gatewayModifier := auth.GatewayResponseModifier{ExternalURL: externalURL, TokenDuration: tokenDuration}- mux := grpcRuntime.NewServeMux(grpcRuntime.WithForwardResponseOption(gatewayModifier.Modify))+ mux := grpcruntime.NewServeMux(grpcruntime.WithForwardResponseOption(gatewayModifier.Modify))if profile.BackupBucket != "" {credentials, err := bbs3.GetCredentialsFromFile(ctx, profile.BackupCredentialFile)@@ -291,8 +291,8 @@ func NewServer(ctx context.Context, profile config.Profile) (*Server, error) {// Setup the gRPC and grpc-gateway.authProvider := auth.New(s.store, s.secret, tokenDuration, s.licenseService, s.stateCfg, profile.Mode)- aclProvider := v1.NewACLInterceptor(s.store, s.secret, s.licenseService, profile.Mode)- debugProvider := v1.NewDebugInterceptor(&s.errorRecordRing, &profile, s.metricReporter)+ aclProvider := apiv1.NewACLInterceptor(s.store, s.secret, s.licenseService, profile.Mode)+ debugProvider := apiv1.NewDebugInterceptor(&s.errorRecordRing, &profile, s.metricReporter)onPanic := func(p any) error {stack := stacktrace.TakeStacktrace(20 /* n */, 5 /* skip */)// keep a multiline stackdiff --git a/backend/sql-server/server.go b/backend/sql-server/server.goindex 5c474b9a29..549b42e6e1 100644--- a/backend/sql-server/server.go+++ b/backend/sql-server/server.go@@ -8,7 +8,7 @@ import ("net/http""time"- echoSwagger "github.com/swaggo/echo-swagger"+ echoswagger "github.com/swaggo/echo-swagger""github.com/bytebase/bytebase/backend/plugin/metric/segment"_ "github.com/bytebase/bytebase/docs/sqlservice" // initial the swagger doc@@ -90,7 +90,7 @@ func NewServer(ctx context.Context, prof Profile) (*Server, error) {}))}e.Use(middleware.RecoverWithConfig(middleware.RecoverConfig{}))- e.GET("/swagger/*", echoSwagger.WrapHandler)+ e.GET("/swagger/*", echoswagger.WrapHandler)apiGroup := e.Group("/v1")apiGroup.Use(func(next echo.HandlerFunc) echo.HandlerFunc {diff --git a/backend/store/database.go b/backend/store/database.goindex 717992e928..054e0d52a3 100644--- a/backend/store/database.go+++ b/backend/store/database.go@@ -73,12 +73,16 @@ type FindDatabaseMessage struct {func (s *Store) GetDatabaseV2(ctx context.Context, find *FindDatabaseMessage) (*DatabaseMessage, error) {if find.InstanceID != nil && find.DatabaseName != nil {if database, ok := s.databaseCache.Load(getDatabaseCacheKey(*find.InstanceID, *find.DatabaseName)); ok {- return database.(*DatabaseMessage), nil+ if db, ok := database.(*DatabaseMessage); ok {+ return db, nil+ }}}if find.UID != nil {if database, ok := s.databaseIDCache.Load(*find.UID); ok {- return database.(*DatabaseMessage), nil+ if v, ok := database.(*DatabaseMessage); ok {+ return v, nil+ }}}diff --git a/backend/store/database_group.go b/backend/store/database_group.goindex e1f48c86cb..c3336b67de 100644--- a/backend/store/database_group.go+++ b/backend/store/database_group.go@@ -101,12 +101,16 @@ func (s *Store) ListDatabaseGroups(ctx context.Context, find *FindDatabaseGroupMfunc (s *Store) GetDatabaseGroup(ctx context.Context, find *FindDatabaseGroupMessage) (*DatabaseGroupMessage, error) {if find.ProjectUID != nil && find.ResourceID != nil && find.UID == nil {if databaseGroup, ok := s.databaseGroupCache.Load(getDatabaseGroupCacheKey(*find.ProjectUID, *find.ResourceID)); ok {- return databaseGroup.(*DatabaseGroupMessage), nil+ if v, ok := databaseGroup.(*DatabaseGroupMessage); ok {+ return v, nil+ }}}if find.UID != nil && find.ProjectUID == nil && find.ResourceID == nil {if databaseGroup, ok := s.databaseGroupIDCache.Load(*find.UID); ok {- return databaseGroup.(*DatabaseGroupMessage), nil+ if v, ok := databaseGroup.(*DatabaseGroupMessage); ok {+ return v, nil+ }}}@@ -398,7 +402,9 @@ func (s *Store) ListSchemaGroups(ctx context.Context, find *FindSchemaGroupMessafunc (s *Store) GetSchemaGroup(ctx context.Context, find *FindSchemaGroupMessage) (*SchemaGroupMessage, error) {if find.DatabaseGroupUID != nil && find.ResourceID != nil {if schemaGroup, ok := s.schemaGroupCache.Load(getSchemaGroupCacheKey(*find.DatabaseGroupUID, *find.ResourceID)); ok {- return schemaGroup.(*SchemaGroupMessage), nil+ if v, ok := schemaGroup.(*SchemaGroupMessage); ok {+ return v, nil+ }}}tx, err := s.db.BeginTx(ctx, &sql.TxOptions{ReadOnly: true})diff --git a/backend/store/db_schema.go b/backend/store/db_schema.goindex 86b8b543c4..86c6554f0f 100644--- a/backend/store/db_schema.go+++ b/backend/store/db_schema.go@@ -153,7 +153,9 @@ func (s *Store) GetDBSchema(ctx context.Context, databaseID int) (*DBSchema, err})if s.dbSchemaCache.MaxCost() != 1_000_000 || instanceCount <= 10 {if dbSchema, ok := s.dbSchemaCache.Get(databaseID); ok {- return dbSchema.(*DBSchema), nil+ if v, ok := dbSchema.(*DBSchema); ok {+ return v, nil+ }}}diff --git a/backend/store/deploy.go b/backend/store/deploy.goindex edb477460c..31213d572c 100644--- a/backend/store/deploy.go+++ b/backend/store/deploy.go@@ -129,7 +129,9 @@ func (s *Store) GetDeploymentConfigV2(ctx context.Context, projectUID int) (*Dep}if deploymentConfig, ok := s.projectIDDeploymentConfigCache.Load(projectUID); ok {- return deploymentConfig.(*DeploymentConfigMessage), nil+ if v, ok := deploymentConfig.(*DeploymentConfigMessage); ok {+ return v, nil+ }}where, args := []string{"TRUE"}, []any{}where, args = append(where, fmt.Sprintf("project_id = $%d", len(args)+1)), append(args, projectUID)diff --git a/backend/store/environment.go b/backend/store/environment.goindex c2ad601d5b..b30a4ddd2d 100644--- a/backend/store/environment.go+++ b/backend/store/environment.go@@ -45,12 +45,16 @@ type UpdateEnvironmentMessage struct {func (s *Store) GetEnvironmentV2(ctx context.Context, find *FindEnvironmentMessage) (*EnvironmentMessage, error) {if find.ResourceID != nil {if environment, ok := s.environmentCache.Load(*find.ResourceID); ok {- return environment.(*EnvironmentMessage), nil+ if v, ok := environment.(*EnvironmentMessage); ok {+ return v, nil+ }}}if find.UID != nil {if environment, ok := s.environmentIDCache.Load(*find.UID); ok {- return environment.(*EnvironmentMessage), nil+ if v, ok := environment.(*EnvironmentMessage); ok {+ return v, nil+ }}}diff --git a/backend/store/idp.go b/backend/store/idp.goindex 8a7556c64f..4a54fb6301 100644--- a/backend/store/idp.go+++ b/backend/store/idp.go@@ -35,9 +35,8 @@ func getConfigBytes(config *storepb.IdentityProviderConfig) ([]byte, error) {} else if v := config.GetLdapConfig(); v != nil {configBytes, err := protojson.Marshal(v)return configBytes, err- } else {- return nil, errors.Errorf("unexpected provider type")}+ return nil, errors.Errorf("unexpected provider type")}// FindIdentityProviderMessage is the message for finding identity providers.@@ -115,7 +114,9 @@ func (s *Store) CreateIdentityProvider(ctx context.Context, create *IdentityProvfunc (s *Store) GetIdentityProvider(ctx context.Context, find *FindIdentityProviderMessage) (*IdentityProviderMessage, error) {if find.ResourceID != nil {if identityProvider, ok := s.idpCache.Load(*find.ResourceID); ok {- return identityProvider.(*IdentityProviderMessage), nil+ if v, ok := identityProvider.(*IdentityProviderMessage); ok {+ return v, nil+ }}}// We will always return the resource regardless of its deleted state.diff --git a/backend/store/instance.go b/backend/store/instance.goindex 51e1ee1c5c..426c1bd622 100644--- a/backend/store/instance.go+++ b/backend/store/instance.go@@ -64,12 +64,16 @@ type FindInstanceMessage struct {func (s *Store) GetInstanceV2(ctx context.Context, find *FindInstanceMessage) (*InstanceMessage, error) {if find.ResourceID != nil {if instance, ok := s.instanceCache.Load(getInstanceCacheKey(*find.ResourceID)); ok {- return instance.(*InstanceMessage), nil+ if v, ok := instance.(*InstanceMessage); ok {+ return v, nil+ }}}if find.UID != nil {if instance, ok := s.instanceIDCache.Load(*find.UID); ok {- return instance.(*InstanceMessage), nil+ if v, ok := instance.(*InstanceMessage); ok {+ return v, nil+ }}}diff --git a/backend/store/issue.go b/backend/store/issue.goindex 49dfd93fc9..45fd099238 100644--- a/backend/store/issue.go+++ b/backend/store/issue.go@@ -107,12 +107,16 @@ type FindIssueMessage struct {func (s *Store) GetIssueV2(ctx context.Context, find *FindIssueMessage) (*IssueMessage, error) {if find.UID != nil {if issue, ok := s.issueCache.Load(*find.UID); ok {- return issue.(*IssueMessage), nil+ if v, ok := issue.(*IssueMessage); ok {+ return v, nil+ }}}if find.PipelineID != nil {if issue, ok := s.issueByPipelineCache.Load(*find.PipelineID); ok {- return issue.(*IssueMessage), nil+ if v, ok := issue.(*IssueMessage); ok {+ return v, nil+ }}}diff --git a/backend/store/pipeline.go b/backend/store/pipeline.goindex 84728b9e05..922906f3d3 100644--- a/backend/store/pipeline.go+++ b/backend/store/pipeline.go@@ -77,7 +77,9 @@ func (s *Store) CreatePipelineV2(ctx context.Context, create *PipelineMessage, c// GetPipelineV2ByID gets the pipeline by ID.func (s *Store) GetPipelineV2ByID(ctx context.Context, id int) (*PipelineMessage, error) {if pipeline, ok := s.pipelineCache.Load(id); ok {- return pipeline.(*PipelineMessage), nil+ if v, ok := pipeline.(*PipelineMessage); ok {+ return v, nil+ }}pipelines, err := s.ListPipelineV2(ctx, &PipelineFind{ID: &id})if err != nil {diff --git a/backend/store/policy.go b/backend/store/policy.goindex a36989e0c2..e5a7d6e4d3 100644--- a/backend/store/policy.go+++ b/backend/store/policy.go@@ -217,7 +217,9 @@ func (s *Store) GetPolicyV2(ctx context.Context, find *FindPolicyMessage) (*Poliif policy == nil {return nil, nil}- return policy.(*PolicyMessage), nil+ if v, ok := policy.(*PolicyMessage); ok {+ return v, nil+ }}}diff --git a/backend/store/principal.go b/backend/store/principal.goindex ea58d29e25..d23f5e11d4 100644--- a/backend/store/principal.go+++ b/backend/store/principal.go@@ -113,7 +113,9 @@ func (s *Store) ListUsers(ctx context.Context, find *FindUserMessage) ([]*UserMe// GetUserByID gets the user by ID.func (s *Store) GetUserByID(ctx context.Context, id int) (*UserMessage, error) {if user, ok := s.userIDCache.Load(id); ok {- return user.(*UserMessage), nil+ if v, ok := user.(*UserMessage); ok {+ return v, nil+ }}tx, err := s.db.BeginTx(ctx, nil)diff --git a/backend/store/project.go b/backend/store/project.goindex 44d6e1d6ff..a78b055ade 100644--- a/backend/store/project.go+++ b/backend/store/project.go@@ -59,12 +59,16 @@ type UpdateProjectMessage struct {func (s *Store) GetProjectV2(ctx context.Context, find *FindProjectMessage) (*ProjectMessage, error) {if find.ResourceID != nil {if project, ok := s.projectCache.Load(*find.ResourceID); ok {- return project.(*ProjectMessage), nil+ if v, ok := project.(*ProjectMessage); ok {+ return v, nil+ }}}if find.UID != nil {if project, ok := s.projectIDCache.Load(*find.UID); ok {- return project.(*ProjectMessage), nil+ if v, ok := project.(*ProjectMessage); ok {+ return v, nil+ }}}diff --git a/backend/store/project_member.go b/backend/store/project_member.goindex 0405886734..d69a51f3ab 100644--- a/backend/store/project_member.go+++ b/backend/store/project_member.go@@ -118,12 +118,16 @@ func (s *Store) GetProjectPolicy(ctx context.Context, find *GetProjectPolicyMess}if find.ProjectID != nil {if policy, ok := s.projectPolicyCache.Load(*find.ProjectID); ok {- return policy.(*IAMPolicyMessage), nil+ if v, ok := policy.(*IAMPolicyMessage); ok {+ return v, nil+ }}}if find.UID != nil {if policy, ok := s.projectIDPolicyCache.Load(*find.UID); ok {- return policy.(*IAMPolicyMessage), nil+ if v, ok := policy.(*IAMPolicyMessage); ok {+ return v, nil+ }}}diff --git a/backend/store/risk.go b/backend/store/risk.goindex ecdc21406f..b9a8e10b7e 100644--- a/backend/store/risk.go+++ b/backend/store/risk.go@@ -110,7 +110,9 @@ func (s *Store) GetRisk(ctx context.Context, id int64) (*RiskMessage, error) {// returned risks are sorted by source, level DESC, id.func (s *Store) ListRisks(ctx context.Context) ([]*RiskMessage, error) {if risks, ok := s.risksCache.Load(0); ok {- return risks.([]*RiskMessage), nil+ if v, ok := risks.([]*RiskMessage); ok {+ return v, nil+ }}query := `diff --git a/backend/store/setting.go b/backend/store/setting.goindex 7b9e663e8e..8a9ad70a95 100644--- a/backend/store/setting.go+++ b/backend/store/setting.go@@ -162,7 +162,9 @@ func (s *Store) DeleteCache() {func (s *Store) GetSettingV2(ctx context.Context, find *FindSettingMessage) (*SettingMessage, error) {if find.Name != nil && !find.Enforce {if setting, ok := s.settingCache.Load(*find.Name); ok {- return setting.(*SettingMessage), nil+ if v, ok := setting.(*SettingMessage); ok {+ return v, nil+ }}}@@ -256,7 +258,9 @@ func (s *Store) UpsertSettingV2(ctx context.Context, update *SetSettingMessage,// CreateSettingIfNotExistV2 creates a new setting only if the named setting doesn't exist.func (s *Store) CreateSettingIfNotExistV2(ctx context.Context, create *SettingMessage, principalUID int) (*SettingMessage, bool, error) {if setting, ok := s.settingCache.Load(create.Name); ok {- return setting.(*SettingMessage), false, nil+ if v, ok := setting.(*SettingMessage); ok {+ return v, false, nil+ }}tx, err := s.db.BeginTx(ctx, nil)diff --git a/backend/store/sheet.go b/backend/store/sheet.goindex 1f66d8a03c..d7813d615f 100644--- a/backend/store/sheet.go+++ b/backend/store/sheet.go@@ -136,7 +136,9 @@ type PatchSheetMessage struct {// GetSheetStatementByID gets the statement of a sheet by ID.func (s *Store) GetSheetStatementByID(ctx context.Context, id int) (string, error) {if statement, ok := s.sheetStatementCache.Get(id); ok {- return statement.(string), nil+ if v, ok := statement.(string); ok {+ return v, nil+ }}sheets, err := s.ListSheets(ctx, &FindSheetMessage{UID: &id, LoadFull: true}, SystemBotID)diff --git a/backend/store/vcs.go b/backend/store/vcs.goindex 404f45938e..099582446c 100644--- a/backend/store/vcs.go+++ b/backend/store/vcs.go@@ -51,7 +51,9 @@ type findExternalVersionControlMessage struct {// GetExternalVersionControlV2 gets an external version control by ID.func (s *Store) GetExternalVersionControlV2(ctx context.Context, id int) (*ExternalVersionControlMessage, error) {if vcs, ok := s.vcsIDCache.Load(id); ok {- return vcs.(*ExternalVersionControlMessage), nil+ if v, ok := vcs.(*ExternalVersionControlMessage); ok {+ return v, nil+ }}tx, err := s.db.BeginTx(ctx, &sql.TxOptions{ReadOnly: true})diff --git a/backend/tests/tests.go b/backend/tests/tests.goindex 2ceb4b342d..3c63ba3420 100644--- a/backend/tests/tests.go+++ b/backend/tests/tests.go@@ -28,7 +28,7 @@ import (_ "github.com/jackc/pgx/v4/stdlib""github.com/bytebase/bytebase/backend/common"- componentConfig "github.com/bytebase/bytebase/backend/component/config"+ component "github.com/bytebase/bytebase/backend/component/config"api "github.com/bytebase/bytebase/backend/legacyapi""github.com/bytebase/bytebase/backend/resources/postgres""github.com/bytebase/bytebase/backend/server"@@ -157,7 +157,7 @@ CREATE TABLE book4 (type controller struct {server *server.Server- profile componentConfig.Profile+ profile component.Profileclient *http.ClientgrpcConn *grpc.ClientConnissueServiceClient v1pb.IssueServiceClient@@ -337,8 +337,8 @@ func (ctl *controller) initWorkspaceProfile(ctx context.Context) error {// GetTestProfile will return a profile for testing.// We require port as an argument of GetTestProfile so that test can run in parallel in different ports.-func getTestProfile(dataDir, resourceDir string, port int, readOnly bool) componentConfig.Profile {- return componentConfig.Profile{+func getTestProfile(dataDir, resourceDir string, port int, readOnly bool) component.Profile {+ return component.Profile{Mode: common.ReleaseModeDev,ExternalURL: fmt.Sprintf("http://localhost:%d", port),GrpcPort: port + 1,@@ -357,8 +357,8 @@ func getTestProfile(dataDir, resourceDir string, port int, readOnly bool) compon// GetTestProfileWithExternalPg will return a profile for testing with external Postgres.// We require port as an argument of GetTestProfile so that test can run in parallel in different ports,// pgURL for connect to Postgres.-func getTestProfileWithExternalPg(dataDir, resourceDir string, port int, pgUser string, pgURL string, skipOnboardingData bool) componentConfig.Profile {- return componentConfig.Profile{+func getTestProfileWithExternalPg(dataDir, resourceDir string, port int, pgUser string, pgURL string, skipOnboardingData bool) component.Profile {+ return component.Profile{Mode: common.ReleaseModeDev,ExternalURL: fmt.Sprintf("http://localhost:%d", port),GrpcPort: port + 1,