mirror of
https://gitee.com/rainbond/Rainbond.git
synced 2024-11-29 18:27:58 +08:00
Merge pull request #869 from GLYASAI/update-application
New Feature: update application governance_mode
This commit is contained in:
commit
3c7716924e
@ -72,7 +72,7 @@ func (a *ApplicationAction) CreateApp(req *model.Application) (*model.Applicatio
|
||||
return nil, err
|
||||
}
|
||||
if len(req.ServiceIDs) != 0 {
|
||||
for _,sid := range req.ServiceIDs {
|
||||
for _, sid := range req.ServiceIDs {
|
||||
if _, err := db.GetManager().TenantServiceDao().GetServiceByID(sid); err != nil {
|
||||
tx.Rollback()
|
||||
return nil, err
|
||||
@ -93,7 +93,15 @@ func (a *ApplicationAction) CreateApp(req *model.Application) (*model.Applicatio
|
||||
|
||||
// UpdateApp -
|
||||
func (a *ApplicationAction) UpdateApp(srcApp *dbmodel.Application, req model.UpdateAppRequest) (*dbmodel.Application, error) {
|
||||
srcApp.AppName = req.AppName
|
||||
if req.AppName != "" {
|
||||
srcApp.AppName = req.AppName
|
||||
}
|
||||
if req.GovernanceMode != "" {
|
||||
if !dbmodel.IsGovernanceModeValid(req.GovernanceMode) {
|
||||
return nil, bcode.NewBadRequest(fmt.Sprintf("governance mode '%s' is valid", req.GovernanceMode))
|
||||
}
|
||||
srcApp.GovernanceMode = req.GovernanceMode
|
||||
}
|
||||
if err := db.GetManager().ApplicationDao().UpdateModel(srcApp); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -249,9 +257,9 @@ func (a *ApplicationAction) getDiskUsage(appID string) float64 {
|
||||
return result
|
||||
}
|
||||
|
||||
//BatchBindService
|
||||
// BatchBindService -
|
||||
func (a *ApplicationAction) BatchBindService(appID string, req model.BindServiceRequest) error {
|
||||
for _,sid := range req.ServiceIDs {
|
||||
for _, sid := range req.ServiceIDs {
|
||||
if _, err := db.GetManager().TenantServiceDao().GetServiceByID(sid); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -1653,7 +1653,8 @@ type ListServiceResponse struct {
|
||||
|
||||
// UpdateAppRequest -
|
||||
type UpdateAppRequest struct {
|
||||
AppName string `json:"app_name" validate:"required"`
|
||||
AppName string `json:"app_name"`
|
||||
GovernanceMode string `json:"governance_mode"`
|
||||
}
|
||||
|
||||
// BindServiceRequest -
|
||||
|
@ -2,18 +2,23 @@ package model
|
||||
|
||||
const (
|
||||
// GovernanceModeBuildInServiceMesh means the governance mode is BUILD_IN_SERVICE_MESH
|
||||
GovernanceModeBuildInServiceMesh = "build_in_service_mesh"
|
||||
GovernanceModeBuildInServiceMesh = "BUILD_IN_SERVICE_MESH"
|
||||
// GovernanceModeKubernetesNativeService means the governance mode is KUBERNETES_NATIVE_SERVICE
|
||||
GovernanceModeKubernetesNativeService = "kubernetes_native_service"
|
||||
GovernanceModeKubernetesNativeService = "KUBERNETES_NATIVE_SERVICE"
|
||||
)
|
||||
|
||||
// IsGovernanceModeValid checks if the governanceMode is valid.
|
||||
func IsGovernanceModeValid(governanceMode string) bool {
|
||||
return governanceMode == GovernanceModeBuildInServiceMesh || governanceMode == GovernanceModeKubernetesNativeService
|
||||
}
|
||||
|
||||
// Application -
|
||||
type Application struct {
|
||||
Model
|
||||
AppName string `gorm:"column:app_name" json:"app_name"`
|
||||
AppID string `gorm:"column:app_id" json:"app_id"`
|
||||
TenantID string `gorm:"column:tenant_id" json:"tenant_id"`
|
||||
GovernanceMode string `gorm:"column:governance_mode;default:'build_in_service_mesh'" json:"governance_mode"`
|
||||
GovernanceMode string `gorm:"column:governance_mode;default:'BUILD_IN_SERVICE_MESH'" json:"governance_mode"`
|
||||
}
|
||||
|
||||
// TableName return tableName "application"
|
||||
|
Loading…
Reference in New Issue
Block a user