code refactory (#403)

* support tt automation by job

* format

* import order

* use map to avoid repetition

* add api for sync from ccp by force

* fix bug

* code refactory

* delete unused code

* delete func

* code refactory

* rename labels key

Co-authored-by: dujiashu <dujiashu@didiglobal.com>
This commit is contained in:
dujiashu 2020-11-16 16:29:42 +08:00 committed by GitHub
parent 86df27587e
commit 3f352a393b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 6 deletions

View File

@ -128,8 +128,6 @@ func Config(r *gin.Engine) {
userLogin.PUT("/resources/note", resourceNotePut)
userLogin.GET("/resources/bindings", resourceBindingsGet)
userLogin.GET("/resources/orphan", resourceOrphanGet)
userLogin.POST("/container/sync", containerSyncPost)
}
v1 := r.Group("/v1/rdb").Use(shouldBeService())
@ -142,6 +140,7 @@ func Config(r *gin.Engine) {
v1.POST("/resources/unregister", v1ResourcesUnregisterPost)
v1.POST("/containers/bind", v1ContainersBindPost)
v1.POST("/container/sync", v1ContainerSyncPost)
// 发送邮件、短信、语音、即时通讯消息,这些都依赖客户那边的通道
v1.POST("/sender/mail", v1SendMail)

View File

@ -20,10 +20,11 @@ func resourceSearchGet(c *gin.Context) {
type containerSyncForm struct {
Name string `json:"name" binding:"required"`
Type string `json:"type" binding:"type"`
Items []v1ContainersRegisterItem `json:"items"`
}
func containerSyncPost(c *gin.Context) {
func v1ContainerSyncPost(c *gin.Context) {
var sf containerSyncForm
bind(c, &sf)
@ -32,7 +33,7 @@ func containerSyncPost(c *gin.Context) {
)
list, err := models.ResourceGets("labels like ?",
fmt.Sprintf("%%,resourceName=%s%%", sf.Name))
fmt.Sprintf("%%,res_type=%s,res_name=%s%%", sf.Type, sf.Name))
dangerous(err)
for _, l := range list {
@ -114,8 +115,6 @@ func resourceHttpRegister(count int, items []v1ContainersRegisterItem) {
dangerous(innerCateNode.Bind([]int64{res.Id}))
}
return
}
// 游离资源页面修改备注,超级管理员,或者是租户管理员