|
|
@@ -3,6 +3,8 @@ package cn.reghao.bnt.web.devops.build.service.impl;
|
|
|
import cn.reghao.bnt.web.devops.app.db.query.AppBuildQuery;
|
|
|
import cn.reghao.bnt.web.devops.app.model.po.config.AppConfig;
|
|
|
import cn.reghao.bnt.web.devops.build.db.repository.CompilerConfigRepository;
|
|
|
+import cn.reghao.bnt.web.devops.build.model.dto.CompilerBindDto;
|
|
|
+import cn.reghao.bnt.web.devops.build.model.po.CompilerBind;
|
|
|
import cn.reghao.bnt.web.devops.build.model.po.CompilerConfig;
|
|
|
import cn.reghao.bnt.web.devops.build.service.CompilerConfigService;
|
|
|
import cn.reghao.bnt.web.devops.builder.chain.BuildTools;
|
|
|
@@ -14,7 +16,9 @@ import cn.reghao.jutil.jdk.shell.ShellExecutor;
|
|
|
import cn.reghao.jutil.jdk.shell.ShellResult;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
@@ -105,4 +109,41 @@ public class CompilerConfigServiceImpl implements CompilerConfigService {
|
|
|
String html = StringUtil.txtToHtml(shellResult.getResult());
|
|
|
return html;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void addDockerBind(CompilerBindDto compilerBindDto) {
|
|
|
+ int id = compilerBindDto.getId();
|
|
|
+ CompilerConfig compilerConfig = compilerConfigRepository.findById(id).orElse(null);
|
|
|
+ if (compilerConfig == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ String hostPath = compilerBindDto.getHostPath();
|
|
|
+ Map<String, CompilerBind> map = compilerConfig.getCompilerBinds().stream()
|
|
|
+ .collect(Collectors.toMap(CompilerBind::getHostPath, bind -> bind));
|
|
|
+ CompilerBind compilerBind = map.get(hostPath);
|
|
|
+ if (compilerBind == null) {
|
|
|
+ compilerConfig.getCompilerBinds().add(new CompilerBind(compilerBindDto));
|
|
|
+ compilerConfigRepository.save(compilerConfig);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void deleteDockerBind(CompilerBindDto compilerBindDto) {
|
|
|
+ int id = compilerBindDto.getId();
|
|
|
+ CompilerConfig compilerConfig = compilerConfigRepository.findById(id).orElse(null);
|
|
|
+ if (compilerConfig == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ String hostPath = compilerBindDto.getHostPath();
|
|
|
+ Map<String, CompilerBind> map = compilerConfig.getCompilerBinds().stream()
|
|
|
+ .collect(Collectors.toMap(CompilerBind::getHostPath, bind -> bind));
|
|
|
+ CompilerBind compilerBind = map.get(hostPath);
|
|
|
+ if (compilerBind != null) {
|
|
|
+ map.remove(hostPath);
|
|
|
+ compilerConfig.setCompilerBinds(new ArrayList<>(map.values()));
|
|
|
+ compilerConfigRepository.save(compilerConfig);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|