mirror of
https://gitee.com/rainbond/Rainbond.git
synced 2024-11-30 10:48:15 +08:00
added service change app_id method
This commit is contained in:
parent
7c6f9303bd
commit
3a5d622a5e
@ -717,6 +717,7 @@ func (t *TenantStruct) UpdateService(w http.ResponseWriter, r *http.Request) {
|
||||
"container_memory": []string{},
|
||||
"service_name": []string{},
|
||||
"extend_method": []string{},
|
||||
"app_id": []string{},
|
||||
}
|
||||
data, ok := httputil.ValidatorRequestMapAndErrorResponse(r, w, rules, nil)
|
||||
if !ok {
|
||||
@ -724,6 +725,22 @@ func (t *TenantStruct) UpdateService(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
serviceID := r.Context().Value(middleware.ContextKey("service_id")).(string)
|
||||
data["service_id"] = serviceID
|
||||
|
||||
// Check if the application ID exists
|
||||
var appID string
|
||||
if data["app_id"] != nil {
|
||||
appID = data["app_id"].(string)
|
||||
}
|
||||
_, err := handler.GetTenantApplicationHandler().GetAppByID(appID)
|
||||
if err != nil || appID == "" {
|
||||
if err.Error() == gorm.ErrRecordNotFound.Error() {
|
||||
httputil.ReturnError(r, w, 404, "can't find application")
|
||||
return
|
||||
}
|
||||
httputil.ReturnError(r, w, 500, "get assign tenant application failed")
|
||||
return
|
||||
}
|
||||
|
||||
logrus.Debugf("begin to update service")
|
||||
if err := handler.GetServiceManager().ServiceUpdate(data); err != nil {
|
||||
httputil.ReturnError(r, w, 500, fmt.Sprintf("update service error, %v", err))
|
||||
|
@ -28,10 +28,10 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/coreos/etcd/clientv3"
|
||||
"github.com/jinzhu/gorm"
|
||||
"github.com/pquerna/ffjson/ffjson"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/twinj/uuid"
|
||||
|
||||
"github.com/goodrain/rainbond/api/proxy"
|
||||
@ -744,6 +744,7 @@ func (s *ServiceAction) ServiceUpdate(sc map[string]interface{}) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ts.AppID = sc["app_id"].(string)
|
||||
version, err := db.GetManager().VersionInfoDao().GetVersionByDeployVersion(ts.DeployVersion, ts.ServiceID)
|
||||
if sc["container_memory"] != nil {
|
||||
ts.ContainerMemory = sc["container_memory"].(int)
|
||||
|
Loading…
Reference in New Issue
Block a user