Skip to content

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

chore: update plan config (#6957)

ecmadao1c5cfc797cee
diff --git a/.github/workflows/frontend-tests.yml b/.github/workflows/frontend-tests.yml
index 80c6adc926..ca966e2af5 100644
--- a/.github/workflows/frontend-tests.yml
+++ b/.github/workflows/frontend-tests.yml
@@ -46,6 +46,5 @@ jobs:
working-directory: frontend
- name: Run pnpm release build
run: |
- cp ../backend/plugin/advisor/config/* ./src/types
pnpm release-docker
working-directory: frontend
diff --git a/.golangci.yaml b/.golangci.yaml
index 48f84ff6da..fca6e55aae 100644
--- a/.golangci.yaml
+++ b/.golangci.yaml
@@ -87,7 +87,7 @@ linters-settings:
govet:
settings:
printf: # The name of the analyzer, run `go tool vet help` to see the list of all analyzers
- funcs: # Run `go tool vet help printf` to see the full configuration of `printf`
+ funcs: # Run `go tool vet help printf` to see the full configuration of `printf`.
- common.Errorf
forbidigo:
forbid:
diff --git a/backend/enterprise/api/license.go b/backend/enterprise/api/license.go
index b35ce0fbcd..e74991db8e 100644
--- a/backend/enterprise/api/license.go
+++ b/backend/enterprise/api/license.go
@@ -3,7 +3,6 @@ package api
import (
"context"
- "math"
"strings"
"time"
@@ -13,28 +12,6 @@ import (
"github.com/bytebase/bytebase/backend/store"
)
-// PlanLimit is the type for plan limits.
-type PlanLimit int
-
-const (
- // PlanLimitMaximumTask is the key name for maximum number of tasks for a plan.
- PlanLimitMaximumTask PlanLimit = iota
- // PlanLimitMaximumEnvironment is the key name for maximum number of environments for a plan.
- PlanLimitMaximumEnvironment
- // PlanLimitMaximumInstance is the key name for maximum number of instance for a plan.
- PlanLimitMaximumInstance
- // PlanLimitMaximumUser is the key name for maximum number of user for a plan.
- PlanLimitMaximumUser
-)
-
-// PlanLimitValues is the plan limit value mapping.
-var PlanLimitValues = map[PlanLimit][3]int64{
- PlanLimitMaximumTask: {math.MaxInt64, math.MaxInt64, math.MaxInt64},
- PlanLimitMaximumEnvironment: {math.MaxInt64, math.MaxInt64, math.MaxInt64},
- PlanLimitMaximumInstance: {20, 20, math.MaxInt64},
- PlanLimitMaximumUser: {20, math.MaxInt64, math.MaxInt64},
-}
-
// validPlans is a string array of valid plan types.
var validPlans = []api.PlanType{
api.TEAM,
diff --git a/backend/enterprise/api/limit.go b/backend/enterprise/api/limit.go
new file mode 100644
index 0000000000..4832d27440
--- /dev/null
+++ b/backend/enterprise/api/limit.go
@@ -0,0 +1,58 @@
+package api
+
+import (
+ _ "embed"
+
+ "gopkg.in/yaml.v3"
+
+ api "github.com/bytebase/bytebase/backend/legacyapi"
+)
+
+//go:embed plan.yaml
+var planConfigStr string
+
+// PlanLimit is the type for plan limits.
+type PlanLimit int
+
+const (
+ // PlanLimitMaximumTask is the key name for maximum number of tasks for a plan.
+ PlanLimitMaximumTask PlanLimit = iota
+ // PlanLimitMaximumEnvironment is the key name for maximum number of environments for a plan.
+ PlanLimitMaximumEnvironment
+ // PlanLimitMaximumInstance is the key name for maximum number of instance for a plan.
+ PlanLimitMaximumInstance
+ // PlanLimitMaximumUser is the key name for maximum number of user for a plan.
+ PlanLimitMaximumUser
+)
+
+// PlanLimitValues is the plan limit value mapping.
+var PlanLimitValues = map[PlanLimit]map[api.PlanType]int64{
+ PlanLimitMaximumTask: {},
+ PlanLimitMaximumEnvironment: {},
+ PlanLimitMaximumInstance: {},
+ PlanLimitMaximumUser: {},
+}
+
+type planLimitConfig struct {
+ Type api.PlanType `yaml:"type"`
+ MaximumInstanceCount int64 `yaml:"maximumInstanceCount"`
+ MaximumSeatCount int64 `yaml:"maximumSeatCount"`
+ MaximumTaskCount int64 `yaml:"maximumTaskCount"`
+ MaximumEnvironmentCount int64 `yaml:"maximumEnvironmentCount"`
+}
+
+type planConfg struct {
+ PlanList []*planLimitConfig `yaml:"planList"`
+}
+
+func init() {
+ conf := &planConfg{}
+ _ = yaml.Unmarshal([]byte(planConfigStr), conf)
+
+ for _, limitConfig := range conf.PlanList {
+ PlanLimitValues[PlanLimitMaximumTask][limitConfig.Type] = limitConfig.MaximumTaskCount
+ PlanLimitValues[PlanLimitMaximumEnvironment][limitConfig.Type] = limitConfig.MaximumEnvironmentCount
+ PlanLimitValues[PlanLimitMaximumInstance][limitConfig.Type] = limitConfig.MaximumInstanceCount
+ PlanLimitValues[PlanLimitMaximumUser][limitConfig.Type] = limitConfig.MaximumSeatCount
+ }
+}
diff --git a/frontend/src/types/plan.yaml b/backend/enterprise/api/plan.yaml
similarity index 97%
rename from frontend/src/types/plan.yaml
rename to backend/enterprise/api/plan.yaml
index 997cc3cfd5..149616eed0 100644
--- a/frontend/src/types/plan.yaml
+++ b/backend/enterprise/api/plan.yaml
@@ -60,10 +60,12 @@ planList:
trialDays: 0
unitPrice: 0
trialPrice: 0
- freeSeatCount: -1
+ freeSeatCount: 20
freeInstanceCount: 20
maximumInstanceCount: 20
- maximumSeatCount: -1
+ maximumSeatCount: 20
+ maximumTaskCount: -1
+ maximumEnvironmentCount: -1
pricePerSeatPerMonth: 0
pricePerInstancePerMonth: 0
featureList:
@@ -132,6 +134,8 @@ planList:
freeInstanceCount: 0
maximumInstanceCount: 20
maximumSeatCount: -1
+ maximumTaskCount: -1
+ maximumEnvironmentCount: -1
pricePerSeatPerMonth: 0
pricePerInstancePerMonth: 100
featureList:
@@ -202,6 +206,8 @@ planList:
freeInstanceCount: 0
maximumInstanceCount: -1
maximumSeatCount: -1
+ maximumTaskCount: -1
+ maximumEnvironmentCount: -1
pricePerSeatPerMonth: 0
pricePerInstancePerMonth: 300
featureList:
diff --git a/backend/enterprise/service/license.go b/backend/enterprise/service/license.go
index eeb7d464c2..9ba44addb3 100644
--- a/backend/enterprise/service/license.go
+++ b/backend/enterprise/service/license.go
@@ -156,7 +156,11 @@ func (s *LicenseService) GetPlanLimitValue(name enterpriseAPI.PlanLimit) int64 {
if !ok {
return 0
}
- return v[s.GetEffectivePlan()]
+ limit := v[s.GetEffectivePlan()]
+ if limit == -1 {
+ return math.MaxInt64
+ }
+ return limit
}
// RefreshCache will invalidate and refresh the subscription cache.
diff --git a/frontend/package.json b/frontend/package.json
index 3a55d4d1f8..957989e892 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -2,16 +2,16 @@
"name": "bytebase",
"license": "SEE LICENSE IN LICENSE",
"scripts": {
- "dev": "npm run copy-sql-review-file && vite --mode dev-local",
- "release": "export NODE_OPTIONS=--max_old_space_size=4096 && npm run copy-sql-review-file && vite build --mode release --outDir=../backend/server/dist --emptyOutDir",
- "dev-embed": "export NODE OPTIONS=--max_old_space_size=4096 && npm run copy-sql-review-file && vite build --mode dev --outDir=../backend/server/dist --emptyOutDir",
- "dev-docker": "export NODE_OPTIONS=--max_old_space_size=4096 && vite build --mode dev",
- "release-docker": "export NODE_OPTIONS=--max_old_space_size=4096 && vite build --mode release",
+ "dev": "npm run copy-config-file && vite --mode dev-local",
+ "release": "export NODE_OPTIONS=--max_old_space_size=4096 && npm run copy-config-file && vite build --mode release --outDir=../backend/server/dist --emptyOutDir",
+ "dev-embed": "export NODE OPTIONS=--max_old_space_size=4096 && npm run copy-config-file && vite build --mode dev --outDir=../backend/server/dist --emptyOutDir",
+ "dev-docker": "export NODE_OPTIONS=--max_old_space_size=4096 && npm run copy-config-file && vite build --mode dev",
+ "release-docker": "export NODE_OPTIONS=--max_old_space_size=4096 && npm run copy-config-file && vite build --mode release",
"lint": "eslint --cache --ext .js,.ts,.tsx,.vue src",
"lint:fix": "eslint --cache --ext .js,.ts,.tsx,.vue --fix src",
"test": "vitest run",
"coverage": "vitest --coverage",
- "copy-sql-review-file": "sh ./scripts/copy_sql_review_files.sh"
+ "copy-config-file": "sh ./scripts/copy_config_files.sh"
},
"dependencies": {
"@bytebase/vue-kbar": "0.1.8",
diff --git a/frontend/scripts/copy_config_files.sh b/frontend/scripts/copy_config_files.sh
new file mode 100644
index 0000000000..6d867e1e1f
--- /dev/null
+++ b/frontend/scripts/copy_config_files.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+cp ../backend/plugin/advisor/config/* ./src/types/
+cp ../backend/enterprise/api/plan.yaml ./src/types/
\ No newline at end of file
diff --git a/frontend/scripts/copy_sql_review_files.sh b/frontend/scripts/copy_sql_review_files.sh
deleted file mode 100644
index 5eb3b2fd70..0000000000
--- a/frontend/scripts/copy_sql_review_files.sh
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/bin/sh
-cp ../backend/plugin/advisor/config/* ./src/types/
\ No newline at end of file