mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-11-07 18:50:26 +08:00
创建集群时自动创建缓存策略和WAF策略
This commit is contained in:
@@ -30,6 +30,7 @@ func (this *NodeClusterService) CreateNodeCluster(ctx context.Context, req *pb.C
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// 系统服务
|
||||
systemServices := map[string]maps.Map{}
|
||||
if len(req.SystemServicesJSON) > 0 {
|
||||
err = json.Unmarshal(req.SystemServicesJSON, &systemServices)
|
||||
@@ -40,6 +41,24 @@ func (this *NodeClusterService) CreateNodeCluster(ctx context.Context, req *pb.C
|
||||
|
||||
var clusterId int64
|
||||
err = this.RunTx(func(tx *dbs.Tx) error {
|
||||
// 缓存策略
|
||||
if req.HttpCachePolicyId <= 0 {
|
||||
policyId, err := models.SharedHTTPCachePolicyDAO.CreateDefaultCachePolicy(tx, req.Name)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
req.HttpCachePolicyId = policyId
|
||||
}
|
||||
|
||||
// WAF策略
|
||||
if req.HttpFirewallPolicyId <= 0 {
|
||||
policyId, err := models.SharedHTTPFirewallPolicyDAO.CreateDefaultFirewallPolicy(tx, req.Name)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
req.HttpFirewallPolicyId = policyId
|
||||
}
|
||||
|
||||
clusterId, err = models.SharedNodeClusterDAO.CreateCluster(tx, adminId, req.Name, req.NodeGrantId, req.InstallDir, req.DnsDomainId, req.DnsName, req.HttpCachePolicyId, req.HttpFirewallPolicyId, systemServices)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user