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: update plan config (#6957)
ecmadao1c5cfc797cee
diff --git a/.github/workflows/frontend-tests.yml b/.github/workflows/frontend-tests.ymlindex 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 buildrun: |- cp ../backend/plugin/advisor/config/* ./src/typespnpm release-dockerworking-directory: frontenddiff --git a/.golangci.yaml b/.golangci.yamlindex 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.Errorfforbidigo:forbid:diff --git a/backend/enterprise/api/license.go b/backend/enterprise/api/license.goindex b35ce0fbcd..e74991db8e 100644--- a/backend/enterprise/api/license.go+++ b/backend/enterprise/api/license.go@@ -3,7 +3,6 @@ package apiimport ("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.gonew file mode 100644index 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.yamlsimilarity index 97%rename from frontend/src/types/plan.yamlrename to backend/enterprise/api/plan.yamlindex 997cc3cfd5..149616eed0 100644--- a/frontend/src/types/plan.yaml+++ b/backend/enterprise/api/plan.yaml@@ -60,10 +60,12 @@ planList:trialDays: 0unitPrice: 0trialPrice: 0- freeSeatCount: -1+ freeSeatCount: 20freeInstanceCount: 20maximumInstanceCount: 20- maximumSeatCount: -1+ maximumSeatCount: 20+ maximumTaskCount: -1+ maximumEnvironmentCount: -1pricePerSeatPerMonth: 0pricePerInstancePerMonth: 0featureList:@@ -132,6 +134,8 @@ planList:freeInstanceCount: 0maximumInstanceCount: 20maximumSeatCount: -1+ maximumTaskCount: -1+ maximumEnvironmentCount: -1pricePerSeatPerMonth: 0pricePerInstancePerMonth: 100featureList:@@ -202,6 +206,8 @@ planList:freeInstanceCount: 0maximumInstanceCount: -1maximumSeatCount: -1+ maximumTaskCount: -1+ maximumEnvironmentCount: -1pricePerSeatPerMonth: 0pricePerInstancePerMonth: 300featureList:diff --git a/backend/enterprise/service/license.go b/backend/enterprise/service/license.goindex 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.jsonindex 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.shnew file mode 100644index 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 filediff --git a/frontend/scripts/copy_sql_review_files.sh b/frontend/scripts/copy_sql_review_files.shdeleted file mode 100644index 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