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 (#2131)
Danny Xuab6edecdcdbf
diff --git a/api/plan.go b/api/plan.goindex 77bd5adaa6..478f9cc1d4 100644--- a/api/plan.go+++ b/api/plan.go@@ -1,6 +1,9 @@package api-import "fmt"+import (+ "fmt"+ "math"+)// PlanType is the type for a plan.type PlanType int@@ -184,3 +187,16 @@ type Plan struct {type PlanPatch struct {Type PlanType `jsonapi:"attr,type"`}++// PlanLimit is the type for plan limits.+type PlanLimit int++const (+ // PlanLimitMaxmimumTask is the key name for maximum number of tasks for a plan.+ PlanLimitMaxmimumTask PlanLimit = iota+)++// PlanLimitValues is the plan limit value mapping.+var PlanLimitValues = map[PlanLimit][3]int64{+ PlanLimitMaxmimumTask: {4, math.MaxInt64, math.MaxInt64},+}diff --git a/server/issue.go b/server/issue.goindex 7e33249f13..483e6cc554 100644--- a/server/issue.go+++ b/server/issue.go@@ -711,6 +711,11 @@ func (s *Server) getPipelineCreateForDatabaseSchemaAndDataUpdate(ctx context.Con}}} else {+ maximumTaskLimit := s.getPlanLimitValue(api.PlanLimitMaxmimumTask)+ if int64(len(c.DetailList)) > maximumTaskLimit {+ return nil, echo.NewHTTPError(http.StatusForbidden, fmt.Sprintf("Effective plan %s can update up to %d databases, got %d.", s.getEffectivePlan(), maximumTaskLimit, len(c.DetailList)))+ }+type envKey struct {name stringid intdiff --git a/server/subscription.go b/server/subscription.goindex 9c20efe511..3c1ccb8353 100644--- a/server/subscription.go+++ b/server/subscription.go@@ -94,8 +94,20 @@ func (s *Server) loadLicense() (*enterpriseAPI.License, error) {}func (s *Server) feature(feature api.FeatureType) bool {+ return api.FeatureMatrix[feature][s.getEffectivePlan()]+}++func (s *Server) getPlanLimitValue(name api.PlanLimit) int64 {+ v, ok := api.PlanLimitValues[name]+ if !ok {+ return 0+ }+ return v[s.getEffectivePlan()]+}++func (s *Server) getEffectivePlan() api.PlanType {if expireTime := time.Unix(s.subscription.ExpiresTs, 0); expireTime.Before(time.Now()) {- return api.FeatureMatrix[feature][api.FREE]+ return api.FREE}- return api.FeatureMatrix[feature][s.subscription.Plan]+ return s.subscription.Plan}