[REV] add deploy version for build-list

This commit is contained in:
GLYASAI 2019-02-13 16:30:17 +08:00
parent b85f086d55
commit c2d5f52ce3
4 changed files with 50 additions and 3 deletions

View File

@ -535,13 +535,15 @@ func (t *TenantStruct) BuildService(w http.ResponseWriter, r *http.Request) {
//BuildList BuildList
func (t *TenantStruct) BuildList(w http.ResponseWriter, r *http.Request) {
serviceID := r.Context().Value(middleware.ContextKey("service_id")).(string)
versionInfoList, err := db.GetManager().VersionInfoDao().GetAllVersionByServiceID(serviceID)
if err != nil && err != gorm.ErrRecordNotFound {
resp, err := handler.GetServiceManager().ListVersionInfo(serviceID)
if err != nil {
logrus.Error("get version info error", err.Error())
httputil.ReturnError(r, w, 500, fmt.Sprintf("get version info erro, %v", err))
return
}
httputil.ReturnSuccess(r, w, versionInfoList)
httputil.ReturnSuccess(r, w, resp)
}
func (t *TenantStruct) BuildVersionIsExist(w http.ResponseWriter, r *http.Request) {

View File

@ -72,4 +72,5 @@ type ServiceHandler interface {
ServiceCheck(*api_model.ServiceCheckStruct) (string, string, *util.APIHandleError)
GetServiceCheckInfo(uuid string) (*exector.ServiceCheckResult, *util.APIHandleError)
GetServiceDeployInfo(tenantID, serviceID string) (*pb.DeployInfo, *util.APIHandleError)
ListVersionInfo(serviceID string) (*api_model.BuildListRespVO, error)
}

View File

@ -1745,6 +1745,25 @@ func (s *ServiceAction) GetServiceDeployInfo(tenantID, serviceID string) (*pb.De
return info, nil
}
// ListVersionInfo lists version info
func (s *ServiceAction) ListVersionInfo(serviceID string) (*api_model.BuildListRespVO, error) {
versionInfos, err := db.GetManager().VersionInfoDao().GetAllVersionByServiceID(serviceID)
if err != nil && err != gorm.ErrRecordNotFound {
logrus.Errorf("error getting all version by service id: %v", err)
return nil, fmt.Errorf("error getting all version by service id: %v", err)
}
svc, err := db.GetManager().TenantServiceDao().GetServiceByID(serviceID)
if err != nil {
logrus.Errorf("error getting service by uuid: %v", err)
return nil, fmt.Errorf("error getting service by uuid: %v", err)
}
result := &api_model.BuildListRespVO{
DeployVersion: svc.DeployVersion,
List: versionInfos,
}
return result, nil
}
//TransStatus trans service status
func TransStatus(eStatus string) string {
switch eStatus {

View File

@ -0,0 +1,25 @@
// RAINBOND, Application Management Platform
// Copyright (C) 2014-2017 Goodrain Co., Ltd.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. For any non-GPL usage of Rainbond,
// one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
// must be obtained first.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package model
// BuildListRespVO is the response value object for build-list api.
type BuildListRespVO struct {
DeployVersion string `json:"deploy_version"`
List interface{} `json:"list"`
}