Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore: refactor backend features (#16469)

Danny Xua6dce9ab9a4b
diff --git a/backend/api/directory-sync/webhook.go b/backend/api/directory-sync/webhook.go
index 13240987ba..93fe5a3731 100644
--- a/backend/api/directory-sync/webhook.go
+++ b/backend/api/directory-sync/webhook.go
@@ -18,11 +18,11 @@ import (
"github.com/labstack/echo/v4"
v1api "github.com/bytebase/bytebase/backend/api/v1"
- "github.com/bytebase/bytebase/backend/base"
"github.com/bytebase/bytebase/backend/common"
"github.com/bytebase/bytebase/backend/common/log"
"github.com/bytebase/bytebase/backend/store"
storepb "github.com/bytebase/bytebase/proto/generated-go/store"
+ v1pb "github.com/bytebase/bytebase/proto/generated-go/v1"
)
const entraIDSource = "Entra ID"
@@ -36,7 +36,7 @@ func (s *Service) RegisterDirectorySyncRoutes(g *echo.Group) {
if err := s.validRequestURL(ctx, c); err != nil {
return c.String(http.StatusInternalServerError, err.Error())
}
- if err := s.licenseService.IsFeatureEnabled(base.FeatureDirectorySync); err != nil {
+ if err := s.licenseService.IsFeatureEnabled(v1pb.PlanLimitConfig_DIRECTORY_SYNC_ENTRA_ID); err != nil {
return c.String(http.StatusForbidden, err.Error())
}
@@ -103,7 +103,7 @@ func (s *Service) RegisterDirectorySyncRoutes(g *echo.Group) {
if err := s.validRequestURL(ctx, c); err != nil {
return c.String(http.StatusInternalServerError, err.Error())
}
- if err := s.licenseService.IsFeatureEnabled(base.FeatureDirectorySync); err != nil {
+ if err := s.licenseService.IsFeatureEnabled(v1pb.PlanLimitConfig_DIRECTORY_SYNC_ENTRA_ID); err != nil {
return c.String(http.StatusForbidden, err.Error())
}
@@ -134,7 +134,7 @@ func (s *Service) RegisterDirectorySyncRoutes(g *echo.Group) {
if err := s.validRequestURL(ctx, c); err != nil {
return c.String(http.StatusInternalServerError, err.Error())
}
- if err := s.licenseService.IsFeatureEnabled(base.FeatureDirectorySync); err != nil {
+ if err := s.licenseService.IsFeatureEnabled(v1pb.PlanLimitConfig_DIRECTORY_SYNC_ENTRA_ID); err != nil {
return c.String(http.StatusForbidden, err.Error())
}
@@ -190,7 +190,7 @@ func (s *Service) RegisterDirectorySyncRoutes(g *echo.Group) {
if err := s.validRequestURL(ctx, c); err != nil {
return c.String(http.StatusInternalServerError, err.Error())
}
- if err := s.licenseService.IsFeatureEnabled(base.FeatureDirectorySync); err != nil {
+ if err := s.licenseService.IsFeatureEnabled(v1pb.PlanLimitConfig_DIRECTORY_SYNC_ENTRA_ID); err != nil {
return c.String(http.StatusForbidden, err.Error())
}
@@ -222,7 +222,7 @@ func (s *Service) RegisterDirectorySyncRoutes(g *echo.Group) {
if err := s.validRequestURL(ctx, c); err != nil {
return c.String(http.StatusInternalServerError, err.Error())
}
- if err := s.licenseService.IsFeatureEnabled(base.FeatureDirectorySync); err != nil {
+ if err := s.licenseService.IsFeatureEnabled(v1pb.PlanLimitConfig_DIRECTORY_SYNC_ENTRA_ID); err != nil {
return c.String(http.StatusForbidden, err.Error())
}
@@ -296,7 +296,7 @@ func (s *Service) RegisterDirectorySyncRoutes(g *echo.Group) {
if err := s.validRequestURL(ctx, c); err != nil {
return c.String(http.StatusInternalServerError, err.Error())
}
- if err := s.licenseService.IsFeatureEnabled(base.FeatureDirectorySync); err != nil {
+ if err := s.licenseService.IsFeatureEnabled(v1pb.PlanLimitConfig_DIRECTORY_SYNC_ENTRA_ID); err != nil {
return c.String(http.StatusForbidden, err.Error())
}
@@ -334,7 +334,7 @@ func (s *Service) RegisterDirectorySyncRoutes(g *echo.Group) {
if err := s.validRequestURL(ctx, c); err != nil {
return c.String(http.StatusInternalServerError, err.Error())
}
- if err := s.licenseService.IsFeatureEnabled(base.FeatureDirectorySync); err != nil {
+ if err := s.licenseService.IsFeatureEnabled(v1pb.PlanLimitConfig_DIRECTORY_SYNC_ENTRA_ID); err != nil {
return c.String(http.StatusForbidden, err.Error())
}
@@ -365,7 +365,7 @@ func (s *Service) RegisterDirectorySyncRoutes(g *echo.Group) {
if err := s.validRequestURL(ctx, c); err != nil {
return c.String(http.StatusInternalServerError, err.Error())
}
- if err := s.licenseService.IsFeatureEnabled(base.FeatureDirectorySync); err != nil {
+ if err := s.licenseService.IsFeatureEnabled(v1pb.PlanLimitConfig_DIRECTORY_SYNC_ENTRA_ID); err != nil {
return c.String(http.StatusForbidden, err.Error())
}
@@ -418,7 +418,7 @@ func (s *Service) RegisterDirectorySyncRoutes(g *echo.Group) {
if err := s.validRequestURL(ctx, c); err != nil {
return c.String(http.StatusInternalServerError, err.Error())
}
- if err := s.licenseService.IsFeatureEnabled(base.FeatureDirectorySync); err != nil {
+ if err := s.licenseService.IsFeatureEnabled(v1pb.PlanLimitConfig_DIRECTORY_SYNC_ENTRA_ID); err != nil {
return c.String(http.StatusForbidden, err.Error())
}
@@ -443,7 +443,7 @@ func (s *Service) RegisterDirectorySyncRoutes(g *echo.Group) {
if err := s.validRequestURL(ctx, c); err != nil {
return c.String(http.StatusInternalServerError, err.Error())
}
- if err := s.licenseService.IsFeatureEnabled(base.FeatureDirectorySync); err != nil {
+ if err := s.licenseService.IsFeatureEnabled(v1pb.PlanLimitConfig_DIRECTORY_SYNC_ENTRA_ID); err != nil {
return c.String(http.StatusForbidden, err.Error())
}
diff --git a/backend/api/v1/actuator_service.go b/backend/api/v1/actuator_service.go
index a42a38bc1e..8547eb64f7 100644
--- a/backend/api/v1/actuator_service.go
+++ b/backend/api/v1/actuator_service.go
@@ -14,7 +14,6 @@ import (
"github.com/pkg/errors"
"github.com/bytebase/bytebase/backend/api/auth"
- "github.com/bytebase/bytebase/backend/base"
"github.com/bytebase/bytebase/backend/common"
"github.com/bytebase/bytebase/backend/common/log"
"github.com/bytebase/bytebase/backend/component/config"
@@ -333,16 +332,17 @@ func (s *ActuatorService) getServerInfo(ctx context.Context) (*v1pb.ActuatorInfo
return &serverInfo, nil
}
-func (s *ActuatorService) getUsedFeatures(ctx context.Context) ([]base.FeatureType, error) {
- var features []base.FeatureType
+func (s *ActuatorService) getUsedFeatures(ctx context.Context) ([]v1pb.PlanLimitConfig_Feature, error) {
+ var features []v1pb.PlanLimitConfig_Feature
// idp
idps, err := s.store.ListIdentityProviders(ctx, &store.FindIdentityProviderMessage{})
if err != nil {
return nil, errors.Wrapf(err, "failed to list identity providers")
}
+ // TODO(d): use fine-grained feature control for SSO.
if len(idps) > 0 {
- features = append(features, base.FeatureSSO)
+ features = append(features, v1pb.PlanLimitConfig_ENTERPRISE_SSO)
}
// setting
@@ -351,7 +351,7 @@ func (s *ActuatorService) getUsedFeatures(ctx context.Context) ([]base.FeatureTy
return nil, errors.Wrapf(err, "failed to get branding logo setting")
}
if brandingLogo != nil && brandingLogo.Value != "" {
- features = append(features, base.FeatureBranding)
+ features = append(features, v1pb.PlanLimitConfig_CUSTOM_LOGO)
}
watermark, err := s.store.GetSettingV2(ctx, storepb.SettingName_WATERMARK)
@@ -359,15 +359,7 @@ func (s *ActuatorService) getUsedFeatures(ctx context.Context) ([]base.FeatureTy
return nil, errors.Wrapf(err, "failed to get watermark setting")
}
if watermark != nil && watermark.Value == "1" {
- features = append(features, base.FeatureWatermark)
- }
-
- aiSetting, err := s.store.GetAISetting(ctx)
- if err != nil {
- return nil, errors.Wrapf(err, "failed to get ai setting")
- }
- if aiSetting.ApiKey != "" {
- features = append(features, base.FeatureAIAssistant)
+ features = append(features, v1pb.PlanLimitConfig_WATERMARK)
}
setting, err := s.store.GetWorkspaceGeneralSetting(ctx)
@@ -375,16 +367,16 @@ func (s *ActuatorService) getUsedFeatures(ctx context.Context) ([]base.FeatureTy
return nil, errors.Wrapf(err, "failed to get workspace general setting")
}
if setting.DisallowSignup && !s.profile.SaaS {
- features = append(features, base.FeatureDisallowSignup)
+ features = append(features, v1pb.PlanLimitConfig_DISALLOW_SELF_SERVICE_SIGNUP)
}
if setting.Require_2Fa {
- features = append(features, base.Feature2FA)
+ features = append(features, v1pb.PlanLimitConfig_TWO_FA)
}
if setting.GetTokenDuration().GetSeconds() > 0 && float64(setting.GetTokenDuration().GetSeconds()) != auth.DefaultTokenDuration.Seconds() {
- features = append(features, base.FeatureSecureToken)
+ features = append(features, v1pb.PlanLimitConfig_SIGN_IN_FREQUENCY_CONTROL)
}
if setting.GetAnnouncement().GetText() != "" {
- features = append(features, base.FeatureAnnouncement)
+ features = append(features, v1pb.PlanLimitConfig_DASHBOARD_ANNOUNCEMENT)
}
// environment tier
@@ -394,7 +386,7 @@ func (s *ActuatorService) getUsedFeatures(ctx context.Context) ([]base.FeatureTy
}
for _, env := range environments.GetEnvironments() {
if v, ok := env.Tags["protected"]; ok && v == "protected" {
- features = append(features, base.FeatureEnvironmentTierPolicy)
+ features = append(features, v1pb.PlanLimitConfig_ENVIRONMENT_TIERS)
break
}
}
@@ -405,13 +397,13 @@ func (s *ActuatorService) getUsedFeatures(ctx context.Context) ([]base.FeatureTy
return nil, errors.Wrapf(err, "failed to list database groups")
}
if len(databaseGroups) > 0 {
- features = append(features, base.FeatureDatabaseGrouping)
+ features = append(features, v1pb.PlanLimitConfig_DATABASE_GROUPS)
}
return features, nil
}
-func (s *ActuatorService) getUnlicensedFeatures(features []base.FeatureType) []base.FeatureType {
- var unlicensedFeatures []base.FeatureType
+func (s *ActuatorService) getUnlicensedFeatures(features []v1pb.PlanLimitConfig_Feature) []v1pb.PlanLimitConfig_Feature {
+ var unlicensedFeatures []v1pb.PlanLimitConfig_Feature
for _, feature := range features {
if err := s.licenseService.IsFeatureEnabled(feature); err != nil {
unlicensedFeatures = append(unlicensedFeatures, feature)
diff --git a/backend/api/v1/audit_log_service.go b/backend/api/v1/audit_log_service.go
index 9efa1c3e31..75e7463a2a 100644
--- a/backend/api/v1/audit_log_service.go
+++ b/backend/api/v1/audit_log_service.go
@@ -15,7 +15,6 @@ import (
celoperators "github.com/google/cel-go/common/operators"
"github.com/pkg/errors"
- "github.com/bytebase/bytebase/backend/base"
"github.com/bytebase/bytebase/backend/common"
"github.com/bytebase/bytebase/backend/component/iam"
enterprise "github.com/bytebase/bytebase/backend/enterprise/api"
@@ -40,7 +39,7 @@ func NewAuditLogService(store *store.Store, iamManager *iam.Manager, licenseServ
}
func (s *AuditLogService) SearchAuditLogs(ctx context.Context, request *v1pb.SearchAuditLogsRequest) (*v1pb.SearchAuditLogsResponse, error) {
- if err := s.licenseService.IsFeatureEnabled(base.FeatureAuditLog); err != nil {
+ if err := s.licenseService.IsFeatureEnabled(v1pb.PlanLimitConfig_AUDIT_LOG); err != nil {
return nil, status.Error(codes.PermissionDenied, err.Error())
}
filter, serr := s.getSearchAuditLogsFilter(ctx, request.Filter)
@@ -98,7 +97,7 @@ func (s *AuditLogService) SearchAuditLogs(ctx context.Context, request *v1pb.Sea
}
func (s *AuditLogService) ExportAuditLogs(ctx context.Context, request *v1pb.ExportAuditLogsRequest) (*v1pb.ExportAuditLogsResponse, error) {
- if err := s.licenseService.IsFeatureEnabled(base.FeatureAuditLog); err != nil {
+ if err := s.licenseService.IsFeatureEnabled(v1pb.PlanLimitConfig_AUDIT_LOG); err != nil {
return nil, status.Error(codes.PermissionDenied, err.Error())
}
if request.Filter == "" {
diff --git a/backend/api/v1/auth_service.go b/backend/api/v1/auth_service.go
index 3a5a6d2942..d7487d444b 100644
--- a/backend/api/v1/auth_service.go
+++ b/backend/api/v1/auth_service.go
@@ -18,7 +18,6 @@ import (
"google.golang.org/protobuf/types/known/timestamppb"
"github.com/bytebase/bytebase/backend/api/auth"
- "github.com/bytebase/bytebase/backend/base"
"github.com/bytebase/bytebase/backend/common"
"github.com/bytebase/bytebase/backend/common/log"
"github.com/bytebase/bytebase/backend/component/config"
@@ -140,7 +139,7 @@ func (s *AuthService) Login(ctx context.Context, request *v1pb.LoginRequest) (*v
tokenDuration := auth.GetTokenDuration(ctx, s.store)
userMFAEnabled := loginUser.MFAConfig != nil && loginUser.MFAConfig.OtpSecret != ""
// We only allow MFA login (2-step) when the feature is enabled and user has enabled MFA.
- if s.licenseService.IsFeatureEnabled(base.Feature2FA) == nil && !mfaSecondLogin && userMFAEnabled {
+ if s.licenseService.IsFeatureEnabled(v1pb.PlanLimitConfig_TWO_FA) == nil && !mfaSecondLogin && userMFAEnabled {
mfaTempToken, err := auth.GenerateMFATempToken(loginUser.Name, loginUser.ID, s.profile.Mode, s.secret, tokenDuration)
if err != nil {
return nil, status.Errorf(codes.Internal, "failed to generate MFA temp token")
@@ -211,7 +210,7 @@ func (s *AuthService) needResetPassword(ctx context.Context, user *store.UserMes
if user.Type != storepb.PrincipalType_END_USER {
return false
}
- if err := s.licenseService.IsFeatureEnabled(base.FeaturePasswordRestriction); err != nil {
+ if err := s.licenseService.IsFeatureEnabled(v1pb.PlanLimitConfig_PASSWORD_RESTRICTIONS); err != nil {
return false
}
@@ -412,7 +411,7 @@ func (s *AuthService) getOrCreateUserWithIDP(ctx context.Context, request *v1pb.
return user, nil
}
- if err := s.licenseService.IsFeatureEnabled(base.FeatureSSO); err != nil {
+ if err := s.licenseService.IsFeatureEnabled(v1pb.PlanLimitConfig_ENTERPRISE_SSO); err != nil {
return nil, status.Error(codes.PermissionDenied, err.Error())
}
// Create new user from identity provider.
diff --git a/backend/api/v1/database_group_service.go b/backend/api/v1/database_group_service.go
index 2a9783b3b3..1180d42306 100644
--- a/backend/api/v1/database_group_service.go
+++ b/backend/api/v1/database_group_service.go
@@ -8,7 +8,6 @@ import (
"google.golang.org/grpc/status"
"google.golang.org/protobuf/types/known/emptypb"
- "github.com/bytebase/bytebase/backend/base"
"github.com/bytebase/bytebase/backend/common"
"github.com/bytebase/bytebase/backend/component/config"
"github.com/bytebase/bytebase/backend/component/iam"
@@ -39,7 +38,7 @@ func NewDatabaseGroupService(store *store.Store, profile *config.Profile, iamMan
// CreateDatabaseGroup creates a database group.
func (s *DatabaseGroupService) CreateDatabaseGroup(ctx context.Context, request *v1pb.CreateDatabaseGroupRequest) (*v1pb.DatabaseGroup, error) {
- if err := s.licenseService.IsFeatureEnabled(base.FeatureDatabaseGrouping); err != nil {
+ if err := s.licenseService.IsFeatureEnabled(v1pb.PlanLimitConfig_DATABASE_GROUPS); err != nil {
return nil, status.Error(codes.PermissionDenied, err.Error())
}
projectResourceID, err := common.GetProjectID(request.Parent)
@@ -103,7 +102,7 @@ func (s *DatabaseGroupService) CreateDatabaseGroup(ctx context.Context, request
// UpdateDatabaseGroup updates a database group.
func (s *DatabaseGroupService) UpdateDatabaseGroup(ctx context.Context, request *v1pb.UpdateDatabaseGroupRequest) (*v1pb.DatabaseGroup, error) {
- if err := s.licenseService.IsFeatureEnabled(base.FeatureDatabaseGrouping); err != nil {
+ if err := s.licenseService.IsFeatureEnabled(v1pb.PlanLimitConfig_DATABASE_GROUPS); err != nil {
return nil, status.Error(codes.PermissionDenied, err.Error())
}
projectResourceID, databaseGroupResourceID, err := common.GetProjectIDDatabaseGroupID(request.DatabaseGroup.Name)
diff --git a/backend/api/v1/database_service.go b/backend/api/v1/database_service.go
index ee78e3b779..742f12a496 100644
--- a/backend/api/v1/database_service.go
+++ b/backend/api/v1/database_service.go
@@ -19,7 +19,6 @@ import (
"google.golang.org/protobuf/types/known/emptypb"
"google.golang.org/protobuf/types/known/fieldmaskpb"
- "github.com/bytebase/bytebase/backend/base"
"github.com/bytebase/bytebase/backend/common"
"github.com/bytebase/bytebase/backend/component/config"
"github.com/bytebase/bytebase/backend/component/iam"
@@ -980,7 +979,7 @@ func (s *DatabaseService) UpdateSecret(ctx context.Context, request *v1pb.Update
return nil, status.Errorf(codes.NotFound, "instance %q not found", instanceID)
}
- if err := s.licenseService.IsFeatureEnabledForInstance(base.FeatureEncryptedSecrets, instance); err != nil {
+ if err := s.licenseService.IsFeatureEnabledForInstance(v1pb.PlanLimitConfig_DATABASE_SECRET_VARIABLES, instance); err != nil {
return nil, status.Error(codes.PermissionDenied, err.Error())
}
@@ -1070,7 +1069,7 @@ func (s *DatabaseService) DeleteSecret(ctx context.Context, request *v1pb.Delete
return nil, status.Errorf(codes.NotFound, "instance %q not found", instanceID)
}
- if err := s.licenseService.IsFeatureEnabledForInstance(base.FeatureEncryptedSecrets, instance); err != nil {
+ if err := s.licenseService.IsFeatureEnabledForInstance(v1pb.PlanLimitConfig_DATABASE_SECRET_VARIABLES, instance); err != nil {
return nil, status.Error(codes.PermissionDenied, err.Error())
}
diff --git a/backend/api/v1/idp_service.go b/backend/api/v1/idp_service.go
index 838b8de482..05935e4070 100644
--- a/backend/api/v1/idp_service.go
+++ b/backend/api/v1/idp_service.go
@@ -11,7 +11,6 @@ import (
"google.golang.org/grpc/status"
"google.golang.org/protobuf/types/known/emptypb"
- "github.com/bytebase/bytebase/backend/base"
"github.com/bytebase/bytebase/backend/common"
"github.com/bytebase/bytebase/backend/common/log"
enterprise "github.com/bytebase/bytebase/backend/enterprise/api"
@@ -200,7 +199,7 @@ func (s *IdentityProviderService) DeleteIdentityProvider(ctx context.Context, re
}
func (s *IdentityProviderService) checkFeatureAvailable(ssoType v1pb.IdentityProviderType) error {
- if err := s.licenseService.IsFeatureEnabled(base.FeatureSSO); err != nil {
+ if err := s.licenseService.IsFeatureEnabled(v1pb.PlanLimitConfig_ENTERPRISE_SSO); err != nil {
return status.Error(codes.PermissionDenied, err.Error())
}
plan := s.licenseService.GetEffectivePlan()
diff --git a/backend/api/v1/instance_service.go b/backend/api/v1/instance_service.go
index a17f605250..bd026a665d 100644
--- a/backend/api/v1/instance_service.go
+++ b/backend/api/v1/instance_service.go
@@ -16,7 +16,6 @@ import (
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/known/emptypb"
- "github.com/bytebase/bytebase/backend/base"
"github.com/bytebase/bytebase/backend/common"
"github.com/bytebase/bytebase/backend/common/log"
"github.com/bytebase/bytebase/backend/component/dbfactory"
@@ -390,7 +389,7 @@ func (s *InstanceService) checkDataSource(instance *store.InstanceMessage, dataS
return status.Errorf(codes.InvalidArgument, "data source id is required")
}
- if err := s.licenseService.IsFeatureEnabledForInstance(base.FeatureExternalSecretManager, instance); err != nil {
+ if err := s.licenseService.IsFeatureEnabledForInstance(v1pb.PlanLimitConfig_EXTERNAL_SECRET_MANAGER, instance); err != nil {
missingFeatureError := status.Error(codes.PermissionDenied, err.Error())
if dataSource.GetExternalSecret() != nil {
return missingFeatureError
@@ -464,19 +463,16 @@ func (s *InstanceService) UpdateInstance(ctx context.Context, request *v1pb.Upda
}
patch.Metadata.Activation = request.Instance.Activation
case "sync_interval":
- if err := s.licenseService.IsFeatureEnabledForInstance(base.FeatureCustomInstanceSynchronization, instance); err != nil {
+ if err := s.licenseService.IsFeatureEnabledForInstance(v1pb.PlanLimitConfig_CUSTOM_INSTANCE_SYNC_TIME, instance); err != nil {
return nil, status.Error(codes.PermissionDenied, err.Error())
}
patch.Metadata.SyncInterval = request.Instance.SyncInterval
case "maximum_connections":
- if err := s.licenseService.IsFeatureEnabledForInstance(base.FeatureCustomInstanceSynchronization, instance); err != nil {
+ if err := s.licenseService.IsFeatureEnabledForInstance(v1pb.PlanLimitConfig_CUSTOM_INSTANCE_CONNECTION_LIMIT, instance); err != nil {
return nil, status.Error(codes.PermissionDenied, err.Error())
}
patch.Metadata.MaximumConnections = request.Instance.MaximumConnections
case "sync_databases":
- if err := s.licenseService.IsFeatureEnabledForInstance(base.FeatureCustomInstanceSynchronization, instance); err != nil {
- return nil, status.Error(codes.PermissionDenied, err.Error())
- }
patch.Metadata.SyncDatabases = request.Instance.SyncDatabases
default:
return nil, status.Errorf(codes.InvalidArgument, `unsupported update_mask "%s"`, path)
@@ -696,7 +692,7 @@ func (s *InstanceService) AddDataSource(ctx context.Context, request *v1pb.AddDa
if dataSource.GetType() != storepb.DataSourceType_READ_ONLY {
return nil, status.Error(codes.InvalidArgument, "only read-only data source can be added.")
}
- if err := s.licenseService.IsFeatureEnabledForInstance(base.FeatureReadReplicaConnection, instance); err != nil {
+ if err := s.licenseService.IsFeatureEnabledForInstance(v1pb.PlanLimitConfig_INSTANCE_READ_ONLY_CONNECTION, instance); err != nil {
return nil, status.Error(codes.PermissionDenied, err.Error())
}
@@ -745,7 +741,7 @@ func (s *InstanceService) UpdateDataSource(ctx context.Context, request *v1pb.Up
}
if dataSource.GetType() == storepb.DataSourceType_READ_ONLY {
- if err := s.licenseService.IsFeatureEnabledForInstance(base.FeatureReadReplicaConnection, instance); err != nil {
+ if err := s.licenseService.IsFeatureEnabledForInstance(v1pb.PlanLimitConfig_INSTANCE_READ_ONLY_CONNECTION, instance); err != nil {
return nil, status.Error(codes.PermissionDenied, err.Error())
}
}
diff --git a/backend/api/v1/org_policy_service.go b/backend/api/v1/org_policy_service.go
index bca302c3f6..85db628bd2 100644
--- a/backend/api/v1/org_policy_service.go
+++ b/backend/api/v1/org_policy_service.go
@@ -12,7 +12,6 @@ import (
"google.golang.org/protobuf/encoding/protojson"
"google.golang.org/protobuf/types/known/emptypb"
- "github.com/bytebase/bytebase/backend/base"
"github.com/bytebase/bytebase/backend/common"
enterprise "github.com/bytebase/bytebase/backend/enterprise/api"
"github.com/bytebase/bytebase/backend/store"
@@ -369,7 +368,7 @@ func (s *OrgPolicyService) convertPolicyPayloadToString(ctx context.Context, pol
case v1pb.PolicyType_ROLLOUT_POLICY:
rolloutPolicy := convertToStorePBRolloutPolicy(policy.GetRolloutPolicy())
if !rolloutPolicy.Automatic {
- if err := s.licenseService.IsFeatureEnabled(base.FeatureRolloutPolicy); err != nil {
+ if err := s.licenseService.IsFeatureEnabled(v1pb.PlanLimitConfig_ROLLOUT_POLICY); err != nil {
return "", status.Error(codes.PermissionDenied, err.Error())
}
}
@@ -388,7 +387,7 @@ func (s *OrgPolicyService) convertPolicyPayloadToString(ctx context.Context, pol
}
return string(payloadBytes), nil
case v1pb.PolicyType_DISABLE_COPY_DATA:
- if err := s.licenseService.IsFeatureEnabled(base.FeatureAccessControl); err != nil {
+ if err := s.licenseService.IsFeatureEnabled(v1pb.PlanLimitConfig_RESTRICT_COPYING_DATA); err != nil {
return "", status.Error(codes.PermissionDenied, err.Error())
}
payload, err := convertToDisableCopyDataPolicyPayload(policy.GetDisableCopyDataPolicy())
@@ -401,7 +400,7 @@ func (s *OrgPolicyService) convertPolicyPayloadToString(ctx context.Context, pol
}
return string(payloadBytes), nil
case v1pb.PolicyType_DATA_EXPORT:
- if err := s.licenseService.IsFeatureEnabled(base.FeatureAccessControl); err != nil {
+ if err := s.licenseService.IsFeatureEnabled(v1pb.PlanLimitConfig_QUERY_DATASOURCE_RESTRICTION); err != nil {
return "", status.Error(codes.PermissionDenied, err.Error())
}
payload, err := convertToExportDataPolicyPayload(policy.GetExportDataPolicy())
@@ -414,7 +413,7 @@ func (s *OrgPolicyService) convertPolicyPayloadToString(ctx context.Context, pol
}
return string(payloadBytes), nil
case v1pb.PolicyType_DATA_QUERY:
- if err := s.licenseService.IsFeatureEnabled(base.FeatureAccessControl); err != nil {
+ if err := s.licenseService.IsFeatureEnabled(v1pb.PlanLimitConfig_QUERY_DATASOURCE_RESTRICTION); err != nil {
return "", status.Error(codes.PermissionDenied, err.Error())
}
payload, err := convertToQueryDataPolicyPayload(policy.GetQueryDataPolicy())
@@ -427,7 +426,7 @@ func (s *OrgPolicyService) convertPolicyPayloadToString(ctx context.Context, pol
}
return string(payloadBytes), nil
case v1pb.PolicyType_MASKING_RULE:
- if err := s.licenseService.IsFeatureEnabled(base.FeatureSensitiveData); err != nil {
+ if err := s.licenseService.IsFeatureEnabled(v1pb.PlanLimitConfig_DATA_MASKING); err != nil {
return "", status.Error(codes.PermissionDenied, err.Error())
}
payload, err := convertToStorePBMskingRulePolicy(policy.GetMaskingRulePolicy())
@@ -440,7 +439,7 @@ func (s *OrgPolicyService) convertPolicyPayloadToString(ctx context.Context, pol
}
return string(payloadBytes), nil
case v1pb.PolicyType_MASKING_EXCEPTION:
- if err := s.licenseService.IsFeatureEnabled(base.FeatureSensitiveData); err != nil {
+ if err := s.licenseService.IsFeatureEnabled(v1pb.PlanLimitConfig_DATA_MASKING); err != nil {
return "", status.Error(codes.PermissionDenied, err.Error())
}
payload, err := s.convertToStorePBMaskingExceptionPolicyPayload(ctx, policy.GetMaskingExceptionPolicy())
@@ -453,9 +452,6 @@ func (s *OrgPolicyService) convertPolicyPayloadToString(ctx context.Context, pol
}
return string(payloadBytes), nil
case v1pb.PolicyType_RESTRICT_ISSUE_CREATION_FOR_SQL_REVIEW:
- if err := s.licenseService.IsFeatureEnabled(base.FeatureAccessControl); err != nil {
- return "", status.Error(codes.PermissionDenied, err.Error())
- }
payload, err := convertToRestrictIssueCreationForSQLReviewPayload(policy.GetRestrictIssueCreationForSqlReviewPolicy())
if err != nil {
return "", status.Error(codes.InvalidArgument, err.Error())
diff --git a/backend/api/v1/project_service.go b/backend/api/v1/project_service.go
index aae3e0a0a3..cdf9c5c6c7 100644
--- a/backend/api/v1/project_service.go
+++ b/backend/api/v1/project_service.go
@@ -4,7 +4,6 @@ import (
"context"
"fmt"
"log/slog"
- "slices"
"strconv"
"strings"
"time"
@@ -23,7 +22,6 @@ import (
"google.golang.org/protobuf/types/known/durationpb"
"google.golang.org/protobuf/types/known/emptypb"
- "github.com/bytebase/bytebase/backend/base"
"github.com/bytebase/bytebase/backend/common"
"github.com/bytebase/bytebase/backend/common/log"
"github.com/bytebase/bytebase/backend/component/config"
@@ -331,24 +329,7 @@ func (s *ProjectService) UpdateProject(ctx context.Context, request *v1pb.Update
ResourceID: project.ResourceID,
}
- issueProjectSettingFeatureRelatedPaths := []string{
- "force_issue_labels",
- "allow_modify_statement",
- "auto_resolve_issue",
- "enforce_issue_title",
- "auto_enable_backup",
- "skip_backup_errors",
- "postgres_database_tenant_mode",
- "ci_sampling_size",
- }
for _, path := range request.UpdateMask.Paths {
- if slices.Contains(issueProjectSettingFeatureRelatedPaths, path) {
- // Check if the issue project setting feature is enabled.
- if err := s.licenseService.IsFeatureEnabled(base.FeatureIssueProjectSetting); err != nil {
- return nil, status.Error(codes.PermissionDenied, err.Error())
- }
- }
-
switch path {
case "title":
patch.Title = &request.Project.Title
diff --git a/backend/api/v1/review_config_service.go b/backend/api/v1/review_config_service.go
index d2e790d7bc..0373a71e9a 100644
--- a/backend/api/v1/review_config_service.go
+++ b/backend/api/v1/review_config_service.go
@@ -9,7 +9,6 @@ import (
"github.com/pkg/errors"
- "github.com/bytebase/bytebase/backend/base"
"github.com/bytebase/bytebase/backend/common"
enterprise "github.com/bytebase/bytebase/backend/enterprise/api"
"github.com/bytebase/bytebase/backend/plugin/advisor"
@@ -35,9 +34,6 @@ func NewReviewConfigService(store *store.Store, licenseService enterprise.Licens
// CreateReviewConfig creates a new review config.
func (s *ReviewConfigService) CreateReviewConfig(ctx context.Context, request *v1pb.CreateReviewConfigRequest) (*v1pb.ReviewConfig, error) {
- if err := s.licenseService.IsFeatureEnabled(base.FeatureSQLReview); err != nil {
- return nil, status.Error(codes.PermissionDenied, err.Error())
- }
if err := validateSQLReviewRules(request.ReviewConfig.Rules); err != nil {
return nil, status.Error(codes.InvalidArgument, err.Error())
}
@@ -90,9 +86,6 @@ func (s *ReviewConfigService) GetReviewConfig(ctx context.Context, request *v1pb
// UpdateReviewConfig updates the review config.
func (s *ReviewConfigService) UpdateReviewConfig(ctx context.Context, request *v1pb.UpdateReviewConfigRequest) (*v1pb.ReviewConfig, error) {
- if err := s.licenseService.IsFeatureEnabled(base.FeatureSQLReview); err != nil {
- return nil, status.Error(codes.PermissionDenied, err.Error())
- }
id, err := common.GetReviewConfigID(request.ReviewConfig.Name)
if err != nil {
return nil, status.Error(codes.InvalidArgument, err.Error())
diff --git a/backend/api/v1/risk_service.go b/backend/api/v1/risk_service.go
index a0cfcbf0ef..9527ade01c 100644
--- a/backend/api/v1/risk_service.go
+++ b/backend/api/v1/risk_service.go
@@ -8,7 +8,6 @@ import (
"google.golang.org/grpc/status"
"google.golang.org/protobuf/types/known/emptypb"
- "github.com/bytebase/bytebase/backend/base"
"github.com/bytebase/bytebase/backend/common"
enterprise "github.com/bytebase/bytebase/backend/enterprise/api"
"github.com/bytebase/bytebase/backend/store"
@@ -69,7 +68,7 @@ func (s *RiskService) GetRisk(ctx context.Context, request *v1pb.GetRiskRequest)
// CreateRisk creates a risk.
func (s *RiskService) CreateRisk(ctx context.Context, request *v1pb.CreateRiskRequest) (*v1pb.Risk, error) {
- if err := s.licenseService.IsFeatureEnabled(base.FeatureCustomApproval); err != nil {
+ if err := s.licenseService.IsFeatureEnabled(v1pb.PlanLimitConfig_RISK_ASSESSMENT); err != nil {
return nil, status.Error(codes.PermissionDenied, err.Error())
}
// Validate the condition.
@@ -92,7 +91,7 @@ func (s *RiskService) CreateRisk(ctx context.Context, request *v1pb.CreateRiskRe
// UpdateRisk updates a risk.
func (s *RiskService) UpdateRisk(ctx context.Context, request *v1pb.UpdateRiskRequest) (*v1pb.Risk, error) {
- if err := s.licenseService.IsFeatureEnabled(base.FeatureCustomApproval); err != nil {
+ if err := s.licenseService.IsFeatureEnabled(v1pb.PlanLimitConfig_RISK_ASSESSMENT); err != nil {
return nil, status.Error(codes.PermissionDenied, err.Error())
}
if request.UpdateMask == nil {
diff --git a/backend/api/v1/role_service.go b/backend/api/v1/role_service.go
index fb7c9dd7b2..1d39953543 100644
--- a/backend/api/v1/role_service.go
+++ b/backend/api/v1/role_service.go
@@ -9,7 +9,6 @@ import (
"google.golang.org/grpc/status"
"google.golang.org/protobuf/types/known/emptypb"
- "github.com/bytebase/bytebase/backend/base"
"github.com/bytebase/bytebase/backend/common"
"github.com/bytebase/bytebase/backend/component/iam"
enterprise "github.com/bytebase/bytebase/backend/enterprise/api"
@@ -83,7 +82,7 @@ func (s *RoleService) getBuildinRole(roleID string) *store.RoleMessage {
// CreateRole creates a new role.
func (s *RoleService) CreateRole(ctx context.Context, request *v1pb.CreateRoleRequest) (*v1pb.Role, error) {
- if err := s.licenseService.IsFeatureEnabled(base.FeatureCustomRole); err != nil {
+ if err := s.licenseService.IsFeatureEnabled(v1pb.PlanLimitConfig_CUSTOM_ROLES); err != nil {
return nil, status.Error(codes.PermissionDenied, err.Error())
}
@@ -126,7 +125,7 @@ func (s *RoleService) CreateRole(ctx context.Context, request *v1pb.CreateRoleRe
// UpdateRole updates an existing role.
func (s *RoleService) UpdateRole(ctx context.Context, request *v1pb.UpdateRoleRequest) (*v1pb.Role, error) {
- if err := s.licenseService.IsFeatureEnabled(base.FeatureCustomRole); err != nil {
+ if err := s.licenseService.IsFeatureEnabled(v1pb.PlanLimitConfig_CUSTOM_ROLES); err != nil {
return nil, status.Error(codes.PermissionDenied, err.Error())
}
if request.UpdateMask == nil {
diff --git a/backend/api/v1/setting_service.go b/backend/api/v1/setting_service.go
index 95e80cb788..b4aa24ebfc 100644
--- a/backend/api/v1/setting_service.go
+++ b/backend/api/v1/setting_service.go
@@ -19,7 +19,6 @@ import (
"google.golang.org/protobuf/testing/protocmp"
"google.golang.org/protobuf/types/known/anypb"
- "github.com/bytebase/bytebase/backend/base"
"github.com/bytebase/bytebase/backend/common"
"github.com/bytebase/bytebase/backend/common/log"
"github.com/bytebase/bytebase/backend/component/config"
@@ -201,7 +200,7 @@ func (s *SettingService) UpdateSetting(ctx context.Context, request *v1pb.Update
if s.profile.SaaS {
return nil, status.Errorf(codes.InvalidArgument, "feature %s is unavailable in current mode", settingName)
}
- if err := s.licenseService.IsFeatureEnabled(base.FeatureDisallowSignup); err != nil {
+ if err := s.licenseService.IsFeatureEnabled(v1pb.PlanLimitConfig_DISALLOW_SELF_SERVICE_SIGNUP); err != nil {
return nil, status.Error(codes.PermissionDenied, err.Error())
}
oldSetting.DisallowSignup = payload.DisallowSignup
@@ -218,14 +217,14 @@ func (s *SettingService) UpdateSetting(ctx context.Context, request *v1pb.Update
}
oldSetting.ExternalUrl = payload.ExternalUrl
case "value.workspace_profile_setting_value.require_2fa":
- if err := s.licenseService.IsFeatureEnabled(base.Feature2FA); err != nil {
+ if err := s.licenseService.IsFeatureEnabled(v1pb.PlanLimitConfig_TWO_FA); err != nil {
return nil, status.Error(codes.PermissionDenied, err.Error())
}
oldSetting.Require_2Fa = payload.Require_2Fa
case "value.workspace_profile_setting_value.outbound_ip_list":
// We're not support update outbound_ip_list via api.
case "value.workspace_profile_setting_value.token_duration":
- if err := s.licenseService.IsFeatureEnabled(base.FeatureSecureToken); err != nil {
+ if err := s.licenseService.IsFeatureEnabled(v1pb.PlanLimitConfig_SIGN_IN_FREQUENCY_CONTROL); err != nil {
return nil, status.Error(codes.PermissionDenied, err.Error())
}
if payload.TokenDuration != nil && payload.TokenDuration.Seconds > 0 && payload.TokenDuration.AsDuration() < time.Hour {
@@ -233,7 +232,7 @@ func (s *SettingService) UpdateSetting(ctx context.Context, request *v1pb.Update
}
oldSetting.TokenDuration = payload.TokenDuration
case "value.workspace_profile_setting_value.announcement":
- if err := s.licenseService.IsFeatureEnabled(base.FeatureAnnouncement); err != nil {
+ if err := s.licenseService.IsFeatureEnabled(v1pb.PlanLimitConfig_DASHBOARD_ANNOUNCEMENT); err != nil {
return nil, status.Error(codes.PermissionDenied, err.Error())
}
oldSetting.Announcement = payload.Announcement
@@ -252,7 +251,7 @@ func (s *SettingService) UpdateSetting(ctx context.Context, request *v1pb.Update
oldSetting.Domains = payload.Domains
case "value.workspace_profile_setting_value.enforce_identity_domain":
if payload.EnforceIdentityDomain {
- if err := s.licenseService.IsFeatureEnabled(base.FeatureDomainRestriction); err != nil {
+ if err := s.licenseService.IsFeatureEnabled(v1pb.PlanLimitConfig_USER_EMAIL_DOMAIN_RESTRICTION); err != nil {
return nil, status.Error(codes.PermissionDenied, err.Error())
}
}
@@ -285,7 +284,7 @@ func (s *SettingService) UpdateSetting(ctx context.Context, request *v1pb.Update
}
storeSettingValue = string(bytes)
case storepb.SettingName_WORKSPACE_APPROVAL:
- if err := s.licenseService.IsFeatureEnabled(base.FeatureCustomApproval); err != nil {
+ if err := s.licenseService.IsFeatureEnabled(v1pb.PlanLimitConfig_APPROVAL_WORKFLOW); err != nil {
return nil, status.Error(codes.PermissionDenied, err.Error())
}
@@ -370,7 +369,7 @@ func (s *SettingService) UpdateSetting(ctx context.Context, request *v1pb.Update
}
storeSettingValue = string(bytes)
case storepb.SettingName_BRANDING_LOGO:
- if err := s.licenseService.IsFeatureEnabled(base.FeatureBranding); err != nil {
+ if err := s.licenseService.IsFeatureEnabled(v1pb.PlanLimitConfig_CUSTOM_LOGO); err != nil {
return nil, status.Error(codes.PermissionDenied, err.Error())
}
storeSettingValue = request.Setting.Value.GetStringValue()
@@ -451,7 +450,7 @@ func (s *SettingService) UpdateSetting(ctx context.Context, request *v1pb.Update
storeSettingValue = string(bytes)
case storepb.SettingName_SCHEMA_TEMPLATE:
- if err := s.licenseService.IsFeatureEnabled(base.FeatureSchemaTemplate); err != nil {
+ if err := s.licenseService.IsFeatureEnabled(v1pb.PlanLimitConfig_SCHEMA_TEMPLATE); err != nil {
return nil, status.Error(codes.PermissionDenied, err.Error())
}
schemaTemplateSetting := request.Setting.Value.GetSchemaTemplateSettingValue()
@@ -516,7 +515,7 @@ func (s *SettingService) UpdateSetting(ctx context.Context, request *v1pb.Update
}
storeSettingValue = string(bytes)
case storepb.SettingName_WATERMARK:
- if err := s.licenseService.IsFeatureEnabled(base.FeatureWatermark); err != nil {
+ if err := s.licenseService.IsFeatureEnabled(v1pb.PlanLimitConfig_WATERMARK); err != nil {
return nil, status.Error(codes.PermissionDenied, err.Error())
}
storeSettingValue = request.Setting.Value.GetStringValue()
@@ -546,7 +545,7 @@ func (s *SettingService) UpdateSetting(ctx context.Context, request *v1pb.Update
}
storeSettingValue = string(bytes)
case storepb.SettingName_PASSWORD_RESTRICTION:
- if err := s.licenseService.IsFeatureEnabled(base.FeaturePasswordRestriction); err != nil {
+ if err := s.licenseService.IsFeatureEnabled(v1pb.PlanLimitConfig_PASSWORD_RESTRICTIONS); err != nil {
return nil, status.Error(codes.PermissionDenied, err.Error())
}
passwordSetting := new(storepb.PasswordRestrictionSetting)
diff --git a/backend/api/v1/sql_service.go b/backend/api/v1/sql_service.go
index 2982da3275..75fa60b910 100644
--- a/backend/api/v1/sql_service.go
+++ b/backend/api/v1/sql_service.go
@@ -24,7 +24,6 @@ import (
"google.golang.org/protobuf/types/known/durationpb"
"google.golang.org/protobuf/types/known/timestamppb"
- "github.com/bytebase/bytebase/backend/base"
"github.com/bytebase/bytebase/backend/common"
"github.com/bytebase/bytebase/backend/common/log"
"github.com/bytebase/bytebase/backend/component/config"
@@ -440,7 +439,7 @@ func queryRetry(
return nil, nil, time.Duration(0), err
}
}
- if licenseService.IsFeatureEnabledForInstance(base.FeatureSensitiveData, instance) == nil {
+ if licenseService.IsFeatureEnabledForInstance(v1pb.PlanLimitConfig_DATA_MASKING, instance) == nil {
masker := NewQueryResultMasker(stores)
sensitivePredicateColumns, err = masker.ExtractSensitivePredicateColumns(ctx, spans, instance, user, action)
if err != nil {
@@ -504,7 +503,7 @@ func queryRetry(
if err := replaceBackupTableWithSource(ctx, stores, instance, database, spans); err != nil {
slog.Debug("failed to replace backup table with source", log.BBError(err))
}
- if licenseService.IsFeatureEnabledForInstance(base.FeatureSensitiveData, instance) == nil {
+ if licenseService.IsFeatureEnabledForInstance(v1pb.PlanLimitConfig_DATA_MASKING, instance) == nil {
masker := NewQueryResultMasker(stores)
sensitivePredicateColumns, err = masker.ExtractSensitivePredicateColumns(ctx, spans, instance, user, action)
if err != nil {
@@ -524,7 +523,7 @@ func queryRetry(
}
}
- if licenseService.IsFeatureEnabledForInstance(base.FeatureSensitiveData, instance) == nil && !queryContext.Explain {
+ if licenseService.IsFeatureEnabledForInstance(v1pb.PlanLimitConfig_DATA_MASKING, instance) == nil && !queryContext.Explain {
// TODO(zp): Refactor Document Database and RDBMS to use the same masking logic.
if instance.Metadata.GetEngine() == storepb.Engine_COSMOSDB {
if len(spans) != 1 {
@@ -668,7 +667,7 @@ func executeWithTimeout(ctx context.Context, stores *store.Store, licenseService
var timeout time.Duration
// For access control feature, we will use the timeout from request and query data policy.
// Otherwise, no timeout will be applied.
- if licenseService.IsFeatureEnabled(base.FeatureAccessControl) == nil {
+ if licenseService.IsFeatureEnabled(v1pb.PlanLimitConfig_QUERY_DATASOURCE_RESTRICTION) == nil {
queryDataPolicy, err := stores.GetQueryDataPolicy(ctx)
if err != nil {
return nil, time.Duration(0), errors.Wrap(err, "failed to get query data policy")
@@ -896,7 +895,7 @@ func DoExport(
return nil, duration, errors.New(results[0].GetError())
}
- if licenseService.IsFeatureEnabledForInstance(base.FeatureSensitiveData, instance) == nil {
+ if licenseService.IsFeatureEnabledForInstance(v1pb.PlanLimitConfig_DATA_MASKING, instance) == nil {
masker := NewQueryResultMasker(stores)
if err := masker.MaskResults(ctx, spans, results, instance, user, storepb.MaskingExceptionPolicy_MaskingException_EXPORT); err != nil {
return nil, duration, err
diff --git a/backend/api/v1/subscription_service.go b/backend/api/v1/subscription_service.go
index 8119d4a5f9..fffffd735a 100644
--- a/backend/api/v1/subscription_service.go
+++ b/backend/api/v1/subscription_service.go
@@ -8,7 +8,6 @@ import (
"google.golang.org/grpc/status"
"google.golang.org/protobuf/types/known/timestamppb"
- "github.com/bytebase/bytebase/backend/base"
"github.com/bytebase/bytebase/backend/common"
"github.com/bytebase/bytebase/backend/component/config"
enterprise "github.com/bytebase/bytebase/backend/enterprise/api"
@@ -48,15 +47,24 @@ func (s *SubscriptionService) GetSubscription(ctx context.Context, _ *v1pb.GetSu
// GetFeatureMatrix gets the feature metric.
func (*SubscriptionService) GetFeatureMatrix(_ context.Context, _ *v1pb.GetFeatureMatrixRequest) (*v1pb.FeatureMatrix, error) {
resp := &v1pb.FeatureMatrix{}
- for key, val := range base.FeatureMatrix {
- matrix := map[string]bool{}
- for i, enabled := range val {
- // Convert array index to PlanType (0=FREE, 1=TEAM, 2=ENTERPRISE)
- plan := v1pb.PlanType(i + 1) // +1 because proto enums start at 1
- matrix[plan.String()] = enabled
+
+ // Create a map to collect features
+ featureMap := make(map[v1pb.PlanLimitConfig_Feature]map[string]bool)
+
+ // Iterate through all plans and features
+ for planType, features := range enterprise.PlanFeatureMatrix {
+ for feature, enabled := range features {
+ if featureMap[feature] == nil {
+ featureMap[feature] = make(map[string]bool)
+ }
+ featureMap[feature][planType.String()] = enabled
}
+ }
+
+ // Convert to response format
+ for feature, matrix := range featureMap {
resp.Features = append(resp.Features, &v1pb.Feature{
- Name: string(key),
+ Name: feature.String(),
Matrix: matrix,
})
}
diff --git a/backend/api/v1/user_service.go b/backend/api/v1/user_service.go
index 9334e081c9..7dd8591baf 100644
--- a/backend/api/v1/user_service.go
+++ b/backend/api/v1/user_service.go
@@ -19,7 +19,6 @@ import (
"google.golang.org/grpc/status"
"google.golang.org/protobuf/types/known/emptypb"
- "github.com/bytebase/bytebase/backend/base"
"github.com/bytebase/bytebase/backend/common"
"github.com/bytebase/bytebase/backend/component/config"
"github.com/bytebase/bytebase/backend/component/iam"
@@ -822,7 +821,7 @@ func convertToPrincipalType(userType v1pb.UserType) (storepb.PrincipalType, erro
}
func validateEmailWithDomains(ctx context.Context, licenseService enterprise.LicenseService, stores *store.Store, email string, isServiceAccount bool, checkDomainSetting bool) error {
- if licenseService.IsFeatureEnabled(base.FeatureDomainRestriction) != nil {
+ if licenseService.IsFeatureEnabled(v1pb.PlanLimitConfig_USER_EMAIL_DOMAIN_RESTRICTION) != nil {
// nolint:nilerr
// feature not enabled, only validate email and skip domain restriction.
if err := validateEmail(email); err != nil {
diff --git a/backend/base/plan.go b/backend/base/plan.go
deleted file mode 100644
index 0cc090bc70..0000000000
--- a/backend/base/plan.go
+++ /dev/null
@@ -1,303 +0,0 @@
-package base
-
-import (
- "fmt"
-
- v1pb "github.com/bytebase/bytebase/proto/generated-go/v1"
-)
-
-// FeatureType is the type of a feature.
-type FeatureType string
-
-const (
- // Admin & Security.
-
- // FeatureSSO allows user to manage SSO provider and authenticate (login) with SSO.
- FeatureSSO FeatureType = "bb.feature.sso"
- // Feature2FA allows user to manage 2FA provider and authenticate (login) with 2FA.
- Feature2FA FeatureType = "bb.feature.2fa"
- // FeatureDisallowSignup allows user to change the disallow signup flag.
- FeatureDisallowSignup FeatureType = "bb.feature.disallow-signup"
- // FeatureDisallowPasswordSignin allows user to disallow password signin.
- FeatureDisallowPasswordSignin FeatureType = "bb.feature.disallow-password-signin"
- // FeatureSecureToken allows user to manage authentication token security.
- FeatureSecureToken FeatureType = "bb.feature.secure-token"
- // FeatureExternalSecretManager uses secrets from external secret manager.
- FeatureExternalSecretManager FeatureType = "bb.feature.external-secret-manager"
- // FeaturePasswordRestriction allows user to configure the password restriction.
- FeaturePasswordRestriction FeatureType = "bb.feature.password-restriction"
- // FeatureDomainRestriction allows user to enforce the member email with workspace domain.
- FeatureDomainRestriction FeatureType = "bb.feature.domain-restriction"
- // FeatureDirectorySync allows to sync users and groups from Entra ID.
- FeatureDirectorySync FeatureType = "bb.feature.directory-sync"
-
- // FeatureRBAC enables RBAC.
- //
- // - Workspace level RBAC
- // - Project level RBAC.
- FeatureRBAC FeatureType = "bb.feature.rbac"
-
- // FeatureWatermark enables full-screen watermark.
- FeatureWatermark FeatureType = "bb.feature.watermark"
-
- // FeatureAuditLog enables viewing audit logs.
- FeatureAuditLog FeatureType = "bb.feature.audit-log"
-
- // FeatureCustomRole enables customizing roles.
- FeatureCustomRole FeatureType = "bb.feature.custom-role"
-
- // FeatureIssueAdvancedSearch supports search issue with advanced filter.
- FeatureIssueAdvancedSearch FeatureType = "bb.feature.issue-advanced-search"
-
- // FeatureAnnouncement enable announcement banner setting.
- FeatureAnnouncement FeatureType = "bb.feature.announcement"
-
- // Branding.
-
- // FeatureBranding enables customized branding.
- //
- // Currently, we only support customizing the logo.
- FeatureBranding FeatureType = "bb.feature.branding"
-
- // Change Workflow.
-
- // FeatureDBAWorkflow enforces the DBA workflow.
- //
- // - Developers can't create and view instances since they are exclusively by DBA, they can
- // only access database.
- // - Developers can't create database.
- // - Developers can't query and export data directly. They must request corresponding permissions first.
- FeatureDBAWorkflow FeatureType = "bb.feature.dba-workflow"
- // FeatureSchemaDrift detects if there occurs schema drift.
- // See https://bytebase.com/docs/features/drift-detection
- FeatureSchemaDrift FeatureType = "bb.feature.schema-drift"
- // FeatureSQLReview allows user to specify schema policy for the environment
- //
- // e.g. One can configure rules for database schema or SQL query.
- FeatureSQLReview FeatureType = "bb.feature.sql-review"
- // FeatureTaskScheduleTime allows user to run task at a scheduled time.
- // FeatureEncryptedSecrets is a feature that allows user to setting the encrypted secrets for the database.
- FeatureEncryptedSecrets FeatureType = "bb.feature.encrypted-secrets"
- // FeatureDatabaseGrouping allows user to create database/schema groups.
- FeatureDatabaseGrouping FeatureType = "bb.feature.database-grouping"
- // FeatureSchemaTemplate allows user to create and use the schema template.
- FeatureSchemaTemplate FeatureType = "bb.feature.schema-template"
- // FeatureIssueProjectSetting supports some advanced project settings for issue.
- FeatureIssueProjectSetting FeatureType = "bb.feature.issue-project-setting"
-
- // Database management.
-
- // FeatureReadReplicaConnection allows user to set a read replica connection
- // including host and port to data source.
- FeatureReadReplicaConnection FeatureType = "bb.feature.read-replica-connection"
- // FeatureCustomInstanceSynchronization allows user to customize the synchronization for instance.
- FeatureCustomInstanceSynchronization FeatureType = "bb.feature.custom-instance-synchronization"
- // FeatureSyncSchemaAllVersions allows user to sync the base database schema all versions into target database.
- FeatureSyncSchemaAllVersions FeatureType = "bb.feature.sync-schema-all-versions"
-
- // Policy Control.
-
- // FeatureRolloutPolicy allows user to specify approval policy for the environment
- //
- // e.g. One can configure to NOT require approval for dev environment while require
- // manual rollout for production.
- FeatureRolloutPolicy FeatureType = "bb.feature.rollout-policy"
- // FeatureEnvironmentTierPolicy allows user to set the tier of an environment.
- //
- // e.g. set the tier to "PROTECTED" for the production environment.
- FeatureEnvironmentTierPolicy FeatureType = "bb.feature.environment-tier-policy"
- // FeatureSensitiveData allows user to annotate and protect sensitive data.
- FeatureSensitiveData FeatureType = "bb.feature.sensitive-data"
- // FeatureAccessControl allows user to config the access control.
- FeatureAccessControl FeatureType = "bb.feature.access-control"
- // FeatureCustomApproval enables custom risk level definition and custom
- // approval chain definition.
- FeatureCustomApproval FeatureType = "bb.feature.custom-approval"
-
- // Efficiency.
-
- // FeatureBatchQuery enables batch query databases in SQL Editor.
- FeatureBatchQuery FeatureType = "bb.feature.batch-query"
-
- // Collaboration.
-
- // FeatureSharedSQLScript enables sharing sql script.
- FeatureSharedSQLScript FeatureType = "bb.feature.shared-sql-script"
-
- // AI Assistant.
-
- // FeatureAIAssistant enables AI features powered by OpenAI.
- FeatureAIAssistant FeatureType = "bb.feature.ai-assistant"
-)
-
-func (e FeatureType) String() string {
- return string(e)
-}
-
-// Name returns a readable name of the feature.
-func (e FeatureType) Name() string {
- switch e {
- // Admin & Security
- case FeatureSSO:
- return "SSO"
- case Feature2FA:
- return "2FA"
- case FeatureDisallowSignup:
- return "Disallow singup"
- case FeatureDisallowPasswordSignin:
- return "Disallow password signin"
- case FeatureSecureToken:
- return "Secure token"
- case FeaturePasswordRestriction:
- return "Password restriction"
- case FeatureDomainRestriction:
- return "Domain restriction"
- case FeatureDirectorySync:
- return "Directory sync"
- case FeatureExternalSecretManager:
- return "External Secret Manager"
- case FeatureRBAC:
- return "RBAC"
- case FeatureWatermark:
- return "Watermark"
- case FeatureAuditLog:
- return "Audit log"
- case FeatureCustomRole:
- return "Custom role"
- case FeatureIssueAdvancedSearch:
- return "Advanced search"
- case FeatureAnnouncement:
- return "Announcement"
- // Branding
- case FeatureBranding:
- return "Branding"
- // Change Workflow
- case FeatureDBAWorkflow:
- return "DBA workflow"
- case FeatureSchemaDrift:
- return "Schema drift"
- case FeatureSQLReview:
- return "SQL review"
- case FeatureEncryptedSecrets:
- return "Encrypted secrets"
- case FeatureDatabaseGrouping:
- return "Database grouping"
- case FeatureSchemaTemplate:
- return "Schema template"
- case FeatureIssueProjectSetting:
- return "Issue project setting"
- // Database management
- case FeatureReadReplicaConnection:
- return "Read replica connection"
- case FeatureCustomInstanceSynchronization:
- return "Custom synchronization for instance"
- case FeatureSyncSchemaAllVersions:
- return "Synchronize schema all versions"
- // Policy Control
- case FeatureRolloutPolicy:
- return "Rollout policy"
- case FeatureEnvironmentTierPolicy:
- return "Environment tier"
- case FeatureSensitiveData:
- return "Sensitive data"
- case FeatureAccessControl:
- return "Access Control"
- case FeatureCustomApproval:
- return "Custom Approval"
- // Efficiency
- case FeatureBatchQuery:
- return "Batch query"
- // Collaboration
- case FeatureSharedSQLScript:
- return "Shared SQL script"
- // Plugins
- case FeatureAIAssistant:
- return "OpenAI"
- }
- return ""
-}
-
-// AccessErrorMessage returns a error message with feature name and minimum supported plan.
-func (e FeatureType) AccessErrorMessage() string {
- plan := e.minimumSupportedPlan()
- return fmt.Sprintf("%s is a %s feature, please upgrade to access it.", e.Name(), plan.String())
-}
-
-// minimumSupportedPlan will find the minimum plan which supports the target feature.
-func (e FeatureType) minimumSupportedPlan() v1pb.PlanType {
- for i, enabled := range FeatureMatrix[e] {
- if enabled {
- return v1pb.PlanType(i + 1) // +1 because proto enums start at 1
- }
- }
-
- return v1pb.PlanType_ENTERPRISE
-}
-
-// FeatureMatrix is a map from the a particular feature to the respective enablement of a particular
-// plan in [FREE, TEAM, Enterprise].
-// Index 0 = FREE, 1 = TEAM, 2 = ENTERPRISE
-var FeatureMatrix = map[FeatureType][3]bool{
- // Admin & Security
- FeatureSSO: {false, true, true},
- Feature2FA: {false, false, true},
- FeatureDisallowSignup: {false, true, true},
- FeatureDisallowPasswordSignin: {false, false, true},
- FeatureSecureToken: {false, false, true},
- FeaturePasswordRestriction: {false, false, true},
- FeatureDomainRestriction: {false, false, true},
- FeatureDirectorySync: {false, false, true},
- FeatureExternalSecretManager: {false, false, true},
- FeatureRBAC: {true, true, true},
- FeatureWatermark: {false, false, true},
- FeatureAuditLog: {false, false, true},
- FeatureCustomRole: {false, false, true},
- FeatureIssueAdvancedSearch: {false, true, true},
- FeatureAnnouncement: {false, false, true},
- // Branding
- FeatureBranding: {false, false, true},
- // Change Workflow
- FeatureDBAWorkflow: {false, false, true},
- FeatureSchemaDrift: {false, false, true},
- FeatureSQLReview: {true, true, true},
- FeatureEncryptedSecrets: {false, true, true},
- FeatureDatabaseGrouping: {false, true, true},
- FeatureSchemaTemplate: {false, false, true},
- FeatureIssueProjectSetting: {false, true, true},
- // Database management
- FeatureReadReplicaConnection: {false, false, true},
- FeatureCustomInstanceSynchronization: {false, false, true},
- FeatureSyncSchemaAllVersions: {false, true, true},
- // Policy Control
- FeatureRolloutPolicy: {true, true, true},
- FeatureEnvironmentTierPolicy: {false, false, true},
- FeatureSensitiveData: {false, false, true},
- FeatureAccessControl: {false, false, true},
- FeatureCustomApproval: {false, false, true},
- // Efficiency
- FeatureBatchQuery: {false, true, true},
- // Collaboration
- FeatureSharedSQLScript: {true, true, true},
- // Plugins
- FeatureAIAssistant: {true, true, true},
-}
-
-// InstanceLimitFeature is the map for instance feature. Only allowed to access these feature for activate instance.
-var InstanceLimitFeature = map[FeatureType]bool{
- FeatureEncryptedSecrets: true,
- FeatureReadReplicaConnection: true,
- FeatureSensitiveData: true,
-}
-
-// Feature returns whether a particular feature is available in a particular plan.
-func Feature(feature FeatureType, plan v1pb.PlanType) bool {
- matrix, ok := FeatureMatrix[feature]
- if !ok {
- return false
- }
- // Convert proto enum to array index (FREE=1 -> 0, TEAM=2 -> 1, ENTERPRISE=3 -> 2)
- if plan < v1pb.PlanType_FREE || plan > v1pb.PlanType_ENTERPRISE {
- return false
- }
- return matrix[plan-1]
-}
diff --git a/backend/component/iam/manager.go b/backend/component/iam/manager.go
index d1b7404ed2..d7d9425e41 100644
--- a/backend/component/iam/manager.go
+++ b/backend/component/iam/manager.go
@@ -8,11 +8,11 @@ import (
"github.com/pkg/errors"
"gopkg.in/yaml.v3"
- "github.com/bytebase/bytebase/backend/base"
"github.com/bytebase/bytebase/backend/common"
enterprise "github.com/bytebase/bytebase/backend/enterprise/api"
"github.com/bytebase/bytebase/backend/store"
storepb "github.com/bytebase/bytebase/proto/generated-go/store"
+ v1pb "github.com/bytebase/bytebase/proto/generated-go/v1"
)
//go:embed acl.yaml
@@ -53,7 +53,7 @@ func NewManager(store *store.Store, licenseService enterprise.LicenseService) (*
// CEL on the binding is not considered.
// When multiple projects are specified, the user should have permission on every projects.
func (m *Manager) CheckPermission(ctx context.Context, p Permission, user *store.UserMessage, projectIDs ...string) (bool, error) {
- if m.licenseService.IsFeatureEnabled(base.FeatureRBAC) != nil {
+ if m.licenseService.IsFeatureEnabled(v1pb.PlanLimitConfig_IAM) != nil {
// nolint
return true, nil
}
diff --git a/backend/enterprise/api/license.go b/backend/enterprise/api/license.go
index 02e1531556..7e0c92593e 100644
--- a/backend/enterprise/api/license.go
+++ b/backend/enterprise/api/license.go
@@ -8,7 +8,6 @@ import (
"github.com/pkg/errors"
- "github.com/bytebase/bytebase/backend/base"
"github.com/bytebase/bytebase/backend/store"
v1pb "github.com/bytebase/bytebase/proto/generated-go/v1"
)
@@ -66,9 +65,9 @@ type LicenseService interface {
// LoadSubscription will load subscription.
LoadSubscription(ctx context.Context) *Subscription
// IsFeatureEnabled returns whether a feature is enabled.
- IsFeatureEnabled(feature base.FeatureType) error
+ IsFeatureEnabled(feature v1pb.PlanLimitConfig_Feature) error
// IsFeatureEnabledForInstance returns whether a feature is enabled for the instance.
- IsFeatureEnabledForInstance(feature base.FeatureType, instance *store.InstanceMessage) error
+ IsFeatureEnabledForInstance(feature v1pb.PlanLimitConfig_Feature, instance *store.InstanceMessage) error
// GetEffectivePlan gets the effective plan.
GetEffectivePlan() v1pb.PlanType
// GetPlanLimitValue gets the limit value for the plan.
diff --git a/backend/enterprise/api/limit.go b/backend/enterprise/api/limit.go
index 5fb8796657..7a57d3142b 100644
--- a/backend/enterprise/api/limit.go
+++ b/backend/enterprise/api/limit.go
@@ -29,6 +29,9 @@ var PlanLimitValues = map[PlanLimit]map[v1pb.PlanType]int{
PlanLimitMaximumUser: {},
}
+// PlanFeatureMatrix maps plans to their available features
+var PlanFeatureMatrix = make(map[v1pb.PlanType]map[v1pb.PlanLimitConfig_Feature]bool)
+
func init() {
// First unmarshal YAML to a generic map, then convert to JSON for protojson
var yamlData map[string]any
@@ -51,5 +54,11 @@ func init() {
for _, plan := range conf.Plans {
PlanLimitValues[PlanLimitMaximumInstance][plan.Type] = int(plan.MaximumInstanceCount)
PlanLimitValues[PlanLimitMaximumUser][plan.Type] = int(plan.MaximumSeatCount)
+
+ // Initialize feature map for this plan
+ PlanFeatureMatrix[plan.Type] = make(map[v1pb.PlanLimitConfig_Feature]bool)
+ for _, feature := range plan.Features {
+ PlanFeatureMatrix[plan.Type][feature] = true
+ }
}
}
diff --git a/backend/enterprise/api/plan.yaml b/backend/enterprise/api/plan.yaml
index 119db9886f..f8320ba1c2 100644
--- a/backend/enterprise/api/plan.yaml
+++ b/backend/enterprise/api/plan.yaml
@@ -168,6 +168,7 @@ plans:
- TERRAFORM_PROVIDER
- DATABASE_GROUPS
- ENVIRONMENT_TIERS
+ - DASHBOARD_ANNOUNCEMENT
- API_INTEGRATION_GUIDANCE
- CUSTOM_LOGO
- WATERMARK
diff --git a/backend/enterprise/service/license.go b/backend/enterprise/service/license.go
index 88e16217c1..bc4ede4d81 100644
--- a/backend/enterprise/service/license.go
+++ b/backend/enterprise/service/license.go
@@ -3,13 +3,13 @@ package service
import (
"context"
+ "fmt"
"math"
"sync"
"time"
"github.com/pkg/errors"
- "github.com/bytebase/bytebase/backend/base"
"github.com/bytebase/bytebase/backend/common"
enterprise "github.com/bytebase/bytebase/backend/enterprise/api"
"github.com/bytebase/bytebase/backend/enterprise/plugin"
@@ -85,29 +85,31 @@ func (s *LicenseService) LoadSubscription(ctx context.Context) *enterprise.Subsc
}
// IsFeatureEnabled returns whether a feature is enabled.
-func (s *LicenseService) IsFeatureEnabled(feature base.FeatureType) error {
- if !base.Feature(feature, s.GetEffectivePlan()) {
- return errors.New(feature.AccessErrorMessage())
+func (s *LicenseService) IsFeatureEnabled(f v1pb.PlanLimitConfig_Feature) error {
+ plan := s.GetEffectivePlan()
+ features, ok := enterprise.PlanFeatureMatrix[plan]
+ if !ok || !features[f] {
+ return errors.New(accessErrorMessage(f))
}
return nil
}
// IsFeatureEnabledForInstance returns whether a feature is enabled for the instance.
-func (s *LicenseService) IsFeatureEnabledForInstance(feature base.FeatureType, instance *store.InstanceMessage) error {
+func (s *LicenseService) IsFeatureEnabledForInstance(f v1pb.PlanLimitConfig_Feature, instance *store.InstanceMessage) error {
plan := s.GetEffectivePlan()
// DONOT check instance license fo FREE plan.
if plan == v1pb.PlanType_FREE {
- return s.IsFeatureEnabled(feature)
+ return s.IsFeatureEnabled(f)
}
- if err := s.IsFeatureEnabled(feature); err != nil {
+ if err := s.IsFeatureEnabled(f); err != nil {
return err
}
- if !base.InstanceLimitFeature[feature] {
+ if !instanceLimitFeature[f] {
// If the feature not exists in the limit map, we just need to check the feature for current plan.
return nil
}
if !instance.Metadata.GetActivation() {
- return errors.Errorf(`feature "%s" is not available for instance %s, please assign license to the instance to enable it`, feature.Name(), instance.ResourceID)
+ return errors.Errorf(`feature "%s" is not available for instance %s, please assign license to the instance to enable it`, f.String(), instance.ResourceID)
}
return nil
}
@@ -172,3 +174,30 @@ func (s *LicenseService) RefreshCache(ctx context.Context) {
s.mu.Unlock()
s.LoadSubscription(ctx)
}
+
+// Helper functions to avoid circular import
+
+// accessErrorMessage returns a error message with feature name and minimum supported plan.
+func accessErrorMessage(f v1pb.PlanLimitConfig_Feature) string {
+ plan := minimumSupportedPlan(f)
+ return fmt.Sprintf("%s is a %s feature, please upgrade to access it.", f.String(), plan.String())
+}
+
+// minimumSupportedPlan will find the minimum plan which supports the target feature.
+func minimumSupportedPlan(f v1pb.PlanLimitConfig_Feature) v1pb.PlanType {
+ // Check from lowest to highest plan
+ if enterprise.PlanFeatureMatrix[v1pb.PlanType_FREE][f] {
+ return v1pb.PlanType_FREE
+ }
+ if enterprise.PlanFeatureMatrix[v1pb.PlanType_TEAM][f] {
+ return v1pb.PlanType_TEAM
+ }
+ return v1pb.PlanType_ENTERPRISE
+}
+
+// instanceLimitFeature is the map for instance feature. Only allowed to access these feature for activate instance.
+var instanceLimitFeature = map[v1pb.PlanLimitConfig_Feature]bool{
+ v1pb.PlanLimitConfig_DATABASE_SECRET_VARIABLES: true,
+ v1pb.PlanLimitConfig_INSTANCE_READ_ONLY_CONNECTION: true,
+ v1pb.PlanLimitConfig_DATA_MASKING: true,
+}
diff --git a/backend/runner/approval/runner.go b/backend/runner/approval/runner.go
index cab052f77c..bf231931d9 100644
--- a/backend/runner/approval/runner.go
+++ b/backend/runner/approval/runner.go
@@ -17,7 +17,6 @@ import (
celtypes "github.com/google/cel-go/common/types"
apiv1 "github.com/bytebase/bytebase/backend/api/v1"
- "github.com/bytebase/bytebase/backend/base"
"github.com/bytebase/bytebase/backend/common"
"github.com/bytebase/bytebase/backend/common/log"
"github.com/bytebase/bytebase/backend/component/dbfactory"
@@ -28,6 +27,7 @@ import (
"github.com/bytebase/bytebase/backend/store"
"github.com/bytebase/bytebase/backend/utils"
storepb "github.com/bytebase/bytebase/proto/generated-go/store"
+ v1pb "github.com/bytebase/bytebase/proto/generated-go/v1"
)
// Runner is the runner for finding approval templates for issues.
@@ -137,7 +137,7 @@ func (r *Runner) findApprovalTemplateForIssue(ctx context.Context, issue *store.
// no need to find if
// - feature is not enabled
// - approval setting rules are empty
- if r.licenseService.IsFeatureEnabled(base.FeatureCustomApproval) != nil || len(approvalSetting.Rules) == 0 {
+ if r.licenseService.IsFeatureEnabled(v1pb.PlanLimitConfig_APPROVAL_WORKFLOW) != nil || len(approvalSetting.Rules) == 0 {
// nolint:nilerr
return nil, 0, true, nil
}
diff --git a/backend/runner/plancheck/statement_advise_executor.go b/backend/runner/plancheck/statement_advise_executor.go
index d879112a29..9d4a4b9a3e 100644
--- a/backend/runner/plancheck/statement_advise_executor.go
+++ b/backend/runner/plancheck/statement_advise_executor.go
@@ -12,7 +12,6 @@ import (
"github.com/bytebase/bytebase/backend/component/dbfactory"
"github.com/bytebase/bytebase/backend/component/sheet"
- "github.com/bytebase/bytebase/backend/base"
enterprise "github.com/bytebase/bytebase/backend/enterprise/api"
"github.com/bytebase/bytebase/backend/plugin/advisor"
"github.com/bytebase/bytebase/backend/plugin/advisor/catalog"
@@ -21,6 +20,7 @@ import (
"github.com/bytebase/bytebase/backend/store"
"github.com/bytebase/bytebase/backend/utils"
storepb "github.com/bytebase/bytebase/proto/generated-go/store"
+ v1pb "github.com/bytebase/bytebase/proto/generated-go/v1"
)
// NewStatementAdviseExecutor creates a plan check statement advise executor.
@@ -51,7 +51,7 @@ func (e *StatementAdviseExecutor) Run(ctx context.Context, config *storepb.PlanC
if config.ChangeDatabaseType == storepb.PlanCheckRunConfig_CHANGE_DATABASE_TYPE_UNSPECIFIED {
return nil, errors.Errorf("change database type is unspecified")
}
- if err := e.licenseService.IsFeatureEnabled(base.FeatureSQLReview); err != nil {
+ if err := e.licenseService.IsFeatureEnabled(v1pb.PlanLimitConfig_PRE_DEPLOYMENT_SQL_REVIEW); err != nil {
// nolint:nilerr
return []*storepb.PlanCheckRunResult_Result{
{
diff --git a/backend/tests/data_source_test.go b/backend/tests/data_source_test.go
index aa4353a245..654b0af9d8 100644
--- a/backend/tests/data_source_test.go
+++ b/backend/tests/data_source_test.go
@@ -52,7 +52,7 @@ func TestDataSource(t *testing.T) {
SslKey: "",
},
})
- a.ErrorContains(err, "Read replica connection is a ENTERPRISE feature")
+ a.ErrorContains(err, "TEAM feature, please upgrade to access it")
err = ctl.setLicense(ctx)
a.NoError(err)
@@ -87,7 +87,7 @@ func TestDataSource(t *testing.T) {
Paths: []string{"host", "port"},
},
})
- a.ErrorContains(err, "Read replica connection is a ENTERPRISE feature")
+ a.ErrorContains(err, "TEAM feature, please upgrade to access it")
err = ctl.setLicense(ctx)
a.NoError(err)
diff --git a/frontend/src/types/proto/v1/subscription_service.ts b/frontend/src/types/proto/v1/subscription_service.ts
index 48e0fef966..58e3115e03 100644
--- a/frontend/src/types/proto/v1/subscription_service.ts
+++ b/frontend/src/types/proto/v1/subscription_service.ts
@@ -196,6 +196,7 @@ export enum PlanLimitConfig_Feature {
TERRAFORM_PROVIDER = "TERRAFORM_PROVIDER",
DATABASE_GROUPS = "DATABASE_GROUPS",
ENVIRONMENT_TIERS = "ENVIRONMENT_TIERS",
+ DASHBOARD_ANNOUNCEMENT = "DASHBOARD_ANNOUNCEMENT",
API_INTEGRATION_GUIDANCE = "API_INTEGRATION_GUIDANCE",
CUSTOM_LOGO = "CUSTOM_LOGO",
WATERMARK = "WATERMARK",
@@ -402,27 +403,30 @@ export function planLimitConfig_FeatureFromJSON(object: any): PlanLimitConfig_Fe
case "ENVIRONMENT_TIERS":
return PlanLimitConfig_Feature.ENVIRONMENT_TIERS;
case 64:
+ case "DASHBOARD_ANNOUNCEMENT":
+ return PlanLimitConfig_Feature.DASHBOARD_ANNOUNCEMENT;
+ case 65:
case "API_INTEGRATION_GUIDANCE":
return PlanLimitConfig_Feature.API_INTEGRATION_GUIDANCE;
- case 65:
+ case 66:
case "CUSTOM_LOGO":
return PlanLimitConfig_Feature.CUSTOM_LOGO;
- case 66:
+ case 67:
case "WATERMARK":
return PlanLimitConfig_Feature.WATERMARK;
- case 67:
+ case 68:
case "ROADMAP_PRIORITIZATION":
return PlanLimitConfig_Feature.ROADMAP_PRIORITIZATION;
- case 68:
+ case 69:
case "CUSTOM_MSA":
return PlanLimitConfig_Feature.CUSTOM_MSA;
- case 69:
+ case 70:
case "COMMUNITY_SUPPORT":
return PlanLimitConfig_Feature.COMMUNITY_SUPPORT;
- case 70:
+ case 71:
case "EMAIL_SUPPORT":
return PlanLimitConfig_Feature.EMAIL_SUPPORT;
- case 71:
+ case 72:
case "DEDICATED_SUPPORT_WITH_SLA":
return PlanLimitConfig_Feature.DEDICATED_SUPPORT_WITH_SLA;
case -1:
@@ -562,6 +566,8 @@ export function planLimitConfig_FeatureToJSON(object: PlanLimitConfig_Feature):
return "DATABASE_GROUPS";
case PlanLimitConfig_Feature.ENVIRONMENT_TIERS:
return "ENVIRONMENT_TIERS";
+ case PlanLimitConfig_Feature.DASHBOARD_ANNOUNCEMENT:
+ return "DASHBOARD_ANNOUNCEMENT";
case PlanLimitConfig_Feature.API_INTEGRATION_GUIDANCE:
return "API_INTEGRATION_GUIDANCE";
case PlanLimitConfig_Feature.CUSTOM_LOGO:
@@ -714,22 +720,24 @@ export function planLimitConfig_FeatureToNumber(object: PlanLimitConfig_Feature)
return 62;
case PlanLimitConfig_Feature.ENVIRONMENT_TIERS:
return 63;
- case PlanLimitConfig_Feature.API_INTEGRATION_GUIDANCE:
+ case PlanLimitConfig_Feature.DASHBOARD_ANNOUNCEMENT:
return 64;
- case PlanLimitConfig_Feature.CUSTOM_LOGO:
+ case PlanLimitConfig_Feature.API_INTEGRATION_GUIDANCE:
return 65;
- case PlanLimitConfig_Feature.WATERMARK:
+ case PlanLimitConfig_Feature.CUSTOM_LOGO:
return 66;
- case PlanLimitConfig_Feature.ROADMAP_PRIORITIZATION:
+ case PlanLimitConfig_Feature.WATERMARK:
return 67;
- case PlanLimitConfig_Feature.CUSTOM_MSA:
+ case PlanLimitConfig_Feature.ROADMAP_PRIORITIZATION:
return 68;
- case PlanLimitConfig_Feature.COMMUNITY_SUPPORT:
+ case PlanLimitConfig_Feature.CUSTOM_MSA:
return 69;
- case PlanLimitConfig_Feature.EMAIL_SUPPORT:
+ case PlanLimitConfig_Feature.COMMUNITY_SUPPORT:
return 70;
- case PlanLimitConfig_Feature.DEDICATED_SUPPORT_WITH_SLA:
+ case PlanLimitConfig_Feature.EMAIL_SUPPORT:
return 71;
+ case PlanLimitConfig_Feature.DEDICATED_SUPPORT_WITH_SLA:
+ return 72;
case PlanLimitConfig_Feature.UNRECOGNIZED:
default:
return -1;
diff --git a/proto/gen/grpc-doc/v1/README.md b/proto/gen/grpc-doc/v1/README.md
index 749bb44c32..9361944701 100644
--- a/proto/gen/grpc-doc/v1/README.md
+++ b/proto/gen/grpc-doc/v1/README.md
@@ -4149,14 +4149,15 @@ Feature represents the available features in Bytebase
| TERRAFORM_PROVIDER | 61 | |
| DATABASE_GROUPS | 62 | |
| ENVIRONMENT_TIERS | 63 | |
-| API_INTEGRATION_GUIDANCE | 64 | |
-| CUSTOM_LOGO | 65 | |
-| WATERMARK | 66 | |
-| ROADMAP_PRIORITIZATION | 67 | |
-| CUSTOM_MSA | 68 | |
-| COMMUNITY_SUPPORT | 69 | |
-| EMAIL_SUPPORT | 70 | |
-| DEDICATED_SUPPORT_WITH_SLA | 71 | |
+| DASHBOARD_ANNOUNCEMENT | 64 | |
+| API_INTEGRATION_GUIDANCE | 65 | |
+| CUSTOM_LOGO | 66 | |
+| WATERMARK | 67 | |
+| ROADMAP_PRIORITIZATION | 68 | |
+| CUSTOM_MSA | 69 | |
+| COMMUNITY_SUPPORT | 70 | |
+| EMAIL_SUPPORT | 71 | |
+| DEDICATED_SUPPORT_WITH_SLA | 72 | |
diff --git a/proto/gen/grpc-doc/v1/index.html b/proto/gen/grpc-doc/v1/index.html
index 8397fd7d96..11ec7a0b7e 100644
--- a/proto/gen/grpc-doc/v1/index.html
+++ b/proto/gen/grpc-doc/v1/index.html
@@ -12505,53 +12505,59 @@ The access is based on approval flow.</p></td>
</tr>
<tr>
- <td>API_INTEGRATION_GUIDANCE</td>
+ <td>DASHBOARD_ANNOUNCEMENT</td>
<td>64</td>
<td><p></p></td>
</tr>
<tr>
- <td>CUSTOM_LOGO</td>
+ <td>API_INTEGRATION_GUIDANCE</td>
<td>65</td>
<td><p></p></td>
</tr>
<tr>
- <td>WATERMARK</td>
+ <td>CUSTOM_LOGO</td>
<td>66</td>
<td><p></p></td>
</tr>
<tr>
- <td>ROADMAP_PRIORITIZATION</td>
+ <td>WATERMARK</td>
<td>67</td>
<td><p></p></td>
</tr>
<tr>
- <td>CUSTOM_MSA</td>
+ <td>ROADMAP_PRIORITIZATION</td>
<td>68</td>
<td><p></p></td>
</tr>
<tr>
- <td>COMMUNITY_SUPPORT</td>
+ <td>CUSTOM_MSA</td>
<td>69</td>
<td><p></p></td>
</tr>
<tr>
- <td>EMAIL_SUPPORT</td>
+ <td>COMMUNITY_SUPPORT</td>
<td>70</td>
<td><p></p></td>
</tr>
<tr>
- <td>DEDICATED_SUPPORT_WITH_SLA</td>
+ <td>EMAIL_SUPPORT</td>
<td>71</td>
<td><p></p></td>
</tr>
+ <tr>
+ <td>DEDICATED_SUPPORT_WITH_SLA</td>
+ <td>72</td>
+ <td><p></p></td>
+ </tr>
+
</tbody>
</table>
diff --git a/proto/generated-go/v1/subscription_service.pb.go b/proto/generated-go/v1/subscription_service.pb.go
index 19c8f0ee6e..1a3566e193 100644
--- a/proto/generated-go/v1/subscription_service.pb.go
+++ b/proto/generated-go/v1/subscription_service.pb.go
@@ -147,14 +147,15 @@ const (
PlanLimitConfig_TERRAFORM_PROVIDER PlanLimitConfig_Feature = 61
PlanLimitConfig_DATABASE_GROUPS PlanLimitConfig_Feature = 62
PlanLimitConfig_ENVIRONMENT_TIERS PlanLimitConfig_Feature = 63
- PlanLimitConfig_API_INTEGRATION_GUIDANCE PlanLimitConfig_Feature = 64
- PlanLimitConfig_CUSTOM_LOGO PlanLimitConfig_Feature = 65
- PlanLimitConfig_WATERMARK PlanLimitConfig_Feature = 66
- PlanLimitConfig_ROADMAP_PRIORITIZATION PlanLimitConfig_Feature = 67
- PlanLimitConfig_CUSTOM_MSA PlanLimitConfig_Feature = 68
- PlanLimitConfig_COMMUNITY_SUPPORT PlanLimitConfig_Feature = 69
- PlanLimitConfig_EMAIL_SUPPORT PlanLimitConfig_Feature = 70
- PlanLimitConfig_DEDICATED_SUPPORT_WITH_SLA PlanLimitConfig_Feature = 71
+ PlanLimitConfig_DASHBOARD_ANNOUNCEMENT PlanLimitConfig_Feature = 64
+ PlanLimitConfig_API_INTEGRATION_GUIDANCE PlanLimitConfig_Feature = 65
+ PlanLimitConfig_CUSTOM_LOGO PlanLimitConfig_Feature = 66
+ PlanLimitConfig_WATERMARK PlanLimitConfig_Feature = 67
+ PlanLimitConfig_ROADMAP_PRIORITIZATION PlanLimitConfig_Feature = 68
+ PlanLimitConfig_CUSTOM_MSA PlanLimitConfig_Feature = 69
+ PlanLimitConfig_COMMUNITY_SUPPORT PlanLimitConfig_Feature = 70
+ PlanLimitConfig_EMAIL_SUPPORT PlanLimitConfig_Feature = 71
+ PlanLimitConfig_DEDICATED_SUPPORT_WITH_SLA PlanLimitConfig_Feature = 72
)
// Enum value maps for PlanLimitConfig_Feature.
@@ -224,14 +225,15 @@ var (
61: "TERRAFORM_PROVIDER",
62: "DATABASE_GROUPS",
63: "ENVIRONMENT_TIERS",
- 64: "API_INTEGRATION_GUIDANCE",
- 65: "CUSTOM_LOGO",
- 66: "WATERMARK",
- 67: "ROADMAP_PRIORITIZATION",
- 68: "CUSTOM_MSA",
- 69: "COMMUNITY_SUPPORT",
- 70: "EMAIL_SUPPORT",
- 71: "DEDICATED_SUPPORT_WITH_SLA",
+ 64: "DASHBOARD_ANNOUNCEMENT",
+ 65: "API_INTEGRATION_GUIDANCE",
+ 66: "CUSTOM_LOGO",
+ 67: "WATERMARK",
+ 68: "ROADMAP_PRIORITIZATION",
+ 69: "CUSTOM_MSA",
+ 70: "COMMUNITY_SUPPORT",
+ 71: "EMAIL_SUPPORT",
+ 72: "DEDICATED_SUPPORT_WITH_SLA",
}
PlanLimitConfig_Feature_value = map[string]int32{
"FEATURE_UNSPECIFIED": 0,
@@ -298,14 +300,15 @@ var (
"TERRAFORM_PROVIDER": 61,
"DATABASE_GROUPS": 62,
"ENVIRONMENT_TIERS": 63,
- "API_INTEGRATION_GUIDANCE": 64,
- "CUSTOM_LOGO": 65,
- "WATERMARK": 66,
- "ROADMAP_PRIORITIZATION": 67,
- "CUSTOM_MSA": 68,
- "COMMUNITY_SUPPORT": 69,
- "EMAIL_SUPPORT": 70,
- "DEDICATED_SUPPORT_WITH_SLA": 71,
+ "DASHBOARD_ANNOUNCEMENT": 64,
+ "API_INTEGRATION_GUIDANCE": 65,
+ "CUSTOM_LOGO": 66,
+ "WATERMARK": 67,
+ "ROADMAP_PRIORITIZATION": 68,
+ "CUSTOM_MSA": 69,
+ "COMMUNITY_SUPPORT": 70,
+ "EMAIL_SUPPORT": 71,
+ "DEDICATED_SUPPORT_WITH_SLA": 72,
}
)
@@ -839,12 +842,12 @@ const file_v1_subscription_service_proto_rawDesc = "" +
"\x05value\x18\x02 \x01(\bR\x05value:\x028\x01\"@\n" +
"\n" +
"PlanConfig\x122\n" +
- "\x05plans\x18\x01 \x03(\v2\x1c.bytebase.v1.PlanLimitConfigR\x05plans\"\xb3\x10\n" +
+ "\x05plans\x18\x01 \x03(\v2\x1c.bytebase.v1.PlanLimitConfigR\x05plans\"\xcf\x10\n" +
"\x0fPlanLimitConfig\x12)\n" +
"\x04type\x18\x01 \x01(\x0e2\x15.bytebase.v1.PlanTypeR\x04type\x124\n" +
"\x16maximum_instance_count\x18\x02 \x01(\x05R\x14maximumInstanceCount\x12,\n" +
"\x12maximum_seat_count\x18\x03 \x01(\x05R\x10maximumSeatCount\x12@\n" +
- "\bfeatures\x18\x04 \x03(\x0e2$.bytebase.v1.PlanLimitConfig.FeatureR\bfeatures\"\xce\x0e\n" +
+ "\bfeatures\x18\x04 \x03(\x0e2$.bytebase.v1.PlanLimitConfig.FeatureR\bfeatures\"\xea\x0e\n" +
"\aFeature\x12\x17\n" +
"\x13FEATURE_UNSPECIFIED\x10\x00\x12\x13\n" +
"\x0fDATABASE_CHANGE\x10\x01\x12$\n" +
@@ -912,16 +915,17 @@ const file_v1_subscription_service_proto_rawDesc = "" +
"\x10IM_NOTIFICATIONS\x10<\x12\x16\n" +
"\x12TERRAFORM_PROVIDER\x10=\x12\x13\n" +
"\x0fDATABASE_GROUPS\x10>\x12\x15\n" +
- "\x11ENVIRONMENT_TIERS\x10?\x12\x1c\n" +
- "\x18API_INTEGRATION_GUIDANCE\x10@\x12\x0f\n" +
- "\vCUSTOM_LOGO\x10A\x12\r\n" +
- "\tWATERMARK\x10B\x12\x1a\n" +
- "\x16ROADMAP_PRIORITIZATION\x10C\x12\x0e\n" +
+ "\x11ENVIRONMENT_TIERS\x10?\x12\x1a\n" +
+ "\x16DASHBOARD_ANNOUNCEMENT\x10@\x12\x1c\n" +
+ "\x18API_INTEGRATION_GUIDANCE\x10A\x12\x0f\n" +
+ "\vCUSTOM_LOGO\x10B\x12\r\n" +
+ "\tWATERMARK\x10C\x12\x1a\n" +
+ "\x16ROADMAP_PRIORITIZATION\x10D\x12\x0e\n" +
"\n" +
- "CUSTOM_MSA\x10D\x12\x15\n" +
- "\x11COMMUNITY_SUPPORT\x10E\x12\x11\n" +
- "\rEMAIL_SUPPORT\x10F\x12\x1e\n" +
- "\x1aDEDICATED_SUPPORT_WITH_SLA\x10G*I\n" +
+ "CUSTOM_MSA\x10E\x12\x15\n" +
+ "\x11COMMUNITY_SUPPORT\x10F\x12\x11\n" +
+ "\rEMAIL_SUPPORT\x10G\x12\x1e\n" +
+ "\x1aDEDICATED_SUPPORT_WITH_SLA\x10H*I\n" +
"\bPlanType\x12\x19\n" +
"\x15PLAN_TYPE_UNSPECIFIED\x10\x00\x12\b\n" +
"\x04FREE\x10\x01\x12\b\n" +
diff --git a/proto/v1/v1/subscription_service.proto b/proto/v1/v1/subscription_service.proto
index 60ea965aa1..1d63cfaf49 100644
--- a/proto/v1/v1/subscription_service.proto
+++ b/proto/v1/v1/subscription_service.proto
@@ -167,14 +167,15 @@ message PlanLimitConfig {
TERRAFORM_PROVIDER = 61;
DATABASE_GROUPS = 62;
ENVIRONMENT_TIERS = 63;
- API_INTEGRATION_GUIDANCE = 64;
- CUSTOM_LOGO = 65;
- WATERMARK = 66;
- ROADMAP_PRIORITIZATION = 67;
- CUSTOM_MSA = 68;
- COMMUNITY_SUPPORT = 69;
- EMAIL_SUPPORT = 70;
- DEDICATED_SUPPORT_WITH_SLA = 71;
+ DASHBOARD_ANNOUNCEMENT = 64;
+ API_INTEGRATION_GUIDANCE = 65;
+ CUSTOM_LOGO = 66;
+ WATERMARK = 67;
+ ROADMAP_PRIORITIZATION = 68;
+ CUSTOM_MSA = 69;
+ COMMUNITY_SUPPORT = 70;
+ EMAIL_SUPPORT = 71;
+ DEDICATED_SUPPORT_WITH_SLA = 72;
}
PlanType type = 1;