mirror of
https://gitee.com/rainbond/Rainbond.git
synced 2024-11-29 18:27:58 +08:00
Merge branch 'master' of code.goodrain.com:goodrain/rainbond
This commit is contained in:
commit
089ad189f1
@ -1852,7 +1852,7 @@
|
||||
"tags": [
|
||||
"v2"
|
||||
],
|
||||
"summary": "获取可以修改的plugin env",
|
||||
"summary": "获取插件设定的env",
|
||||
"operationId": "getPluginEnv",
|
||||
"parameters": [
|
||||
{
|
||||
@ -3620,6 +3620,201 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/v2/tenants/{tenant_name}/services/{service_alias}/plugin/{plugin_id}/envs": {
|
||||
"get": {
|
||||
"description": "get version env",
|
||||
"consumes": [
|
||||
"application/json",
|
||||
"application/x-protobuf"
|
||||
],
|
||||
"produces": [
|
||||
"application/json",
|
||||
"application/xml"
|
||||
],
|
||||
"tags": [
|
||||
"v2"
|
||||
],
|
||||
"summary": "获取可配置的env; 从service plugin对应中取, 若不存在则返回默认可修改的变量",
|
||||
"operationId": "getVersionEnvs",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"x-go-name": "TenantName",
|
||||
"name": "tenant_name",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"x-go-name": "ServiceAlias",
|
||||
"name": "service_alias",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"x-go-name": "PluginID",
|
||||
"description": "插件id",
|
||||
"name": "plugin_id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"default": {
|
||||
"description": "统一返回格式",
|
||||
"schema": {
|
||||
"$ref": "#/responses/commandResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/v2/tenants/{tenant_name}/services/{service_alias}/plugin/{plugin_id}/setenv": {
|
||||
"post": {
|
||||
"description": "set version env",
|
||||
"consumes": [
|
||||
"application/json",
|
||||
"application/x-protobuf"
|
||||
],
|
||||
"produces": [
|
||||
"application/json",
|
||||
"application/xml"
|
||||
],
|
||||
"tags": [
|
||||
"v2"
|
||||
],
|
||||
"summary": "设置用户可配的环境变量",
|
||||
"operationId": "setVersionEnv",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"x-go-name": "TenantName",
|
||||
"name": "tenant_name",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"x-go-name": "ServiceAlias",
|
||||
"name": "service_alias",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"x-go-name": "PluginID",
|
||||
"description": "插件id",
|
||||
"name": "plugin_id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"name": "Body",
|
||||
"in": "body",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"envs"
|
||||
],
|
||||
"properties": {
|
||||
"envs": {
|
||||
"description": "环境变量\nin: body",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/VersionEnv"
|
||||
},
|
||||
"x-go-name": "Envs"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"default": {
|
||||
"description": "统一返回格式",
|
||||
"schema": {
|
||||
"$ref": "#/responses/commandResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/v2/tenants/{tenant_name}/services/{service_alias}/plugin/{plugin_id}/setenv/{env_name}": {
|
||||
"put": {
|
||||
"description": "update version env",
|
||||
"consumes": [
|
||||
"application/json",
|
||||
"application/x-protobuf"
|
||||
],
|
||||
"produces": [
|
||||
"application/json",
|
||||
"application/xml"
|
||||
],
|
||||
"tags": [
|
||||
"v2"
|
||||
],
|
||||
"summary": "修改用户可配的环境变量",
|
||||
"operationId": "updateVersionEnv",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"x-go-name": "TenantName",
|
||||
"name": "tenant_name",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"x-go-name": "ServiceAlias",
|
||||
"name": "service_alias",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"x-go-name": "PluginID",
|
||||
"description": "插件id",
|
||||
"name": "plugin_id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"x-go-name": "EnvName",
|
||||
"description": "变量名",
|
||||
"name": "env_name",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"name": "Body",
|
||||
"in": "body",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"env_value"
|
||||
],
|
||||
"properties": {
|
||||
"env_value": {
|
||||
"description": "变量值\nin: body",
|
||||
"type": "string",
|
||||
"x-go-name": "EnvValue"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"default": {
|
||||
"description": "统一返回格式",
|
||||
"schema": {
|
||||
"$ref": "#/responses/commandResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/v2/tenants/{tenant_name}/services/{service_alias}/pods": {
|
||||
"get": {
|
||||
"description": "get pods info **完成",
|
||||
@ -5598,6 +5793,27 @@
|
||||
}
|
||||
},
|
||||
"x-go-package": "net/url"
|
||||
},
|
||||
"VersionEnv": {
|
||||
"description": "VersionEnv VersionEnv",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"env_name",
|
||||
"env_value"
|
||||
],
|
||||
"properties": {
|
||||
"env_name": {
|
||||
"description": "变量名\nin:body",
|
||||
"type": "string",
|
||||
"x-go-name": "EnvName"
|
||||
},
|
||||
"env_value": {
|
||||
"description": "变量值\nin:body",
|
||||
"type": "string",
|
||||
"x-go-name": "EnvValue"
|
||||
}
|
||||
},
|
||||
"x-go-package": "github.com/goodrain/rainbond/pkg/api/model"
|
||||
}
|
||||
},
|
||||
"responses": {
|
||||
|
@ -100,5 +100,8 @@ type PluginInterface interface {
|
||||
//plugin
|
||||
PluginSet(w http.ResponseWriter, r *http.Request)
|
||||
DeletePluginRelation(w http.ResponseWriter, r *http.Request)
|
||||
GetPluginEnvWhichCanBeSet(w http.ResponseWriter, r *http.Request)
|
||||
GePluginEnvWhichCanBeSet(w http.ResponseWriter, r *http.Request)
|
||||
SetVersionEnv(w http.ResponseWriter, r *http.Request)
|
||||
UpdateVersionEnv(w http.ResponseWriter, r *http.Request)
|
||||
GetPluginDefaultEnvs(w http.ResponseWriter, r *http.Request)
|
||||
}
|
||||
|
@ -36,12 +36,12 @@ func (v2 *V2) pluginRouter() chi.Router {
|
||||
r.Delete("/", controller.GetManager().PluginAction)
|
||||
r.Post("/build", controller.GetManager().PluginBuild)
|
||||
r.Post("/default-env", controller.GetManager().PluginDefaultENV)
|
||||
r.Get("/default-env", controller.GetManager().GetPluginDefaultEnvs)
|
||||
r.Put("/default-env/{env_name}", controller.GetManager().PluginDefaultENV)
|
||||
r.Delete("/default-env/{env_name}", controller.GetManager().PluginDefaultENV)
|
||||
//get this plugin all build version
|
||||
r.Get("/build-version", controller.GetManager().GetAllPluginBuildVersons)
|
||||
r.Get("/build-version/{version_id}", controller.GetManager().GetPluginBuildVersion)
|
||||
r.Delete("/build-version/{version_id}", controller.GetManager().DeletePluginBuildVersion)
|
||||
r.Get("/envs", controller.GetManager().GetPluginEnvWhichCanBeSet)
|
||||
return r
|
||||
}
|
||||
|
@ -170,6 +170,9 @@ func (v2 *V2) serviceRouter() chi.Router {
|
||||
r.Get("/plugin", controller.GetManager().PluginSet)
|
||||
r.Delete("/plugin/{plugin_id}", controller.GetManager().DeletePluginRelation)
|
||||
// plugin enable set env,包含普通设置和预设可修改部分
|
||||
r.Post("/plugin/{plugin_id}/setenv", controller.GetManager().SetVersionEnv)
|
||||
r.Put("/plugin/{plugin_id}/setenv/{env_name}", controller.GetManager().UpdateVersionEnv)
|
||||
r.Get("/plugin/{plugin_id}/envs", controller.GetManager().GePluginEnvWhichCanBeSet)
|
||||
return r
|
||||
}
|
||||
|
||||
|
@ -244,8 +244,9 @@ func (t *TenantStruct) DeleteDefaultENV(w http.ResponseWriter, r *http.Request)
|
||||
// schema:
|
||||
// "$ref": "#/responses/commandResponse"
|
||||
// description: 统一返回格式
|
||||
pluginID := r.Context().Value(middleware.ContextKey("plugin_id")).(string)
|
||||
envName := chi.URLParam(r, "env_name")
|
||||
if err := handler.GetPluginManager().DeleteDefaultEnv(envName); err != nil {
|
||||
if err := handler.GetPluginManager().DeleteDefaultEnv(pluginID, envName); err != nil {
|
||||
err.Handle(r, w)
|
||||
return
|
||||
}
|
||||
@ -563,11 +564,11 @@ func (t *TenantStruct) DeletePluginRelation(w http.ResponseWriter, r *http.Reque
|
||||
httputil.ReturnSuccess(r, w, nil)
|
||||
}
|
||||
|
||||
//GetPluginEnvWhichCanBeSet GetPluginEnvWhichCanBeSets
|
||||
func (t *TenantStruct) GetPluginEnvWhichCanBeSet(w http.ResponseWriter, r *http.Request) {
|
||||
//GetPluginDefaultEnvs GetPluginDefaultEnvs
|
||||
func (t *TenantStruct) GetPluginDefaultEnvs(w http.ResponseWriter, r *http.Request) {
|
||||
// swagger:operation GET /v2/tenants/{tenant_name}/plugin/{plugin_id}/envs v2 getPluginEnv
|
||||
//
|
||||
// 获取可以修改的plugin env
|
||||
// 获取插件设定的env
|
||||
//
|
||||
// get plugin env
|
||||
//
|
||||
@ -586,10 +587,117 @@ func (t *TenantStruct) GetPluginEnvWhichCanBeSet(w http.ResponseWriter, r *http.
|
||||
// "$ref": "#/responses/commandResponse"
|
||||
// description: 统一返回格式
|
||||
pluginID := r.Context().Value(middleware.ContextKey("plugin_id")).(string)
|
||||
envs, err := handler.GetPluginManager().GetDefaultEnvWhichCanBeSet(pluginID)
|
||||
envs, err := handler.GetPluginManager().GetDefaultEnv(pluginID)
|
||||
if err != nil {
|
||||
err.Handle(r, w)
|
||||
return
|
||||
}
|
||||
httputil.ReturnSuccess(r, w, envs)
|
||||
}
|
||||
|
||||
//GePluginEnvWhichCanBeSet GePluginEnvWhichCanBeSet
|
||||
func (t *TenantStruct) GePluginEnvWhichCanBeSet(w http.ResponseWriter, r *http.Request) {
|
||||
// swagger:operation GET /v2/tenants/{tenant_name}/services/{service_alias}/plugin/{plugin_id}/envs v2 getVersionEnvs
|
||||
//
|
||||
// 获取可配置的env; 从service plugin对应中取, 若不存在则返回默认可修改的变量
|
||||
//
|
||||
// get version env
|
||||
//
|
||||
// ---
|
||||
// consumes:
|
||||
// - application/json
|
||||
// - application/x-protobuf
|
||||
//
|
||||
// produces:
|
||||
// - application/json
|
||||
// - application/xml
|
||||
//
|
||||
// responses:
|
||||
// default:
|
||||
// schema:
|
||||
// "$ref": "#/responses/commandResponse"
|
||||
// description: 统一返回格式
|
||||
serviceID := r.Context().Value(middleware.ContextKey("service_id")).(string)
|
||||
pluginID := chi.URLParam(r, "plugin_id")
|
||||
envs, err := handler.GetPluginManager().GetEnvsWhichCanBeSet(serviceID, pluginID)
|
||||
if err != nil {
|
||||
err.Handle(r, w)
|
||||
return
|
||||
}
|
||||
httputil.ReturnSuccess(r, w, envs)
|
||||
}
|
||||
|
||||
//SetVersionEnv SetVersionEnv
|
||||
func (t *TenantStruct) SetVersionEnv(w http.ResponseWriter, r *http.Request) {
|
||||
// swagger:operation POST /v2/tenants/{tenant_name}/services/{service_alias}/plugin/{plugin_id}/setenv v2 setVersionEnv
|
||||
//
|
||||
// 设置用户可配的环境变量
|
||||
//
|
||||
// set version env
|
||||
//
|
||||
// ---
|
||||
// consumes:
|
||||
// - application/json
|
||||
// - application/x-protobuf
|
||||
//
|
||||
// produces:
|
||||
// - application/json
|
||||
// - application/xml
|
||||
//
|
||||
// responses:
|
||||
// default:
|
||||
// schema:
|
||||
// "$ref": "#/responses/commandResponse"
|
||||
// description: 统一返回格式
|
||||
var sve api_model.SetVersionEnv
|
||||
ok := httputil.ValidatorRequestStructAndErrorResponse(r, w, &sve.Body, nil)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
serviceID := r.Context().Value(middleware.ContextKey("service_id")).(string)
|
||||
pluginID := chi.URLParam(r, "plugin_id")
|
||||
if err := handler.GetServiceManager().SetVersionEnv(serviceID, pluginID, &sve); err != nil {
|
||||
err.Handle(r, w)
|
||||
return
|
||||
}
|
||||
httputil.ReturnSuccess(r, w, nil)
|
||||
}
|
||||
|
||||
//UpdateVersionEnv UpdateVersionEnv
|
||||
func (t *TenantStruct) UpdateVersionEnv(w http.ResponseWriter, r *http.Request) {
|
||||
// swagger:operation PUT /v2/tenants/{tenant_name}/services/{service_alias}/plugin/{plugin_id}/setenv/{env_name} v2 updateVersionEnv
|
||||
//
|
||||
// 修改用户可配的环境变量
|
||||
//
|
||||
// update version env
|
||||
//
|
||||
// ---
|
||||
// consumes:
|
||||
// - application/json
|
||||
// - application/x-protobuf
|
||||
//
|
||||
// produces:
|
||||
// - application/json
|
||||
// - application/xml
|
||||
//
|
||||
// responses:
|
||||
// default:
|
||||
// schema:
|
||||
// "$ref": "#/responses/commandResponse"
|
||||
// description: 统一返回格式
|
||||
var uve api_model.UpdateVersionEnv
|
||||
ok := httputil.ValidatorRequestStructAndErrorResponse(r, w, &uve.Body, nil)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
serviceID := r.Context().Value(middleware.ContextKey("service_id")).(string)
|
||||
pluginID := chi.URLParam(r, "plugin_id")
|
||||
envName := chi.URLParam(r, "env_name")
|
||||
uve.PluginID = pluginID
|
||||
uve.EnvName = envName
|
||||
if err := handler.GetServiceManager().UpdateVersionEnv(serviceID, &uve); err != nil {
|
||||
err.Handle(r, w)
|
||||
return
|
||||
}
|
||||
httputil.ReturnSuccess(r, w, nil)
|
||||
}
|
||||
|
@ -33,12 +33,13 @@ type PluginHandler interface {
|
||||
GetPlugins(tenantID string) ([]*dbmodel.TenantPlugin, *util.APIHandleError)
|
||||
AddDefaultEnv(est *api_model.ENVStruct) *util.APIHandleError
|
||||
UpdateDefaultEnv(est *api_model.ENVStruct) *util.APIHandleError
|
||||
DeleteDefaultEnv(ENVName string) *util.APIHandleError
|
||||
DeleteDefaultEnv(pluginID, ENVName string) *util.APIHandleError
|
||||
BuildPluginManual(bps *api_model.BuildPluginStruct) (string, *util.APIHandleError)
|
||||
GetAllPluginBuildVersions(pluginID string) ([]*dbmodel.TenantPluginBuildVersion, *util.APIHandleError)
|
||||
GetPluginBuildVersion(pluginID, versionID string) (*dbmodel.TenantPluginBuildVersion, *util.APIHandleError)
|
||||
DeletePluginBuildVersion(pluginID, versionID string) *util.APIHandleError
|
||||
GetDefaultEnvWhichCanBeSet(pluginID string) ([]*dbmodel.TenantPluginDefaultENV, *util.APIHandleError)
|
||||
GetDefaultEnv(pluginID string) ([]*dbmodel.TenantPluginDefaultENV, *util.APIHandleError)
|
||||
GetEnvsWhichCanBeSet(serviceID, pluginID string) (interface{}, *util.APIHandleError)
|
||||
}
|
||||
|
||||
var defaultPluginHandler PluginHandler
|
||||
|
@ -63,6 +63,8 @@ type ServiceHandler interface {
|
||||
GetTenantServicePluginRelation(serviceID string) ([]*dbmodel.TenantServicePluginRelation, *util.APIHandleError)
|
||||
SetTenantServicePluginRelation(serviceID string, pss *api_model.PluginSetStruct) *util.APIHandleError
|
||||
UpdateTenantServicePluginRelation(serviceID string, pss *api_model.PluginSetStruct) *util.APIHandleError
|
||||
SetVersionEnv(serviecID, pluginID string, sve *api_model.SetVersionEnv) *util.APIHandleError
|
||||
UpdateVersionEnv(serviceID string, uve *api_model.UpdateVersionEnv) *util.APIHandleError
|
||||
}
|
||||
|
||||
var defaultServieHandler ServiceHandler
|
||||
|
@ -197,22 +197,38 @@ func (p *PluginAction) UpdateDefaultEnv(est *api_model.ENVStruct) *util.APIHandl
|
||||
}
|
||||
|
||||
//DeleteDefaultEnv DeleteDefaultEnv
|
||||
func (p *PluginAction) DeleteDefaultEnv(name string) *util.APIHandleError {
|
||||
if err := db.GetManager().TenantPluginDefaultENVDao().DeleteDefaultENVByName(name); err != nil {
|
||||
func (p *PluginAction) DeleteDefaultEnv(pluginID, name string) *util.APIHandleError {
|
||||
if err := db.GetManager().TenantPluginDefaultENVDao().DeleteDefaultENVByName(pluginID, name); err != nil {
|
||||
return util.CreateAPIHandleErrorFromDBError(fmt.Sprintf("delete default env %s", name), err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
//GetDefaultEnvWhichCanBeSet GetDefaultEnvWhichCanBeSet
|
||||
func (p *PluginAction) GetDefaultEnvWhichCanBeSet(pluginID string) ([]*dbmodel.TenantPluginDefaultENV, *util.APIHandleError) {
|
||||
envs, err := db.GetManager().TenantPluginDefaultENVDao().GetDefaultEnvWhichCanBeSetByPluginID(pluginID)
|
||||
//GetDefaultEnv GetDefaultEnv
|
||||
func (p *PluginAction) GetDefaultEnv(pluginID string) ([]*dbmodel.TenantPluginDefaultENV, *util.APIHandleError) {
|
||||
envs, err := db.GetManager().TenantPluginDefaultENVDao().GetDefaultENVSByPluginID(pluginID)
|
||||
if err != nil {
|
||||
return nil, util.CreateAPIHandleErrorFromDBError("get default env", err)
|
||||
}
|
||||
return envs, nil
|
||||
}
|
||||
|
||||
//GetEnvsWhichCanBeSet GetEnvsWhichCanBeSet
|
||||
func (p *PluginAction) GetEnvsWhichCanBeSet(serviceID, pluginID string) (interface{}, *util.APIHandleError) {
|
||||
envs, err := db.GetManager().TenantPluginVersionENVDao().GetVersionEnvByServiceID(serviceID, pluginID)
|
||||
if err != nil {
|
||||
return nil, util.CreateAPIHandleErrorFromDBError("get envs which can be set", err)
|
||||
}
|
||||
if len(envs) > 0 {
|
||||
return envs, nil
|
||||
}
|
||||
envD, errD := db.GetManager().TenantPluginDefaultENVDao().GetDefaultENVSByPluginIDCantBeSet(pluginID)
|
||||
if errD != nil {
|
||||
return nil, util.CreateAPIHandleErrorFromDBError("get envs which can be set", errD)
|
||||
}
|
||||
return envD, nil
|
||||
}
|
||||
|
||||
//BuildPluginManual BuildPluginManual
|
||||
func (p *PluginAction) BuildPluginManual(bps *api_model.BuildPluginStruct) (string, *util.APIHandleError) {
|
||||
eventID := bps.Body.EventID
|
||||
|
@ -1470,6 +1470,41 @@ func (s *ServiceAction) UpdateTenantServicePluginRelation(serviceID string, pss
|
||||
return nil
|
||||
}
|
||||
|
||||
//SetVersionEnv SetVersionEnv
|
||||
func (s *ServiceAction) SetVersionEnv(serviecID, pluginID string, sve *api_model.SetVersionEnv) *util.APIHandleError {
|
||||
tx := db.GetManager().Begin()
|
||||
for _, env := range sve.Body.Envs {
|
||||
tpv := &dbmodel.TenantPluginVersionEnv{
|
||||
PluginID: pluginID,
|
||||
ServiceID: serviecID,
|
||||
EnvName: env.EnvName,
|
||||
EnvValue: env.EnvValue,
|
||||
}
|
||||
if err := db.GetManager().TenantPluginVersionENVDaoTransactions(tx).AddModel(tpv); err != nil {
|
||||
tx.Rollback()
|
||||
return util.CreateAPIHandleErrorFromDBError("set version env", err)
|
||||
}
|
||||
}
|
||||
if err := tx.Commit().Error; err != nil {
|
||||
tx.Rollback()
|
||||
return util.CreateAPIHandleErrorFromDBError("commit set version env", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
//UpdateVersionEnv UpdateVersionEnv
|
||||
func (s *ServiceAction) UpdateVersionEnv(serviceID string, uve *api_model.UpdateVersionEnv) *util.APIHandleError {
|
||||
env, err := db.GetManager().TenantPluginVersionENVDao().GetVersionEnvByEnvName(serviceID, uve.PluginID, uve.EnvName)
|
||||
if err != nil {
|
||||
return util.CreateAPIHandleErrorFromDBError("update get version env", err)
|
||||
}
|
||||
env.EnvValue = uve.Body.EnvValue
|
||||
if err := db.GetManager().TenantPluginVersionENVDao().UpdateModel(env); err != nil {
|
||||
return util.CreateAPIHandleErrorFromDBError("update version env", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
//TransStatus trans service status
|
||||
func TransStatus(eStatus string) string {
|
||||
switch eStatus {
|
||||
|
@ -331,3 +331,78 @@ type GetPluginEnvStruct struct {
|
||||
// required: true
|
||||
PluginID string `json:"plugin_id"`
|
||||
}
|
||||
|
||||
//GetVersionEnvStruct GetVersionEnvStruct
|
||||
//swagger:parameters getVersionEnvs
|
||||
type GetVersionEnvStruct struct {
|
||||
// in: path
|
||||
// required: true
|
||||
TenantName string `json:"tenant_name"`
|
||||
// in: path
|
||||
// required: true
|
||||
ServiceAlias string `json:"service_alias"`
|
||||
// 插件id
|
||||
// in: path
|
||||
// required: true
|
||||
PluginID string `json:"plugin_id"`
|
||||
}
|
||||
|
||||
//SetVersionEnv SetVersionEnv
|
||||
//swagger:parameters setVersionEnv
|
||||
type SetVersionEnv struct {
|
||||
// in: path
|
||||
// required: true
|
||||
TenantName string `json:"tenant_name"`
|
||||
// in: path
|
||||
// required: true
|
||||
ServiceAlias string `json:"service_alias"`
|
||||
// 插件id
|
||||
// in: path
|
||||
// required: true
|
||||
PluginID string `json:"plugin_id"`
|
||||
//in: body
|
||||
Body struct {
|
||||
// 环境变量
|
||||
// in: body
|
||||
// required: true
|
||||
Envs []*VersionEnv `json:"envs"`
|
||||
}
|
||||
}
|
||||
|
||||
//VersionEnv VersionEnv
|
||||
type VersionEnv struct {
|
||||
//变量名
|
||||
//in:body
|
||||
//required: true
|
||||
EnvName string `json:"env_name" validate:"env_name"`
|
||||
//变量值
|
||||
//in:body
|
||||
//required: true
|
||||
EnvValue string `json:"env_value" validate:"env_value"`
|
||||
}
|
||||
|
||||
//UpdateVersionEnv UpdateVersionEnv
|
||||
//swagger:parameters updateVersionEnv
|
||||
type UpdateVersionEnv struct {
|
||||
// in: path
|
||||
// required: true
|
||||
TenantName string `json:"tenant_name"`
|
||||
// in: path
|
||||
// required: true
|
||||
ServiceAlias string `json:"service_alias"`
|
||||
// 插件id
|
||||
// in: path
|
||||
// required: true
|
||||
PluginID string `json:"plugin_id"`
|
||||
// 变量名
|
||||
// in: path
|
||||
// required: true
|
||||
EnvName string `json:"env_name"`
|
||||
//in: body
|
||||
Body struct {
|
||||
// 变量值
|
||||
// in: body
|
||||
// required: true
|
||||
EnvValue string `json:"env_value" validate:"env_value"`
|
||||
}
|
||||
}
|
||||
|
@ -93,10 +93,10 @@ type TenantPluginDao interface {
|
||||
//TenantPluginDefaultENVDao TenantPluginDefaultENVDao
|
||||
type TenantPluginDefaultENVDao interface {
|
||||
Dao
|
||||
GetDefaultENVByName(ENVName string) (*model.TenantPluginDefaultENV, error)
|
||||
GetDefaultENVByName(pluginID, ENVName string) (*model.TenantPluginDefaultENV, error)
|
||||
GetDefaultENVSByPluginID(pluginID string) ([]*model.TenantPluginDefaultENV, error)
|
||||
GetDefaultENVSByPluginIDCantBeSet(pluginID string) ([]*model.TenantPluginDefaultENV, error)
|
||||
DeleteDefaultENVByName(ENVName string) error
|
||||
DeleteDefaultENVByName(pluginID, ENVName string) error
|
||||
DeleteAllDefaultENVByPluginID(PluginID string) error
|
||||
GetDefaultEnvWhichCanBeSetByPluginID(pluginID string) ([]*model.TenantPluginDefaultENV, error)
|
||||
}
|
||||
@ -117,6 +117,7 @@ type TenantPluginVersionEnvDao interface {
|
||||
DeleteEnvByPluginID(serviceID, pluginID string) error
|
||||
DeleteEnvByServiceID(serviceID string) error
|
||||
GetVersionEnvByServiceID(serviceID string, pluginID string) ([]*model.TenantPluginVersionEnv, error)
|
||||
GetVersionEnvByEnvName(serviceID, pluginID, envName string) (*model.TenantPluginVersionEnv, error)
|
||||
}
|
||||
|
||||
//TenantServicePluginRelationDao TenantServicePluginRelationDao
|
||||
|
@ -1152,7 +1152,7 @@ type PluginDefaultENVDaoImpl struct {
|
||||
func (t *PluginDefaultENVDaoImpl) AddModel(mo model.Interface) error {
|
||||
env := mo.(*model.TenantPluginDefaultENV)
|
||||
var oldENV model.TenantPluginDefaultENV
|
||||
if ok := t.DB.Where(" env_name = ?", env.ENVName).Find(&oldENV).RecordNotFound(); ok {
|
||||
if ok := t.DB.Where("plugin_id=? and env_name = ?", env.PluginID, env.ENVName).Find(&oldENV).RecordNotFound(); ok {
|
||||
if err := t.DB.Create(env).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
@ -1172,9 +1172,9 @@ func (t *PluginDefaultENVDaoImpl) UpdateModel(mo model.Interface) error {
|
||||
}
|
||||
|
||||
//GetDefaultENVByName GetDefaultENVByName
|
||||
func (t *PluginDefaultENVDaoImpl) GetDefaultENVByName(name string) (*model.TenantPluginDefaultENV, error) {
|
||||
func (t *PluginDefaultENVDaoImpl) GetDefaultENVByName(pluginID string, name string) (*model.TenantPluginDefaultENV, error) {
|
||||
var env model.TenantPluginDefaultENV
|
||||
if err := t.DB.Where("env_name=?", name).Find(&env).Error; err != nil {
|
||||
if err := t.DB.Where("plugin_id=? and env_name=?", name).Find(&env).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &env, nil
|
||||
@ -1199,11 +1199,11 @@ func (t *PluginDefaultENVDaoImpl) GetDefaultENVSByPluginIDCantBeSet(pluginID str
|
||||
}
|
||||
|
||||
//DeleteDefaultENVByName DeleteDefaultENVByName
|
||||
func (t *PluginDefaultENVDaoImpl) DeleteDefaultENVByName(name string) error {
|
||||
func (t *PluginDefaultENVDaoImpl) DeleteDefaultENVByName(pluginID, name string) error {
|
||||
relation := &model.TenantPluginDefaultENV{
|
||||
ENVName: name,
|
||||
}
|
||||
if err := t.DB.Where("env_name=?", name).Delete(relation).Error; err != nil {
|
||||
if err := t.DB.Where("plugin_id=? and env_name=?", pluginID, name).Delete(relation).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
@ -1238,7 +1238,7 @@ type PluginBuildVersionDaoImpl struct {
|
||||
func (t *PluginBuildVersionDaoImpl) AddModel(mo model.Interface) error {
|
||||
version := mo.(*model.TenantPluginBuildVersion)
|
||||
var oldVersion model.TenantPluginBuildVersion
|
||||
if ok := t.DB.Where("version_id = ?", version.VersionID).Find(&oldVersion).RecordNotFound(); ok {
|
||||
if ok := t.DB.Where("plugin_id =? and version_id = ?", version.PluginID, version.VersionID).Find(&oldVersion).RecordNotFound(); ok {
|
||||
if err := t.DB.Create(version).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
@ -1310,7 +1310,7 @@ type PluginVersionEnvDaoImpl struct {
|
||||
func (t *PluginVersionEnvDaoImpl) AddModel(mo model.Interface) error {
|
||||
env := mo.(*model.TenantPluginVersionEnv)
|
||||
var oldENV model.TenantPluginVersionEnv
|
||||
if ok := t.DB.Where(" env_name = ?", env.EnvName).Find(&oldENV).RecordNotFound(); ok {
|
||||
if ok := t.DB.Where("plugin_id=? and env_name = ?", env.PluginID, env.EnvName).Find(&oldENV).RecordNotFound(); ok {
|
||||
if err := t.DB.Create(env).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
@ -1368,6 +1368,15 @@ func (t *PluginVersionEnvDaoImpl) GetVersionEnvByServiceID(serviceID string, plu
|
||||
return envs, nil
|
||||
}
|
||||
|
||||
//GetVersionEnvByEnvName GetVersionEnvByEnvName
|
||||
func (t *PluginVersionEnvDaoImpl) GetVersionEnvByEnvName(serviceID, pluginID, envName string) (*model.TenantPluginVersionEnv, error) {
|
||||
var env *model.TenantPluginVersionEnv
|
||||
if err := t.DB.Where("service_id=? and plugin_id=? and env_name=?", serviceID, pluginID, envName).Find(&env).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return env, nil
|
||||
}
|
||||
|
||||
//TenantServicePluginRelationDaoImpl TenantServicePluginRelationDaoImpl
|
||||
type TenantServicePluginRelationDaoImpl struct {
|
||||
DB *gorm.DB
|
||||
|
Loading…
Reference in New Issue
Block a user