Skip to content

Commit 762454c

Browse files
authored
feat: add cdn cluster id for scheduler cluster (#580)
* feat: add cdn cluster id * docs: swagger api Signed-off-by: Gaius <gaius.qi@gmail.com>
1 parent f0f55db commit 762454c

File tree

6 files changed

+43
-1
lines changed

6 files changed

+43
-1
lines changed

api/manager/docs.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1839,6 +1839,9 @@ var doc = `{
18391839
"bio": {
18401840
"type": "string"
18411841
},
1842+
"cdn_cluster_id": {
1843+
"type": "integer"
1844+
},
18421845
"client_config": {
18431846
"type": "object",
18441847
"additionalProperties": true
@@ -2012,6 +2015,9 @@ var doc = `{
20122015
"bio": {
20132016
"type": "string"
20142017
},
2018+
"cdn_cluster_id": {
2019+
"type": "integer"
2020+
},
20152021
"client_config": {
20162022
"type": "object",
20172023
"additionalProperties": true

api/manager/swagger.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1824,6 +1824,9 @@
18241824
"bio": {
18251825
"type": "string"
18261826
},
1827+
"cdn_cluster_id": {
1828+
"type": "integer"
1829+
},
18271830
"client_config": {
18281831
"type": "object",
18291832
"additionalProperties": true
@@ -1997,6 +2000,9 @@
19972000
"bio": {
19982001
"type": "string"
19992002
},
2003+
"cdn_cluster_id": {
2004+
"type": "integer"
2005+
},
20002006
"client_config": {
20012007
"type": "object",
20022008
"additionalProperties": true

api/manager/swagger.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,8 @@ definitions:
212212
properties:
213213
bio:
214214
type: string
215+
cdn_cluster_id:
216+
type: integer
215217
client_config:
216218
additionalProperties: true
217219
type: object
@@ -333,6 +335,8 @@ definitions:
333335
properties:
334336
bio:
335337
type: string
338+
cdn_cluster_id:
339+
type: integer
336340
client_config:
337341
additionalProperties: true
338342
type: object

manager/router/router.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ func Init(console bool, verbose bool, publicPath string, service service.REST, e
122122
c.GET(":id", h.GetCDN)
123123
c.GET("", h.GetCDNs)
124124

125-
// roles
125+
// Role
126126
re := apiv1.Group("/roles", jwt.MiddlewareFunc(), rbac)
127127
re.POST("", h.CreateRole)
128128
re.GET("", h.GetRoles)

manager/service/scheduler_cluster.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ func (s *rest) CreateSchedulerCluster(json types.CreateSchedulerClusterRequest)
3535
return nil, err
3636
}
3737

38+
if json.CDNClusterID > 0 {
39+
if err := s.AddSchedulerClusterToCDNCluster(json.CDNClusterID, schedulerCluster.ID); err != nil {
40+
return nil, err
41+
}
42+
}
43+
3844
return &schedulerCluster, nil
3945
}
4046

@@ -59,6 +65,12 @@ func (s *rest) CreateSchedulerClusterWithSecurityGroupDomain(json types.CreateSc
5965
return nil, err
6066
}
6167

68+
if json.CDNClusterID > 0 {
69+
if err := s.AddSchedulerClusterToCDNCluster(json.CDNClusterID, schedulerCluster.ID); err != nil {
70+
return nil, err
71+
}
72+
}
73+
6274
return &schedulerCluster, nil
6375
}
6476

@@ -83,6 +95,12 @@ func (s *rest) UpdateSchedulerCluster(id uint, json types.UpdateSchedulerCluster
8395
return nil, err
8496
}
8597

98+
if json.CDNClusterID > 0 {
99+
if err := s.AddSchedulerClusterToCDNCluster(json.CDNClusterID, schedulerCluster.ID); err != nil {
100+
return nil, err
101+
}
102+
}
103+
86104
return &schedulerCluster, nil
87105
}
88106

@@ -107,6 +125,12 @@ func (s *rest) UpdateSchedulerClusterWithSecurityGroupDomain(id uint, json types
107125
return nil, err
108126
}
109127

128+
if json.CDNClusterID > 0 {
129+
if err := s.AddSchedulerClusterToCDNCluster(json.CDNClusterID, schedulerCluster.ID); err != nil {
130+
return nil, err
131+
}
132+
}
133+
110134
return &schedulerCluster, nil
111135
}
112136

manager/types/scheduler_cluster.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ type CreateSchedulerClusterRequest struct {
3232
ClientConfig map[string]interface{} `json:"client_config" binding:"required"`
3333
Scopes map[string]interface{} `json:"scopes" binding:"omitempty"`
3434
IsDefault bool `json:"is_default" binding:"omitempty"`
35+
CDNClusterID uint `json:"cdn_cluster_id" binding:"omitempty"`
3536
SecurityGroupDomain string `json:"security_group_domain" binding:"omitempty"`
3637
}
3738

@@ -42,6 +43,7 @@ type UpdateSchedulerClusterRequest struct {
4243
ClientConfig map[string]interface{} `json:"client_config" binding:"omitempty"`
4344
Scopes map[string]interface{} `json:"scopes" binding:"omitempty"`
4445
IsDefault bool `json:"is_default" binding:"omitempty"`
46+
CDNClusterID uint `json:"cdn_cluster_id" binding:"omitempty"`
4547
SecurityGroupDomain string `json:"security_group_domain" binding:"omitempty"`
4648
}
4749

0 commit comments

Comments
 (0)