|
|
@@ -1,15 +1,13 @@
|
|
|
package cn.reghao.autodop.dmaster.app.controller;
|
|
|
|
|
|
-import cn.reghao.autodop.common.utils.data.serializer.JsonConverter;
|
|
|
import cn.reghao.autodop.dmaster.app.constant.EnvType;
|
|
|
import cn.reghao.autodop.dmaster.app.vo.SuccessfullyBuildVO;
|
|
|
-import cn.reghao.autodop.dmaster.app.vo.log.BuildDeployResult;
|
|
|
+import cn.reghao.autodop.dmaster.app.vo.log.BuildDeployAppVO;
|
|
|
import cn.reghao.autodop.dmaster.app.service.BuildService;
|
|
|
import cn.reghao.autodop.common.utils.data.db.PageList;
|
|
|
import cn.reghao.autodop.dmaster.app.vo.log.BuildLogVO;
|
|
|
import cn.reghao.autodop.dmaster.app.vo.log.CommitLogVO;
|
|
|
import cn.reghao.autodop.dmaster.app.vo.log.DeployLogVO;
|
|
|
-import cn.reghao.autodop.dmaster.app.service.OssService;
|
|
|
import cn.reghao.autodop.dmaster.app.service.BuildDeployDispatcher;
|
|
|
import cn.reghao.autodop.common.result.WebResult;
|
|
|
import io.swagger.annotations.Api;
|
|
|
@@ -21,7 +19,6 @@ import org.springframework.data.domain.PageRequest;
|
|
|
import org.springframework.data.domain.Sort;
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
-import org.tmatesoft.svn.core.SVNException;
|
|
|
|
|
|
/**
|
|
|
* @author reghao
|
|
|
@@ -31,37 +28,29 @@ import org.tmatesoft.svn.core.SVNException;
|
|
|
@Api(tags = "应用构建部署接口")
|
|
|
@RestController
|
|
|
@RequestMapping("/api/app/bd")
|
|
|
-public class BuildController {
|
|
|
+public class BuildDeployController {
|
|
|
private BuildService buildService;
|
|
|
private BuildDeployDispatcher buildDeployDispatcher;
|
|
|
- private OssService ossService;
|
|
|
|
|
|
- public BuildController(BuildService buildService, BuildDeployDispatcher buildDeployDispatcher, OssService ossService) {
|
|
|
+ public BuildDeployController(BuildService buildService, BuildDeployDispatcher buildDeployDispatcher) {
|
|
|
this.buildService = buildService;
|
|
|
this.buildDeployDispatcher = buildDeployDispatcher;
|
|
|
- this.ossService = ossService;
|
|
|
}
|
|
|
|
|
|
- // TODO docker 打包时 repository:tag 为空
|
|
|
- // TODO docker push 没有成功
|
|
|
@ApiOperation(value = "构建部署应用")
|
|
|
- @ApiImplicitParams(
|
|
|
- @ApiImplicitParam(name="appId", value="应用 ID", paramType="query", dataType = "String")
|
|
|
- )
|
|
|
+ @ApiImplicitParams(@ApiImplicitParam(name="appId", value="应用 ID", paramType="query", dataType = "String"))
|
|
|
@PostMapping("/update")
|
|
|
public String buildAndDeploy(@RequestParam("appId") String appId) throws Exception {
|
|
|
- BuildDeployResult buildDeployResult = buildDeployDispatcher.buildAndDeploy(appId, true);
|
|
|
- return WebResult.success(buildDeployResult);
|
|
|
+ BuildDeployAppVO buildDeployAppVO = buildDeployDispatcher.buildAndDeploy(appId, true);
|
|
|
+ return WebResult.success(buildDeployAppVO);
|
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "构建应用")
|
|
|
- @ApiImplicitParams(
|
|
|
- @ApiImplicitParam(name="appId", value="应用 ID", paramType="query", dataType = "String")
|
|
|
- )
|
|
|
+ @ApiImplicitParams(@ApiImplicitParam(name="appId", value="应用 ID", paramType="query", dataType = "String"))
|
|
|
@PostMapping("/build")
|
|
|
public String build(@RequestParam("appId") String appId) throws Exception {
|
|
|
- BuildDeployResult buildDeployResult = buildDeployDispatcher.buildAndDeploy(appId, false);
|
|
|
- return WebResult.success(buildDeployResult);
|
|
|
+ BuildDeployAppVO buildDeployAppVO = buildDeployDispatcher.buildAndDeploy(appId, false);
|
|
|
+ return WebResult.success(buildDeployAppVO);
|
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "部署应用")
|
|
|
@@ -71,18 +60,15 @@ public class BuildController {
|
|
|
})
|
|
|
@PostMapping("/deploy")
|
|
|
public String deploy(@RequestParam("appId") String appId, @RequestParam("commitId") String commitId) {
|
|
|
- // TODO 单独部署某个或几个节点
|
|
|
- buildDeployDispatcher.deploy1(appId, commitId);
|
|
|
- return WebResult.success("deploy");
|
|
|
+ BuildDeployAppVO buildDeployAppVO = buildDeployDispatcher.deploy(appId, commitId);
|
|
|
+ return WebResult.success(buildDeployAppVO);
|
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "某个环境需要构建部署的应用")
|
|
|
@GetMapping("/list")
|
|
|
public ResponseEntity<String> buildList(@RequestParam("page") int page, @RequestParam("size") int size,
|
|
|
@RequestParam("env") String env) {
|
|
|
- PageRequest pageRequest =
|
|
|
- PageRequest.of(page-1, size, Sort.by(Sort.Direction.DESC, "createTime"));
|
|
|
- PageList<BuildDeployResult> pageList = buildService.buildList(EnvType.valueOf(env).name(), pageRequest);
|
|
|
+ PageList<BuildDeployAppVO> pageList = buildService.buildList(page, size, EnvType.valueOf(env).name());
|
|
|
return ResponseEntity.ok().body(WebResult.success(pageList));
|
|
|
}
|
|
|
|
|
|
@@ -171,14 +157,4 @@ public class BuildController {
|
|
|
PageList<DeployLogVO> pageList = buildService.deployLogs(env1, appId, pageRequest);
|
|
|
return ResponseEntity.ok().body(WebResult.success(pageList));
|
|
|
}
|
|
|
-
|
|
|
- @ApiOperation(value = "部署 OSS 资源")
|
|
|
- @ApiImplicitParams(
|
|
|
- @ApiImplicitParam(name="appId", value="应用标识", paramType="query", dataType = "String")
|
|
|
- )
|
|
|
- @PostMapping("/deploy/oss/{appId}")
|
|
|
- public String deployOss(@PathVariable("appId") String appId) throws SVNException {
|
|
|
- ossService.upload(appId);
|
|
|
- return WebResult.success("ok");
|
|
|
- }
|
|
|
}
|