Пример #1
0
func CreateAppsHandler(pathParams map[string]string, data []byte) interface{} {
	var request entity.DeployAppsRequest
	webUtils.ParseOuterRequest(data, &request)
	deployInfo := webUtils.BuildAppsRequest(request)
	var resData map[string]interface{}
	resCode := fasthttp.JsonReqAndResHandler(common.Path.MarathonAppsUrl, deployInfo, &resData, "POST")
	return webUtils.ProcessResponse(resCode, resData)
}
Пример #2
0
// 逻辑为:放入仓库的时候,即每个模块携带时间戳,每次前端构建时候传入比如zookeeper
// 则后端则从私库里捞出zookeeper所有模块,并按时间倒叙取出最新的zk模块镜像进行部署
// 则,在回滚时候,捞出倒数第二新的模块进行重新部署。部署时候更新labels即可。
func RollbackAppsHandler(pathParams map[string]string, data []byte) interface{} {
	var request entity.RollbackAppsBatchRequest
	webUtils.ParseOuterRequest(data, &request)

	requestBatch := make([]entity.DeployAppsRequest, len(request.Batch))
	for i, v := range request.Batch {
		// TODO 通过ID把Image信息拿到,暂时认为ID和Image是等价的
		_, image, tag := common.DockerClient.GetPreviousImageAndTag(v.Id, v.Version, "")
		var request entity.DeployAppsRequest
		request.Id = v.Id
		request.Image = image
		request.Version = tag
		requestBatch[i] = request
	}
	appsBatchRequest := entity.DeployAppsBatchRequest{}
	appsBatchRequest.Batch = requestBatch
	resData, code := createOrUpdateAppsService(appsBatchRequest)
	return webUtils.ProcessResponse(code, resData)
}
Пример #3
0
func DeployGroupsHandler(pathParams map[string]string, data []byte) interface{} {
	var request entity.DeployGroupsRequest
	webUtils.ParseOuterRequest(data, &request)

	var groupsRequest marathon.MarathonGroupsRequest
	groupsRequest.Id = request.Id
	perGroups := make([]marathon.MarathonGroupsInfo, len(request.Groups))
	for i, v := range request.Groups {
		var group marathon.MarathonGroupsInfo
		group.Id = v.Id
		perApps := make([]marathon.MarathonAppsRequest, len(v.Apps))
		for j, app := range v.Apps {
			perApps[j] = *webUtils.BuildAppsRequest(app)
		}
		group.Apps = perApps
		perGroups[i] = group
	}
	groupsRequest.Groups = perGroups
	var resData map[string]interface{}
	resCode := fasthttp.JsonReqAndResHandler(common.Path.MarathonGroupsUrl, groupsRequest, &resData, "POST")
	return webUtils.ProcessResponse(resCode, resData)
}
Пример #4
0
func CreateContainerInfo(pathParams map[string]string, data []byte) interface{} {
	var request model.Container
	webUtils.ParseOuterRequest(data, &request)
	mongo.InsertContainer(request)
	return webUtils.ProcessResponseFully(http.StatusOK, nil, true)
}
Пример #5
0
func CreateOrUpdateAppsHandler(pathParams map[string]string, data []byte) interface{} {
	var request entity.DeployAppsBatchRequest
	webUtils.ParseOuterRequest(data, &request)
	resData, resCode := createOrUpdateAppsService(request)
	return webUtils.ProcessResponse(resCode, resData)
}