|
@@ -1,7 +1,9 @@
|
|
|
package cn.reghao.devops.mgr.ops.build.controller;
|
|
package cn.reghao.devops.mgr.ops.build.controller;
|
|
|
|
|
|
|
|
import cn.reghao.devops.mgr.ops.build.db.repository.CompilerConfigRepository;
|
|
import cn.reghao.devops.mgr.ops.build.db.repository.CompilerConfigRepository;
|
|
|
|
|
+import cn.reghao.devops.mgr.ops.build.model.dto.CompilerArgDto;
|
|
|
import cn.reghao.devops.mgr.ops.build.model.dto.CompilerBindDto;
|
|
import cn.reghao.devops.mgr.ops.build.model.dto.CompilerBindDto;
|
|
|
|
|
+import cn.reghao.devops.mgr.ops.build.model.dto.CompilerEnvDto;
|
|
|
import cn.reghao.devops.mgr.ops.build.model.po.CompilerConfig;
|
|
import cn.reghao.devops.mgr.ops.build.model.po.CompilerConfig;
|
|
|
import cn.reghao.devops.mgr.ops.build.service.CompilerConfigService;
|
|
import cn.reghao.devops.mgr.ops.build.service.CompilerConfigService;
|
|
|
import cn.reghao.devops.mgr.ops.build.model.constant.CompileType;
|
|
import cn.reghao.devops.mgr.ops.build.model.constant.CompileType;
|
|
@@ -40,6 +42,32 @@ public class CompilerController {
|
|
|
this.compilerConfigService = compilerConfigService;
|
|
this.compilerConfigService = compilerConfigService;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Operation(summary = "编译类型列表", description = "N")
|
|
|
|
|
+ @GetMapping(value = "/types", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
|
|
+ public String addCompilerPage() {
|
|
|
|
|
+ List<SelectOption> compileTypes = Arrays.stream(CompileType.values())
|
|
|
|
|
+ .filter(compileType -> !compileType.name().equals(CompileType.none.name()))
|
|
|
|
|
+ .map(compileType -> new SelectOption(compileType.getName(), compileType.getName()))
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+ return WebResult.success(compileTypes);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Operation(summary = "添加编译配置", description = "N")
|
|
|
|
|
+ @PostMapping(value = "", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
|
|
+ @ResponseBody
|
|
|
|
|
+ public String addCompileConfig(@Validated CompilerConfig compilerConfig) {
|
|
|
|
|
+ Result result = compilerConfigService.addOrUpdate(compilerConfig);
|
|
|
|
|
+ return WebResult.result(result);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Operation(summary = "删除应用编译配置", description = "N")
|
|
|
|
|
+ @PostMapping(value = "/delete", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
|
|
+ @ResponseBody
|
|
|
|
|
+ public String deleteCompileConfig(Integer id) {
|
|
|
|
|
+ Result result = compilerConfigService.delete(id);
|
|
|
|
|
+ return WebResult.result(result);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@Operation(summary = "编译配置列表页面", description = "N")
|
|
@Operation(summary = "编译配置列表页面", description = "N")
|
|
|
@GetMapping(value = "", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
@GetMapping(value = "", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
public String compilerConfigPage(@RequestParam("pn") int pageNumber) {
|
|
public String compilerConfigPage(@RequestParam("pn") int pageNumber) {
|
|
@@ -57,81 +85,75 @@ public class CompilerController {
|
|
|
return PageList.pageList(pageNumber, pageSize, (int) total, list);
|
|
return PageList.pageList(pageNumber, pageSize, (int) total, list);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @Operation(summary = "编译类型列表", description = "N")
|
|
|
|
|
- @GetMapping(value = "/types", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
|
|
- public String addCompilerPage() {
|
|
|
|
|
- List<SelectOption> compileTypes = Arrays.stream(CompileType.values())
|
|
|
|
|
- .filter(compileType -> !compileType.name().equals(CompileType.none.name()))
|
|
|
|
|
- .map(compileType -> new SelectOption(compileType.getName(), compileType.getName()))
|
|
|
|
|
- .collect(Collectors.toList());
|
|
|
|
|
- return WebResult.success(compileTypes);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @Operation(summary = "添加 docker 编译器映射目录", description = "N")
|
|
|
|
|
|
|
+ @Operation(summary = "添加 docker 容器映射目录", description = "N")
|
|
|
@PostMapping(value = "/bind/add", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
@PostMapping(value = "/bind/add", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
- public String addCompilerBind(@RequestBody @Validated CompilerBindDto compilerBindDto) {
|
|
|
|
|
- compilerConfigService.addDockerBind(compilerBindDto);
|
|
|
|
|
- return WebResult.success();
|
|
|
|
|
|
|
+ public String addContainerBind(@RequestBody @Validated CompilerBindDto compilerBindDto) {
|
|
|
|
|
+ Result result = compilerConfigService.addContainerBind(compilerBindDto);
|
|
|
|
|
+ return WebResult.result(result);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @Operation(summary = "添加 docker 编译器映射目录", description = "N")
|
|
|
|
|
|
|
+ @Operation(summary = "删除 docker 容器映射目录", description = "N")
|
|
|
@PostMapping(value = "/bind/delete", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
@PostMapping(value = "/bind/delete", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
- public String deleteCompilerBind(@RequestBody @Validated CompilerBindDto compilerBindDto) {
|
|
|
|
|
- compilerConfigService.deleteDockerBind(compilerBindDto);
|
|
|
|
|
- return WebResult.success();
|
|
|
|
|
|
|
+ public String deleteContainerBind(@RequestBody @Validated CompilerBindDto compilerBindDto) {
|
|
|
|
|
+ Result result = compilerConfigService.deleteContainerBind(compilerBindDto);
|
|
|
|
|
+ return WebResult.result(result);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @Operation(summary = "编译器的容器映射目录页面", description = "N")
|
|
|
|
|
|
|
+ @Operation(summary = "docker 容器目录映射列表", description = "N")
|
|
|
@GetMapping(value = "/bind/list", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
@GetMapping(value = "/bind/list", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
- public String compilerBindPage(@RequestParam("id") int id) {
|
|
|
|
|
|
|
+ public String containerBindList(@RequestParam("id") int id) {
|
|
|
CompilerConfig compilerConfig = compilerConfigRepository.findById(id).orElse(null);
|
|
CompilerConfig compilerConfig = compilerConfigRepository.findById(id).orElse(null);
|
|
|
if (compilerConfig != null && compilerConfig.getType().equals(CompileType.dockerRun.getName())) {
|
|
if (compilerConfig != null && compilerConfig.getType().equals(CompileType.dockerRun.getName())) {
|
|
|
return WebResult.success(compilerConfig.getCompilerBinds());
|
|
return WebResult.success(compilerConfig.getCompilerBinds());
|
|
|
}
|
|
}
|
|
|
- return WebResult.failWithMsg("compiler not dockerRun type");
|
|
|
|
|
|
|
+ return WebResult.failWithMsg("只有 dockerRun 类型支持添加容器目录映射");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @Operation(summary = "编译器的容器环境变量页面", description = "N")
|
|
|
|
|
- @GetMapping(value = "/env/list", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
|
|
- public String compilerEnvPage(@RequestParam("id") int id) {
|
|
|
|
|
- CompilerConfig compilerConfig = compilerConfigRepository.findById(id).orElse(null);
|
|
|
|
|
- if (compilerConfig != null && compilerConfig.getType().equals(CompileType.dockerRun.getName())) {
|
|
|
|
|
- return WebResult.success(compilerConfig.getCompilerBinds());
|
|
|
|
|
- }
|
|
|
|
|
- return WebResult.failWithMsg("compiler not dockerRun type");
|
|
|
|
|
|
|
+ @Operation(summary = "添加 docker 容器环境变量", description = "N")
|
|
|
|
|
+ @PostMapping(value = "/env/add", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
|
|
+ public String addContainerEnv(@RequestBody @Validated CompilerEnvDto compilerEnvDto) {
|
|
|
|
|
+ Result result = compilerConfigService.addContainerEnv(compilerEnvDto);
|
|
|
|
|
+ return WebResult.result(result);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Operation(summary = "删除 docker 容器环境变量", description = "N")
|
|
|
|
|
+ @PostMapping(value = "/env/delete", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
|
|
+ public String deleteContainerEnv(@RequestBody @Validated CompilerEnvDto compilerEnvDto) {
|
|
|
|
|
+ Result result = compilerConfigService.deleteContainerEnv(compilerEnvDto);
|
|
|
|
|
+ return WebResult.result(result);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @Operation(summary = "编译器的 dockerfile 变量页面", description = "N")
|
|
|
|
|
- @GetMapping(value = "/dockerfile/list", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
|
|
- public String compilerDockerfilePage(@RequestParam("id") int id) {
|
|
|
|
|
|
|
+ @Operation(summary = "docker 容器环境变量列表", description = "N")
|
|
|
|
|
+ @GetMapping(value = "/env/list", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
|
|
+ public String containerEnvList(@RequestParam("id") int id) {
|
|
|
CompilerConfig compilerConfig = compilerConfigRepository.findById(id).orElse(null);
|
|
CompilerConfig compilerConfig = compilerConfigRepository.findById(id).orElse(null);
|
|
|
- if (compilerConfig != null && compilerConfig.getType().equals(CompileType.dockerBuild.getName())) {
|
|
|
|
|
- return WebResult.success(compilerConfig.getCompilerArgs());
|
|
|
|
|
|
|
+ if (compilerConfig != null && compilerConfig.getType().equals(CompileType.dockerRun.getName())) {
|
|
|
|
|
+ return WebResult.success(compilerConfig.getCompilerEnvs());
|
|
|
}
|
|
}
|
|
|
- return WebResult.failWithMsg("compiler not dockerBuild type");
|
|
|
|
|
|
|
+ return WebResult.failWithMsg("只有 dockerRun 类型支持添加容器环境变量");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @Operation(summary = "添加编译配置", description = "N")
|
|
|
|
|
- @PostMapping(value = "", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
|
|
- @ResponseBody
|
|
|
|
|
- public String addCompileConfig(@Validated CompilerConfig compilerConfig) {
|
|
|
|
|
- Result result = compilerConfigService.addOrUpdate(compilerConfig);
|
|
|
|
|
|
|
+ @Operation(summary = "添加 docker 容器环境变量", description = "N")
|
|
|
|
|
+ @PostMapping(value = "/arg/add", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
|
|
+ public String addDockerfileArg(@RequestBody @Validated CompilerArgDto compilerArgDto) {
|
|
|
|
|
+ Result result = compilerConfigService.addDockerfileArg(compilerArgDto);
|
|
|
return WebResult.result(result);
|
|
return WebResult.result(result);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @Operation(summary = "删除应用编译配置", description = "N")
|
|
|
|
|
- @PostMapping(value = "/delete", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
|
|
- @ResponseBody
|
|
|
|
|
- public String deleteCompileConfig(Integer id) {
|
|
|
|
|
- Result result = compilerConfigService.delete(id);
|
|
|
|
|
|
|
+ @Operation(summary = "删除 docker 容器环境变量", description = "N")
|
|
|
|
|
+ @PostMapping(value = "/arg/delete", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
|
|
+ public String deleteDockerfileArg(@RequestBody @Validated CompilerArgDto compilerArgDto) {
|
|
|
|
|
+ Result result = compilerConfigService.deleteDockerfileArg(compilerArgDto);
|
|
|
return WebResult.result(result);
|
|
return WebResult.result(result);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @Operation(summary = "获取编译器版本信息", description = "N")
|
|
|
|
|
- @GetMapping(value = "/version", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
|
|
- @ResponseBody
|
|
|
|
|
- public String getCompileVersion(@RequestParam("id") Integer id) {
|
|
|
|
|
- String result = compilerConfigService.getCompilerVersion(id);
|
|
|
|
|
- return WebResult.success(result);
|
|
|
|
|
|
|
+ @Operation(summary = "dockerfile 参数变量列表", description = "N")
|
|
|
|
|
+ @GetMapping(value = "/arg/list", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
|
|
+ public String dockerfileArgList(@RequestParam("id") int id) {
|
|
|
|
|
+ CompilerConfig compilerConfig = compilerConfigRepository.findById(id).orElse(null);
|
|
|
|
|
+ if (compilerConfig != null && compilerConfig.getType().equals(CompileType.dockerBuild.getName())) {
|
|
|
|
|
+ return WebResult.success(compilerConfig.getCompilerArgs());
|
|
|
|
|
+ }
|
|
|
|
|
+ return WebResult.failWithMsg("只有 dockerBuild 类型支持添加 dockerfile 参数变量");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|