Przeglądaj źródła

开发应用编排中的添加应用页面

reghao 5 lat temu
rodzic
commit
8215aab791
22 zmienionych plików z 171 dodań i 562 usunięć
  1. 1 3
      common/src/main/java/cn/reghao/autodop/common/dagent/app/api/data/deploy/AppDeployArgs.java
  2. 2 1
      dagent/src/main/java/cn/reghao/autodop/dagent/app/DockerAppServiceImpl.java
  3. 2 31
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/controller/crud/AppConfigController.java
  4. 24 20
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/controller/view/AppConfigPageController.java
  5. 2 2
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/db/config/AppOrchestrationCrudService.java
  6. 2 2
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/db/config/ProjOrchestrationCrudService.java
  7. 19 52
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/db/config/SharedEntityChecker.java
  8. 14 10
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/entity/config/AppOrchestration.java
  9. 12 6
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/entity/config/ProjOrchestration.java
  10. 1 0
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/entity/config/build/BuildConfig.java
  11. 1 2
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/entity/config/deploy/DeployConfig.java
  12. 3 3
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/entity/log/BuildLog.java
  13. 1 1
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/AppStatusService.java
  14. 4 4
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/bd/AppDeployer.java
  15. 3 13
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/bd/AppIntegrate.java
  16. 0 46
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/vo/BuildConfigVO.java
  17. 0 204
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/vo/orchestration/AppVO.java
  18. 0 82
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/vo/orchestration/ProjVO.java
  19. 0 23
      dmaster/src/main/java/cn/reghao/autodop/dmaster/app/vo/status/BuildDeployAppVO.java
  20. 36 0
      dmaster/src/main/resources/static/js/main.js
  21. 33 44
      dmaster/src/main/resources/templates/app/config/app/add.html
  22. 11 13
      dmaster/src/main/resources/templates/app/config/app/detail.html

+ 1 - 3
common/src/main/java/cn/reghao/autodop/common/dagent/app/api/data/deploy/AppDeployArgs.java

@@ -1,6 +1,5 @@
 package cn.reghao.autodop.common.dagent.app.api.data.deploy;
 
-import cn.reghao.autodop.common.docker.pojo.Config;
 import lombok.Data;
 
 /**
@@ -15,7 +14,6 @@ public class AppDeployArgs {
     private String packerType;
     private String appId;
     private String packagePath;
-    private String startHome;
     private String startScript;
-    private Config dockerConfig;
+    private String startHome;
 }

+ 2 - 1
dagent/src/main/java/cn/reghao/autodop/dagent/app/DockerAppServiceImpl.java

@@ -13,6 +13,7 @@ import cn.reghao.autodop.common.docker.pojo.State;
 import cn.reghao.autodop.common.docker.pojo.result.ContainerInfo;
 import cn.reghao.autodop.common.utils.DateTimeConverter;
 import cn.reghao.autodop.common.utils.ExceptionUtil;
+import cn.reghao.autodop.common.utils.serializer.JsonConverter;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -35,7 +36,7 @@ public class DockerAppServiceImpl implements AppService {
     public AppStatus deploy(AppDeployArgs appDeployArgs) throws DockerException {
         String appId = appDeployArgs.getAppId();
         String packagePath = appDeployArgs.getPackagePath();
-        Config dockerConfig = appDeployArgs.getDockerConfig();
+        Config dockerConfig = JsonConverter.jsonToObject(appDeployArgs.getStartScript(), Config.class);
 
         try (Docker docker = new Docker()) {
             docker.pull(packagePath);

+ 2 - 31
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/controller/crud/AppConfigController.java

@@ -1,22 +1,16 @@
 package cn.reghao.autodop.dmaster.app.controller.crud;
 
 import cn.reghao.autodop.dmaster.utils.WebBody;
-import cn.reghao.autodop.dmaster.utils.db.PageList;
 import cn.reghao.autodop.common.utils.serializer.JsonConverter;
-import cn.reghao.autodop.dmaster.app.entity.config.AppOrchestration;
 import cn.reghao.autodop.dmaster.app.entity.config.ProjOrchestration;
 import cn.reghao.autodop.dmaster.app.db.config.AppOrchestrationCrudService;
 import cn.reghao.autodop.dmaster.app.db.config.ProjOrchestrationCrudService;
-import cn.reghao.autodop.dmaster.app.vo.orchestration.AppVO;
-import cn.reghao.autodop.dmaster.app.vo.orchestration.ProjVO;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.http.ResponseEntity;
 import org.springframework.web.bind.annotation.*;
 
-import java.util.stream.Collectors;
-
 /**
  * @author reghao
  * @date 2019-11-27 11:29:43
@@ -38,9 +32,6 @@ public class AppConfigController {
     @ApiOperation(value = "添加应用编排")
     @PostMapping(value = "/app", consumes = "application/json")
     public ResponseEntity<String> addAppOrchestration(@RequestBody String json) throws Exception {
-        AppVO appVO = JsonConverter.jsonToObject(json, AppVO.class);
-        AppOrchestration app = AppVO.to(appVO);
-        appOrchestrationCrudService.insert(app);
         return ResponseEntity.ok().body(WebBody.success());
     }
 
@@ -55,9 +46,6 @@ public class AppConfigController {
     @ApiOperation(value = "修改应用编排")
     @PutMapping("/app")
     public ResponseEntity<String> modifyAppOrchestration(@RequestBody String json) throws Exception {
-        AppVO appVO = JsonConverter.jsonToObject(json, AppVO.class);
-        AppOrchestration app = AppVO.to(appVO);
-        appOrchestrationCrudService.update(app);
         return ResponseEntity.ok().body(WebBody.success());
     }
 
@@ -73,23 +61,13 @@ public class AppConfigController {
     public ResponseEntity<String> getAppOrchestrationByPage(@RequestParam("page") int page,
                                                             @RequestParam("size") int size,
                                                             @RequestParam("env") String env) {
-        PageList<AppOrchestration> pageList = appOrchestrationCrudService.getByPage(page, size, env);
-        PageList<AppVO> vos = new PageList<>();
-        vos.setTotalPages(pageList.getTotalPages());
-        vos.setTotalSize(pageList.getTotalSize());
-        vos.setHasNext(pageList.isHasNext());
-        vos.setPageSize(pageList.getPageSize());
-        vos.setList(pageList.getList().stream().map(AppVO::from).collect(Collectors.toList()));
-        return ResponseEntity.ok().body(WebBody.success(vos));
+        return ResponseEntity.ok().body(WebBody.success("vos"));
     }
 
     /* 项目编排 */
     @ApiOperation(value = "添加项目编排")
     @PostMapping(value = "/proj", consumes = "application/json")
     public ResponseEntity<String> addProjOrchestration(@RequestBody String json) throws Exception {
-        ProjVO projVO = JsonConverter.jsonToObject(json, ProjVO.class);
-        ProjOrchestration proj = ProjVO.to(projVO);
-        projOrchestrationCrudService.insert(proj);
         return ResponseEntity.ok().body(WebBody.success());
     }
 
@@ -121,13 +99,6 @@ public class AppConfigController {
     public ResponseEntity<String> getProjOrchestrationByPage(@RequestParam("page") int page,
                                                              @RequestParam("size") int size,
                                                              @RequestParam("env") String env) {
-        PageList<ProjOrchestration> pageList = projOrchestrationCrudService.getByPage(page, size, env);
-        PageList<ProjVO> vos = new PageList<>();
-        vos.setTotalPages(pageList.getTotalPages());
-        vos.setTotalSize(pageList.getTotalSize());
-        vos.setHasNext(pageList.isHasNext());
-        vos.setPageSize(pageList.getPageSize());
-        vos.setList(pageList.getList().stream().map(ProjVO::from).collect(Collectors.toList()));
-        return ResponseEntity.ok().body(WebBody.success(vos));
+        return ResponseEntity.ok().body(WebBody.success("vos"));
     }
 }

+ 24 - 20
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/controller/view/AppConfigPageController.java

@@ -4,9 +4,6 @@ import cn.reghao.autodop.dmaster.app.constant.AppType;
 import cn.reghao.autodop.dmaster.app.constant.EnvType;
 import cn.reghao.autodop.dmaster.app.db.app.AppConfigQuery;
 import cn.reghao.autodop.dmaster.app.entity.config.AppOrchestration;
-import cn.reghao.autodop.dmaster.app.entity.config.build.CompilerConfig;
-import cn.reghao.autodop.dmaster.app.entity.config.build.PackerConfig;
-import cn.reghao.autodop.dmaster.app.entity.config.build.RepoAuthConfig;
 import cn.reghao.autodop.dmaster.app.repository.config.AppOrchestrationRepository;
 import cn.reghao.autodop.dmaster.app.repository.config.build.CompilerConfigRepository;
 import cn.reghao.autodop.dmaster.app.repository.config.build.PackerConfigRepository;
@@ -20,6 +17,8 @@ import cn.reghao.autodop.dmaster.utils.db.PageList;
 import cn.reghao.autodop.dmaster.utils.db.PageSort;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import lombok.AllArgsConstructor;
+import lombok.Data;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.PageImpl;
@@ -109,45 +108,43 @@ public class AppConfigPageController {
     }
 
     private void setModel(Model model) {
-        List<String> environments = new ArrayList<>();
+        List<KeyValue> envs = new ArrayList<>();
         for (EnvType envType : EnvType.values()) {
-            environments.add(envType.name());
+            envs.add(new KeyValue(envType.name(), envType.name()));
         }
 
-        List<String> appTypes = new ArrayList<>();
+        List<KeyValue> appTypes = new ArrayList<>();
         for (AppType appType : AppType.values()) {
-            appTypes.add(appType.name());
+            appTypes.add(new KeyValue(appType.name(), appType.name()));
         }
 
-        List<String> repoAuths = repoAuthRepository.findAllByIsDeleteFalse().stream()
-                .map(RepoAuthConfig::getName)
+        List<KeyValue> repoAuths = repoAuthRepository.findAllByIsDeleteFalse().stream()
+                .map(repoAuthConfig -> new KeyValue(String.valueOf(repoAuthConfig.getId()), repoAuthConfig.getName()))
                 .collect(Collectors.toList());
-        List<String> compilers = compilerRepository.findAllByIsDeleteFalse().stream()
-                .map(CompilerConfig::getName)
+        List<KeyValue> compilers = compilerRepository.findAllByIsDeleteFalse().stream()
+                .map(compilerConfig -> new KeyValue(String.valueOf(compilerConfig.getId()), compilerConfig.getName()))
                 .collect(Collectors.toList());
-        List<String> packers = packerRepository.findAllByIsDeleteFalse().stream()
-                .map(PackerConfig::getName)
+        List<KeyValue> packers = packerRepository.findAllByIsDeleteFalse().stream()
+                .map(packerConfig -> new KeyValue(String.valueOf(packerConfig.getId()), packerConfig.getName()))
                 .collect(Collectors.toList());
 
-        List<MachineInfo> machines = machineRepository.findAllByIsDeleteFalse();
-        List<String> machineIpv4s = machines.stream()
+        List<KeyValue> machines = machineRepository.findAllByIsDeleteFalse().stream()
                 .map(machineInfo -> {
                     List<NetworkInfo> networkInfos = machineInfo.getNetworkInfo();
                     if (!networkInfos.isEmpty()) {
-                        return networkInfos.get(0).getIpv4();
+                        return new KeyValue(String.valueOf(machineInfo.getId()), networkInfos.get(0).getIpv4());
                     }
-
                     return null;
                 })
-                .filter(Objects::isNull)
+                .filter(Objects::nonNull)
                 .collect(Collectors.toList());
 
-        model.addAttribute("environments", environments);
+        model.addAttribute("environments", envs);
         model.addAttribute("appTypes", appTypes);
         model.addAttribute("repoAuths", repoAuths);
         model.addAttribute("compilers", compilers);
         model.addAttribute("packers", packers);
-        model.addAttribute("machines", machineIpv4s);
+        model.addAttribute("machines", machines);
     }
 
     @GetMapping("/app/edit/{id}")
@@ -181,4 +178,11 @@ public class AppConfigPageController {
         model.addAttribute("list", pageList.getList());
         return "/app/config/proj/index";
     }
+
+    @AllArgsConstructor
+    @Data
+    class KeyValue {
+        private String key;
+        private String value;
+    }
 }

+ 2 - 2
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/db/config/AppOrchestrationCrudService.java

@@ -36,7 +36,7 @@ public class AppOrchestrationCrudService implements CrudOps<AppOrchestration> {
         if (app.getProj() != null) {
             sharedEntityChecker.checkAndSetProj(app);
         } else {
-            sharedEntityChecker.checkAndSetBuildConfig(app.getBuildConfig());
+            sharedEntityChecker.checkAndSetBuildConfig(app);
         }
         sharedEntityChecker.checkAndSetRole(app);
 
@@ -105,7 +105,7 @@ public class AppOrchestrationCrudService implements CrudOps<AppOrchestration> {
         if (app.getProj() != null) {
             sharedEntityChecker.checkAndSetProj(app);
         } else {
-            sharedEntityChecker.checkAndSetBuildConfig(app.getBuildConfig());
+            sharedEntityChecker.checkAndSetBuildConfig(app);
         }
         sharedEntityChecker.checkAndSetRole(app);
     }

+ 2 - 2
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/db/config/ProjOrchestrationCrudService.java

@@ -28,7 +28,7 @@ public class ProjOrchestrationCrudService implements CrudOps<ProjOrchestration>
 
     @Override
     public void insert(ProjOrchestration proj) throws Exception {
-        sharedEntityChecker.checkAndSetBuildConfig(proj.getBuildConfig());
+        /*sharedEntityChecker.checkAndSetBuildConfig(proj.getBuildConfig());
         ProjOrchestration projEntity = projRepository.findByIsDeleteFalseAndProjId(proj.getProjId());
         if (projEntity != null) {
             proj.setId(projEntity.getId());
@@ -36,7 +36,7 @@ public class ProjOrchestrationCrudService implements CrudOps<ProjOrchestration>
             proj.setUpdateTime(LocalDateTime.now());
         }
         proj.setIsDelete(false);
-        projRepository.save(proj);
+        projRepository.save(proj);*/
     }
 
     public void copy(String from, String to) throws Exception {

+ 19 - 52
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/db/config/SharedEntityChecker.java

@@ -1,6 +1,5 @@
 package cn.reghao.autodop.dmaster.app.db.config;
 
-import cn.reghao.autodop.dmaster.app.entity.config.build.BuildConfig;
 import cn.reghao.autodop.dmaster.app.entity.config.build.CompilerConfig;
 import cn.reghao.autodop.dmaster.app.entity.config.build.PackerConfig;
 import cn.reghao.autodop.dmaster.app.entity.config.build.RepoAuthConfig;
@@ -57,61 +56,29 @@ public class SharedEntityChecker {
      * @return
      * @date 2020-09-30 下午3:17
      */
-    @Deprecated
     public void checkAndSetBuildConfig(AppOrchestration app) throws Exception {
-        BuildConfig buildConfig = app.getBuildConfig();
-        if (buildConfig != null) {
-            RepoAuthConfig repo = buildConfig.getRepoAuthConfig();
-            RepoAuthConfig repoEntity = repoAuthConfigRepository.findByIsDeleteFalseAndName(repo.getName());
-            if (repoEntity != null) {
-                buildConfig.setRepoAuthConfig(repoEntity);
-            } else {
-                throw new Exception("仓库配置 " + repo.getName() + " 不存在...");
-            }
-
-            CompilerConfig compiler = buildConfig.getCompilerConfig();
-            CompilerConfig compilerEntity = compilerConfigRepository.findByIsDeleteFalseAndName(compiler.getName());
-            if (compilerEntity != null) {
-                buildConfig.setCompilerConfig(compilerEntity);
-            } else {
-                throw new Exception("编译器配置 " + compiler.getName() + " 不存在...");
-            }
-
-            PackerConfig packer = buildConfig.getPackerConfig();
-            PackerConfig packerEntity = packerConfigRepository.findByIsDeleteFalseAndName(packer.getName());
-            if (packerEntity != null) {
-                buildConfig.setPackerConfig(packerEntity);
-            } else {
-                throw new Exception("打包配置 " + packer.getName() + " 不存在...");
-            }
+        RepoAuthConfig repo = app.getRepoAuthConfig();
+        RepoAuthConfig repoEntity = repoAuthConfigRepository.findByIsDeleteFalseAndName(repo.getName());
+        if (repoEntity != null) {
+            app.setRepoAuthConfig(repoEntity);
+        } else {
+            throw new Exception("仓库配置 " + repo.getName() + " 不存在...");
         }
-    }
 
-    public void checkAndSetBuildConfig(BuildConfig buildConfig) throws Exception {
-        if (buildConfig != null) {
-            RepoAuthConfig repo = buildConfig.getRepoAuthConfig();
-            RepoAuthConfig repoEntity = repoAuthConfigRepository.findByIsDeleteFalseAndName(repo.getName());
-            if (repoEntity != null) {
-                buildConfig.setRepoAuthConfig(repoEntity);
-            } else {
-                throw new Exception("仓库配置 " + repo.getName() + " 不存在...");
-            }
-
-            CompilerConfig compiler = buildConfig.getCompilerConfig();
-            CompilerConfig compilerEntity = compilerConfigRepository.findByIsDeleteFalseAndName(compiler.getName());
-            if (compilerEntity != null) {
-                buildConfig.setCompilerConfig(compilerEntity);
-            } else {
-                throw new Exception("编译器配置 " + compiler.getName() + " 不存在...");
-            }
+        CompilerConfig compiler = app.getCompilerConfig();
+        CompilerConfig compilerEntity = compilerConfigRepository.findByIsDeleteFalseAndName(compiler.getName());
+        if (compilerEntity != null) {
+            app.setCompilerConfig(compilerEntity);
+        } else {
+            throw new Exception("编译器配置 " + compiler.getName() + " 不存在...");
+        }
 
-            PackerConfig packer = buildConfig.getPackerConfig();
-            PackerConfig packerEntity = packerConfigRepository.findByIsDeleteFalseAndName(packer.getName());
-            if (packerEntity != null) {
-                buildConfig.setPackerConfig(packerEntity);
-            } else {
-                throw new Exception("打包配置 " + packer.getName() + " 不存在...");
-            }
+        PackerConfig packer = app.getPackerConfig();
+        PackerConfig packerEntity = packerConfigRepository.findByIsDeleteFalseAndName(packer.getName());
+        if (packerEntity != null) {
+            app.setPackerConfig(packerEntity);
+        } else {
+            throw new Exception("打包配置 " + packer.getName() + " 不存在...");
         }
     }
 

+ 14 - 10
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/entity/config/AppOrchestration.java

@@ -1,7 +1,9 @@
 package cn.reghao.autodop.dmaster.app.entity.config;
 
+import cn.reghao.autodop.dmaster.app.entity.config.build.CompilerConfig;
+import cn.reghao.autodop.dmaster.app.entity.config.build.PackerConfig;
+import cn.reghao.autodop.dmaster.app.entity.config.build.RepoAuthConfig;
 import cn.reghao.autodop.dmaster.common.orm.BaseEntity;
-import cn.reghao.autodop.dmaster.app.entity.config.build.BuildConfig;
 import cn.reghao.autodop.dmaster.app.entity.config.deploy.DeployConfig;
 import cn.reghao.autodop.dmaster.app.entity.config.deploy.RunningConfig;
 import cn.reghao.autodop.dmaster.auth.entity.Role;
@@ -35,7 +37,17 @@ public class AppOrchestration extends BaseEntity<Integer> implements Cloneable {
 
     // TODO 操作系统类型和版本,CPU 架构
     // 构建配置,buildConfig 和 projId 二者只能存在一个
-    private BuildConfig buildConfig;
+    // buildConfig;
+    @ManyToOne(cascade = CascadeType.PERSIST)
+    @JoinColumn(name = "repo_auth_config_id", foreignKey = @ForeignKey(value = ConstraintMode.NO_CONSTRAINT))
+    private RepoAuthConfig repoAuthConfig;
+    @ManyToOne(cascade = CascadeType.PERSIST)
+    @JoinColumn(name = "compiler_config_id", foreignKey = @ForeignKey(value = ConstraintMode.NO_CONSTRAINT))
+    private CompilerConfig compilerConfig;
+    @ManyToOne(cascade = CascadeType.PERSIST)
+    @JoinColumn(name = "packer_config_id", foreignKey = @ForeignKey(value = ConstraintMode.NO_CONSTRAINT))
+    private PackerConfig packerConfig;
+
     @ManyToOne(cascade = CascadeType.PERSIST)
     @JoinColumn(name = "proj_config_id", foreignKey = @ForeignKey(value = ConstraintMode.NO_CONSTRAINT))
     private ProjOrchestration proj;
@@ -68,12 +80,4 @@ public class AppOrchestration extends BaseEntity<Integer> implements Cloneable {
     public Object clone() throws CloneNotSupportedException {
         return super.clone();
     }
-
-    public AppOrchestration vo() {
-        this.setId(null);
-        this.setIsDelete(null);
-        this.setCreateTime(null);
-        this.setUpdateTime(null);
-        return this;
-    }
 }

+ 12 - 6
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/entity/config/ProjOrchestration.java

@@ -1,7 +1,9 @@
 package cn.reghao.autodop.dmaster.app.entity.config;
 
+import cn.reghao.autodop.dmaster.app.entity.config.build.CompilerConfig;
+import cn.reghao.autodop.dmaster.app.entity.config.build.PackerConfig;
+import cn.reghao.autodop.dmaster.app.entity.config.build.RepoAuthConfig;
 import cn.reghao.autodop.dmaster.common.orm.BaseEntity;
-import cn.reghao.autodop.dmaster.app.entity.config.build.BuildConfig;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.NoArgsConstructor;
@@ -27,11 +29,15 @@ public class ProjOrchestration extends BaseEntity<Integer> implements Cloneable
     @Column(nullable = false)
     private String dirname;
     // 同一个项目内所有应用的构建策略是相同的
-    private BuildConfig buildConfig;
-
-    public ProjOrchestration(String projId) {
-        this.projId = projId;
-    }
+    @ManyToOne(cascade = CascadeType.PERSIST)
+    @JoinColumn(name = "repo_auth_config_id", foreignKey = @ForeignKey(value = ConstraintMode.NO_CONSTRAINT))
+    private RepoAuthConfig repoAuthConfig;
+    @ManyToOne(cascade = CascadeType.PERSIST)
+    @JoinColumn(name = "compiler_config_id", foreignKey = @ForeignKey(value = ConstraintMode.NO_CONSTRAINT))
+    private CompilerConfig compilerConfig;
+    @ManyToOne(cascade = CascadeType.PERSIST)
+    @JoinColumn(name = "packer_config_id", foreignKey = @ForeignKey(value = ConstraintMode.NO_CONSTRAINT))
+    private PackerConfig packerConfig;
 
     @Override
     public Object clone() throws CloneNotSupportedException {

+ 1 - 0
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/entity/config/build/BuildConfig.java

@@ -8,6 +8,7 @@ import javax.persistence.*;
  * @author reghao
  * @date 2020-05-13 16:40:22
  */
+@Deprecated
 @Data
 @Embeddable
 public class BuildConfig {

+ 1 - 2
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/entity/config/deploy/DeployConfig.java

@@ -24,7 +24,6 @@ public class DeployConfig {
     // 参照 https://docs.docker.com/engine/api/v1.40/#operation/ContainerCreate 的 reqeust body
     @Lob
     @Column(columnDefinition="text")
-    private String dockerConfig;
-    private String startHome;
     private String startScript;
+    private String startHome;
 }

+ 3 - 3
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/entity/log/BuildLog.java

@@ -39,9 +39,9 @@ public class BuildLog extends BaseDocument {
         buildLog.setAppType(app.getAppType());
         buildLog.setEnv(app.getEnv());
         buildLog.setBranch(app.getBranch());
-        buildLog.setRepo(app.getBuildConfig().getRepoAuthConfig().getName());
-        buildLog.setCompiler(app.getBuildConfig().getCompilerConfig().getName());
-        buildLog.setPacker(app.getBuildConfig().getPackerConfig().getName());
+        buildLog.setRepo(app.getRepoAuthConfig().getName());
+        buildLog.setCompiler(app.getCompilerConfig().getName());
+        buildLog.setPacker(app.getPackerConfig().getName());
         buildLog.setDockerfile(app.getDockerfile());
 
         buildLog.setBuildTime(new BuildTime());

+ 1 - 1
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/AppStatusService.java

@@ -97,7 +97,7 @@ public class AppStatusService {
     private Map<String, AppStatus> getAppStatusMap(AppOrchestration app, AppOps appOps) {
         List<AsyncMsg> asyncMsgs = new ArrayList<>();
         for (DeployConfig deployConfig : app.getDeployConfigs()) {
-            AppIdArgs appIdArgs = new AppIdArgs(app.getBuildConfig().getPackerConfig().getType(), app.getAppId());
+            AppIdArgs appIdArgs = new AppIdArgs(app.getPackerConfig().getType(), app.getAppId());
 
             AsyncMsg asyncMsg = new AsyncMsg();
             asyncMsg.setMachineId(deployConfig.getMachineId());

+ 4 - 4
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/bd/AppDeployer.java

@@ -44,8 +44,8 @@ public class AppDeployer {
             appDeployArgs.setPackerType(deployConfig.getPackerType());
             appDeployArgs.setStartHome(deployConfig.getStartHome());
             appDeployArgs.setStartScript(deployConfig.getStartScript());
-            String config = deployConfig.getDockerConfig();
-            appDeployArgs.setDockerConfig(JsonConverter.jsonToObject(config, Config.class));
+            String startScript = deployConfig.getStartScript();
+            appDeployArgs.setStartScript(startScript);
 
             String machineId = deployConfig.getMachineId();
             AsyncMsg asyncMsg = new AsyncMsg();
@@ -76,8 +76,8 @@ public class AppDeployer {
             appDeployArgs.setPackerType(deployConfig.getPackerType());
             appDeployArgs.setStartHome(deployConfig.getStartHome());
             appDeployArgs.setStartScript(deployConfig.getStartScript());
-            String config = deployConfig.getDockerConfig();
-            appDeployArgs.setDockerConfig(JsonConverter.jsonToObject(config, Config.class));
+            String startScript = deployConfig.getStartScript();
+            appDeployArgs.setStartScript(startScript);
 
             AsyncMsg asyncMsg = new AsyncMsg();
             asyncMsg.setMachineId(deployConfig.getMachineId());

+ 3 - 13
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/service/bd/AppIntegrate.java

@@ -3,7 +3,6 @@ package cn.reghao.autodop.dmaster.app.service.bd;
 import cn.reghao.autodop.common.dagent.app.api.data.deploy.PackerType;
 import cn.reghao.autodop.dmaster.app.constant.build.CompileType;
 import cn.reghao.autodop.dmaster.app.constant.build.RepoType;
-import cn.reghao.autodop.dmaster.app.entity.config.build.BuildConfig;
 import cn.reghao.autodop.dmaster.app.entity.config.build.CompilerConfig;
 import cn.reghao.autodop.dmaster.app.entity.config.build.PackerConfig;
 import cn.reghao.autodop.dmaster.app.entity.config.build.RepoAuthConfig;
@@ -86,17 +85,8 @@ public class AppIntegrate {
      * @date 2021-02-05 下午11:01
      */
     private void initBuildConfig() {
-        BuildConfig buildConfig;
-        ProjOrchestration proj = app.getProj();
-        if (proj != null) {
-            buildConfig = proj.getBuildConfig();
-            app.setBuildConfig(buildConfig);
-        } else {
-            buildConfig = app.getBuildConfig();
-        }
-
         // 初始化更新配置
-        RepoAuthConfig repoAuthConfig = buildConfig.getRepoAuthConfig();
+        RepoAuthConfig repoAuthConfig = app.getRepoAuthConfig();
         switch (RepoType.valueOf(repoAuthConfig.getType())) {
             case git:
                 codeUpdater = new GitImpl(repoAuthConfig);
@@ -108,7 +98,7 @@ public class AppIntegrate {
         }
 
         // 初始化编译配置
-        CompilerConfig compilerConfig = buildConfig.getCompilerConfig();
+        CompilerConfig compilerConfig = app.getCompilerConfig();
         switch (CompileType.valueOf(compilerConfig.getType())) {
             case shell:
                 codeCompiler = new ShellCompiler(compilerConfig);
@@ -128,7 +118,7 @@ public class AppIntegrate {
         }
 
         // 初始化打包配置
-        PackerConfig packerConfig = buildConfig.getPackerConfig();
+        PackerConfig packerConfig = app.getPackerConfig();
         switch (PackerType.valueOf(packerConfig.getType())) {
             case docker:
                 codePacker = new DockerPack(packerConfig, app.getDockerfile());

+ 0 - 46
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/vo/BuildConfigVO.java

@@ -1,46 +0,0 @@
-package cn.reghao.autodop.dmaster.app.vo;
-
-import cn.reghao.autodop.dmaster.app.entity.config.build.BuildConfig;
-import cn.reghao.autodop.dmaster.app.entity.config.build.CompilerConfig;
-import cn.reghao.autodop.dmaster.app.entity.config.build.PackerConfig;
-import cn.reghao.autodop.dmaster.app.entity.config.build.RepoAuthConfig;
-import lombok.Data;
-
-/**
- * @author reghao
- * @date 2020-09-17 15:06:22
- */
-@Data
-public class BuildConfigVO {
-    private String repo;
-    private String compiler;
-    private String packer;
-
-    public static BuildConfigVO from(BuildConfig buildConfig) {
-        BuildConfigVO vo = new BuildConfigVO();
-        vo.repo = buildConfig.getRepoAuthConfig().getName();
-        vo.compiler = buildConfig.getCompilerConfig().getName();
-        vo.packer = buildConfig.getPackerConfig().getName();
-        return vo;
-    }
-
-    public static BuildConfig to(BuildConfigVO vo) {
-        BuildConfig buildConfig = new BuildConfig();
-        String repo = vo.getRepo();
-        if (repo != null) {
-            buildConfig.setRepoAuthConfig(new RepoAuthConfig(repo));
-        }
-
-        String compiler = vo.getCompiler();
-        if (compiler != null) {
-            buildConfig.setCompilerConfig(new CompilerConfig(compiler));
-        }
-
-        String packer = vo.getPacker();
-        if (packer != null) {
-            buildConfig.setPackerConfig(new PackerConfig(packer));
-        }
-
-        return buildConfig;
-    }
-}

+ 0 - 204
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/vo/orchestration/AppVO.java

@@ -1,204 +0,0 @@
-package cn.reghao.autodop.dmaster.app.vo.orchestration;
-
-import cn.reghao.autodop.common.dagent.app.api.data.log.LogConfig;
-import cn.reghao.autodop.common.dagent.app.api.data.log.LogLevel;
-import cn.reghao.autodop.common.dagent.app.api.data.log.LogType;
-import cn.reghao.autodop.common.utils.serializer.JsonConverter;
-import cn.reghao.autodop.common.dagent.app.api.data.deploy.PackerType;
-import cn.reghao.autodop.dmaster.app.constant.build.CompileType;
-import cn.reghao.autodop.dmaster.app.constant.build.RepoAuthType;
-import cn.reghao.autodop.dmaster.app.constant.build.RepoType;
-import cn.reghao.autodop.dmaster.app.entity.config.build.BuildConfig;
-import cn.reghao.autodop.dmaster.app.entity.config.build.CompilerConfig;
-import cn.reghao.autodop.dmaster.app.entity.config.build.PackerConfig;
-import cn.reghao.autodop.dmaster.app.entity.config.build.RepoAuthConfig;
-import cn.reghao.autodop.dmaster.app.entity.config.AppOrchestration;
-import cn.reghao.autodop.dmaster.app.constant.AppType;
-import cn.reghao.autodop.dmaster.app.constant.EnvType;
-import cn.reghao.autodop.dmaster.app.entity.config.ProjOrchestration;
-import cn.reghao.autodop.dmaster.app.entity.config.deploy.DeployConfig;
-import cn.reghao.autodop.dmaster.app.entity.config.deploy.RunningConfig;
-import cn.reghao.autodop.dmaster.app.vo.BuildConfigVO;
-import cn.reghao.autodop.dmaster.auth.entity.Role;
-import lombok.Data;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author reghao
- * @date 2020-02-29 17:22:19
- */
-@Deprecated
-@Data
-public class AppVO {
-    private String appId;
-    private String env;
-    private String description;
-    private boolean alwaysBuild;
-    private boolean enable;
-
-    /* 构建配置 */
-    private String appType;
-    private String appRepo;
-    private String branch;
-    private String dirname;
-    private String compileHome;
-    private String dockerfile;
-
-    private BuildConfigVO buildConfig;
-    private String projId;
-
-    /* 部署配置 */
-    private List<DeployConfig> deployConfigs;
-    /* 运行配置 */
-    private RunningConfig runningConfig;
-
-    private String notifier;
-    private String role;
-
-    public static AppVO from(AppOrchestration app) {
-        AppVO vo = new AppVO();
-        vo.appId = app.getAppId();
-        vo.env = app.getEnv();
-        vo.description = app.getDescription();
-        vo.enable = app.getEnable();
-
-        vo.appType = app.getAppType();
-        vo.appRepo = app.getAppRepo();
-        vo.branch = app.getBranch();
-        vo.dirname = app.getDirname();
-        vo.compileHome = app.getCompileHome();
-        vo.dockerfile = app.getDockerfile();
-
-        if (app.getBuildConfig() != null) {
-            vo.buildConfig = BuildConfigVO.from(app.getBuildConfig());
-        } else {
-            vo.projId = app.getProj().getProjId();
-        }
-
-        vo.deployConfigs = app.getDeployConfigs();
-        vo.runningConfig = app.getRunningConfig();
-
-        /*if (app.getNotifyReceiver() != null) {
-            vo.notifier = app.getNotifyReceiver().getName();
-        }*/
-
-        if (app.getRole() != null) {
-            vo.role = app.getRole().getName();
-        }
-
-        return vo;
-    }
-
-    public static AppOrchestration to(AppVO vo) {
-        AppOrchestration app = new AppOrchestration();
-        app.setAppId(vo.appId);
-        app.setEnv(vo.env);
-        app.setDescription(vo.description);
-        app.setEnable(vo.enable);
-
-        app.setAppType(vo.appType);
-        app.setAppRepo(vo.appRepo);
-        app.setBranch(vo.branch);
-        app.setDirname(vo.dirname);
-        app.setCompileHome(vo.compileHome);
-        app.setDockerfile(vo.getDockerfile());
-
-        if (vo.getBuildConfig() != null) {
-            app.setBuildConfig(BuildConfigVO.to(vo.getBuildConfig()));
-        } else {
-            app.setProj(new ProjOrchestration(vo.getProjId()));
-        }
-
-        app.setDeployConfigs(vo.getDeployConfigs());
-        app.setRunningConfig(vo.getRunningConfig());
-
-        String notifier = vo.getNotifier();
-        /*if (notifier != null) {
-            app.setNotifyReceiver(new NotifyReceiver(notifier));
-        }*/
-
-        String role = vo.getRole();
-        if (role != null) {
-            app.setRole(new Role());
-        }
-
-        return app;
-    }
-
-    public static void main(String[] args) {
-        AppOrchestration app = new AppOrchestration();
-        app.setAppId("content");
-        app.setEnv(EnvType.test.name());
-        app.setDescription("内容服务");
-        app.setEnable(true);
-        app.setAppType(AppType.dotnetCore.name());
-        app.setAppRepo("https://codeup.aliyun.com/5f1f8daf6207a1a8b17f6742/background/ContentService.git");
-        app.setBranch("develop");
-        app.setDirname("ContentService");
-        app.setCompileHome("");
-
-        BuildConfig buildConfig = new BuildConfig();
-        RepoAuthConfig repoAuthConfig = new RepoAuthConfig();
-        repoAuthConfig.setName("git-codeup");
-        repoAuthConfig.setType(RepoType.git.name());
-        repoAuthConfig.setAuthType(RepoAuthType.ssh.name());
-        repoAuthConfig.setRsaPrikey("rsa private key");
-        buildConfig.setRepoAuthConfig(repoAuthConfig);
-
-        CompilerConfig compilerConfig = new CompilerConfig();
-        compilerConfig.setName("dotnet5-dev");
-        compilerConfig.setType(CompileType.shell.name());
-        /*compilerConfig.setHomePath("/home/reghao/dev/env/dotnet/dotnet-sdk-5.0.100-linux-x64");
-        compilerConfig.setBinPath("/home/reghao/dev/env/dotnet/dotnet-sdk-5.0.100-linux-x64/dotnet");
-        compilerConfig.setCompileCmd("dotnet publish");*/
-        buildConfig.setCompilerConfig(compilerConfig);
-
-        PackerConfig packerConfig = new PackerConfig();
-        packerConfig.setName("docker-dev");
-        packerConfig.setType(PackerType.docker.name());
-        packerConfig.setTargetPath("docker.alpha.iquizoo.com/iq3x");
-        buildConfig.setPackerConfig(packerConfig);
-        app.setBuildConfig(buildConfig);
-
-        List<DeployConfig> list = new ArrayList<>();
-        DeployConfig deployConfig = new DeployConfig();
-        deployConfig.setPackerType(PackerType.docker.name());
-        deployConfig.setStartHome(null);
-        deployConfig.setStartScript(null);
-        deployConfig.setDockerConfig("{\"env\":[\"ASPNETCORE_ENVIRONMENT\\u003dProduction\",\"ASPNETCORE_URLS\\u003dhttp://172.16.45.67:8002;https://172.16.45.67:8102\"],\"hostConfig\":{\"networkMode\":\"host\",\"restartPolicy\":{\"name\":\"on-failure\",\"maximumRetryCount\":5}}}");
-        list.add(deployConfig);
-        app.setDeployConfigs(list);
-
-        RunningConfig runningConfig = new RunningConfig();
-        runningConfig.setHttpPort(8002);
-        runningConfig.setHealthCheck("/health");
-
-        List<LogConfig> logs = new ArrayList<>();
-        LogConfig logConfig = new LogConfig();
-        logConfig.setType(LogType.console.name());
-        logConfig.setLevel(LogLevel.info.name());
-        logConfig.setLogPath(null);
-        logs.add(logConfig);
-
-        LogConfig logConfig1 = new LogConfig();
-        logConfig1.setType(LogType.file.name());
-        logConfig1.setLevel(LogLevel.info.name());
-        logConfig1.setLogPath("/Logs/Info");
-        logs.add(logConfig);
-        //runningConfig.setLogConfigs(logs);
-        app.setRunningConfig(runningConfig);
-
-        /*NotifyReceiver notifyReceiver = new NotifyReceiver();
-        notifyReceiver.setName("ding-dev");
-        notifyReceiver.setType(NotifyType.webhook.name());
-        List<String> receivers = new ArrayList<>();
-        receivers.add("https://oapi.dingtalk.com/robot/send?access_token=ba9cf0d846cff8c471168e0d2f91ec0c44645a086cf5e4e421697c9b0c606bd2");
-        notifyReceiver.setReceivers(receivers);
-        app.setNotifyReceiver(notifyReceiver);*/
-
-        String json = JsonConverter.objectToJson(AppVO.from(app));
-        System.out.println(json);
-    }
-}

+ 0 - 82
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/vo/orchestration/ProjVO.java

@@ -1,82 +0,0 @@
-package cn.reghao.autodop.dmaster.app.vo.orchestration;
-
-import cn.reghao.autodop.common.utils.serializer.JsonConverter;
-import cn.reghao.autodop.dmaster.app.constant.build.CompileType;
-import cn.reghao.autodop.common.dagent.app.api.data.deploy.PackerType;
-import cn.reghao.autodop.dmaster.app.constant.build.RepoAuthType;
-import cn.reghao.autodop.dmaster.app.constant.build.RepoType;
-import cn.reghao.autodop.dmaster.app.entity.config.build.BuildConfig;
-import cn.reghao.autodop.dmaster.app.entity.config.build.CompilerConfig;
-import cn.reghao.autodop.dmaster.app.entity.config.build.PackerConfig;
-import cn.reghao.autodop.dmaster.app.entity.config.build.RepoAuthConfig;
-import cn.reghao.autodop.dmaster.app.entity.config.ProjOrchestration;
-import cn.reghao.autodop.dmaster.app.vo.BuildConfigVO;
-import lombok.Data;
-
-/**
- * @author reghao
- * @date 2020-02-29 17:22:19
- */
-@Data
-public class ProjVO {
-    private String projId;
-    private String description;
-    private String projRepo;
-    private String dirname;
-    private BuildConfigVO buildConfigVO;
-
-    public static ProjVO from(ProjOrchestration proj) {
-        ProjVO vo = new ProjVO();
-        vo.projId = proj.getProjId();
-        vo.description = proj.getDescription();
-        vo.projRepo = proj.getProjRepo();
-        vo.dirname = proj.getDirname();
-        vo.buildConfigVO = BuildConfigVO.from(proj.getBuildConfig());
-        return vo;
-    }
-    
-    public static ProjOrchestration to(ProjVO vo) {
-        ProjOrchestration proj = new ProjOrchestration();
-        proj.setProjId(vo.projId);
-        proj.setDescription(vo.description);
-        proj.setProjRepo(vo.projRepo);
-        proj.setDirname(vo.dirname);
-        proj.setBuildConfig(BuildConfigVO.to(vo.getBuildConfigVO()));
-        return proj;
-    }
-
-    public static void main(String[] args) {
-        ProjOrchestration proj = new ProjOrchestration();
-        proj.setProjId("spiderlab");
-        proj.setDescription("分布式爬虫系统");
-        proj.setProjRepo("http://git.reghao.cn/reghao/spiderlab.git");
-        proj.setDirname("spiderlab");
-
-        /* 构建配置 */
-        BuildConfig buildConfig = new BuildConfig();
-        RepoAuthConfig repoAuthConfig = new RepoAuthConfig();
-        repoAuthConfig.setName("git-codeup");
-        repoAuthConfig.setType(RepoType.git.name());
-        repoAuthConfig.setAuthType(RepoAuthType.ssh.name());
-        repoAuthConfig.setRsaPrikey("rsa private key");
-        buildConfig.setRepoAuthConfig(repoAuthConfig);
-
-        CompilerConfig compilerConfig = new CompilerConfig();
-        compilerConfig.setName("dotnet5-dev");
-        compilerConfig.setType(CompileType.shell.name());
-        /*compilerConfig.setHomePath("/home/reghao/dev/env/dotnet/dotnet-sdk-5.0.100-linux-x64");
-        compilerConfig.setBinPath("/home/reghao/dev/env/dotnet/dotnet-sdk-5.0.100-linux-x64/dotnet");*/
-        compilerConfig.setCompileCmd("dotnet publish");
-        buildConfig.setCompilerConfig(compilerConfig);
-
-        PackerConfig packerConfig = new PackerConfig();
-        packerConfig.setName("docker-dev");
-        packerConfig.setType(PackerType.docker.name());
-        packerConfig.setTargetPath("docker.alpha.iquizoo.com/iq3x");
-        buildConfig.setPackerConfig(packerConfig);
-        proj.setBuildConfig(buildConfig);
-
-        String json = JsonConverter.objectToJson(ProjVO.from(proj));
-        System.out.println(json);
-    }
-}

+ 0 - 23
dmaster/src/main/java/cn/reghao/autodop/dmaster/app/vo/status/BuildDeployAppVO.java

@@ -1,23 +0,0 @@
-package cn.reghao.autodop.dmaster.app.vo.status;
-
-import cn.reghao.autodop.common.utils.DateTimeConverter;
-import cn.reghao.autodop.dmaster.app.entity.status.BuildDeployApp;
-import lombok.Data;
-
-/**
- * @author reghao
- * @date 2021-02-20 13:41:04
- */
-@Deprecated
-@Data
-public class BuildDeployAppVO {
-    private String appId;
-    private String env;
-    private String commitId;
-    private String commitTime;
-    private String bdType;
-    private String bdTime;
-    // 0 - 成功 1 - 失败
-    private Integer statusCode;
-    private String result;
-}

+ 36 - 0
dmaster/src/main/resources/static/js/main.js

@@ -5,6 +5,42 @@ layui.use(['element', 'form', 'layer', 'upload'], function () {
     var layer = layui.layer; //加载layer模块
     var upload = layui.upload;  //加载upload模块
 
+    /*// 触发事件
+    var active = {
+        tabAdd: function(){
+            //新增一个Tab项
+            element.tabAdd('demo', {
+                title: '新选项'+ (Math.random()*1000|0) //用于演示
+                ,content: '内容'+ (Math.random()*1000|0)
+                ,id: new Date().getTime() //实际使用一般是规定好的id,这里以时间戳模拟下
+            })
+        }
+        ,tabDelete: function(othis){
+            //删除指定Tab项
+            element.tabDelete('demo', '44'); //删除:“商品管理”
+
+
+            othis.addClass('layui-btn-disabled');
+        }
+        ,tabChange: function(){
+            //切换到指定Tab项
+            element.tabChange('demo', '22'); //切换到:用户管理
+        }
+    };
+
+    $('.site-demo-active').on('click', function(){
+        var othis = $(this), type = othis.data('type');
+        active[type] ? active[type].call(this, othis) : '';
+    });
+
+    // Hash地址的定位
+    var layid = location.hash.replace(/^#test=/, '');
+    element.tabChange('test', layid);
+
+    element.on('tab(test)', function(elem){
+        location.hash = 'test='+ $(this).attr('lay-id');
+    });*/
+
     /* 侧边栏开关 */
     $(".side-toggle").on("click", function (e) {
         e.preventDefault();

+ 33 - 44
dmaster/src/main/resources/templates/app/config/app/add.html

@@ -1,8 +1,6 @@
 <!DOCTYPE html>
 <html xmlns:th="http://www.thymeleaf.org">
-<head th:replace="/common/template :: header(~{::title},~{::link},~{::style})">
-    <link rel="stylesheet" th:href="@{/lib/zTree_v3/css/zTreeStyle/zTreeStyle.css}" type="text/css">
-</head>
+<head th:replace="/common/template :: header(~{::title},~{::link},~{::style})"></head>
 
 <body>
 <div class="layui-form timo-compile">
@@ -37,11 +35,10 @@
                 <td>
                     <div class="layui-form-item">
                         <div class="layui-input-inline">
-                            <input class="layui-input" type="text" list="isEnable" name="enable" placeholder="请输入是否启用" required th:value="${app?.enable}">
-                            <datalist id="isEnable">
-                                <option>true</option>
-                                <option>false</option>
-                            </datalist>
+                            <select name="enable">
+                                <option value="1">是</option>
+                                <option value="0">否</option>
+                            </select>
                         </div>
                     </div>
                 </td>
@@ -51,10 +48,9 @@
                 <td>
                     <div class="layui-form-item">
                         <div class="layui-input-inline">
-                            <input class="layui-input" type="text" list="envList" name="env"  placeholder="请选择应用所属环境" required th:value="${app?.env}">
-                            <datalist id="envList">
-                                <option th:each="item : ${environments}">[[${item}]]</option>
-                            </datalist>
+                            <select name="env">
+                                <option th:each="item : ${environments}" th:value="${item.key}">[[${item.value}]]</option>
+                            </select>
                         </div>
                     </div>
                 </td>
@@ -62,10 +58,13 @@
                 <td>
                     <div class="layui-form-item">
                         <div class="layui-input-inline">
-                            <input class="layui-input" type="text" list="appTypeList" name="appType"  placeholder="请选择应用类型" required th:value="${app?.appType}">
+                            <select name="appType">
+                                <option th:each="item : ${appTypes}" th:value="${item.key}">[[${item.value}]]</option>
+                            </select>
+                            <!--<input class="layui-input" type="text" list="appTypeList" name="appType"  placeholder="请选择应用类型" required th:value="${app?.appType}">
                             <datalist id="appTypeList">
                                 <option th:each="item : ${appTypes}">[[${item}]]</option>
-                            </datalist>
+                            </datalist>-->
                         </div>
                     </div>
                 </td>
@@ -106,7 +105,7 @@
                 <td>
                     <div class="layui-form-item">
                         <div class="layui-input-inline">
-                            <input class="layui-input" type="text" name="env"  placeholder="请输入应用所属环境" required th:value="${app?.env}">
+                            <input class="layui-input" type="text" name="dirname"  placeholder="请输入应用代码目录" required th:value="${app?.dirname}">
                         </div>
                     </div>
                 </td>
@@ -114,7 +113,7 @@
                 <td>
                     <div class="layui-form-item">
                         <div class="layui-input-inline">
-                            <input class="layui-input" type="text" name="appType"  placeholder="请输入应用类型" required th:value="${app?.appType}">
+                            <input class="layui-input" type="text" name="compileHome"  placeholder="请输入应用编译主目录" required th:value="${app?.compileHome}">
                         </div>
                     </div>
                 </td>
@@ -122,7 +121,7 @@
                 <td>
                     <div class="layui-form-item">
                         <div class="layui-input-inline">
-                            <input class="layui-input" type="text" name="description"  placeholder="请输入应用描述" required th:value="${app?.description}">
+                            <input class="layui-input" type="text" name="execBinName"  placeholder="请输入构建生成的可执行文件名" required th:value="${app?.execBinName}">
                         </div>
                     </div>
                 </td>
@@ -132,7 +131,8 @@
                 <td>
                     <div class="layui-form-item">
                         <div class="layui-input-inline">
-                            <input class="layui-input" type="text" name="appRepo"  placeholder="请输入应用仓库" required th:value="${app?.appRepo}">
+                            <textarea class="layui-textarea" name="dockerfile" placeholder="请输入 Dockerfile" required th:value="${app?.dockerfile}"></textarea>
+                            <!--<input class="layui-input" type="text" name="dockerfile"  placeholder="请输入 Dockerfile" required th:value="${app?.dockerfile}">-->
                         </div>
                     </div>
                 </td>
@@ -142,10 +142,9 @@
                 <td>
                     <div class="layui-form-item">
                         <div class="layui-input-inline">
-                            <input class="layui-input" type="text" list="repoAuthList" name="repoAuth"  placeholder="请选择仓库认证" required th:value="${app?.buildConfig?.repoAuthConfig?.name}">
-                            <datalist id="repoAuthList">
-                                <option th:each="item : ${repoAuths}">[[${item}]]</option>
-                            </datalist>
+                            <select name="repoAuthConfig">
+                                <option th:each="item : ${repoAuths}" th:value="${item.key}">[[${item.value}]]</option>
+                            </select>
                         </div>
                     </div>
                 </td>
@@ -153,10 +152,9 @@
                 <td>
                     <div class="layui-form-item">
                         <div class="layui-input-inline">
-                            <input class="layui-input" type="text" list="compilerList" name="compiler"  placeholder="请选择编译器" required th:value="${app?.buildConfig?.compilerConfig?.name}">
-                            <datalist id="compilerList">
-                                <option th:each="item : ${compilers}">[[${item}]]</option>
-                            </datalist>
+                            <select name="compilerConfig">
+                                <option th:each="item : ${compilers}" th:value="${item.key}">[[${item.value}]]</option>
+                            </select>
                         </div>
                     </div>
                 </td>
@@ -164,10 +162,9 @@
                 <td>
                     <div class="layui-form-item">
                         <div class="layui-input-inline">
-                            <input class="layui-input" type="text" list="packerList" name="compiler"  placeholder="请选择打包工具" required th:value="${app?.buildConfig?.packerConfig?.name}">
-                            <datalist id="packerList">
-                                <option th:each="item : ${packers}">[[${item}]]</option>
-                            </datalist>
+                            <select name="packerConfig">
+                                <option th:each="item : ${packers}" th:value="${item.key}">[[${item.value}]]</option>
+                            </select>
                         </div>
                     </div>
                 </td>
@@ -182,17 +179,17 @@
                 <td>
                     <div class="layui-form-item">
                         <div class="layui-input-inline">
-                            <input class="layui-input" type="text" name="appName"  placeholder="请输入机器地址" required th:value="${app?.appName}">
+                            <select name="machineId">
+                                <option th:each="item : ${machines}" th:value="${item.key}">[[${item.value}]]</option>
+                            </select>
                         </div>
                     </div>
                 </td>
-            </tr>
-            <tr>
-                <th>Docker 配置</th>
+                <th>启动脚本</th>
                 <td>
                     <div class="layui-form-item">
                         <div class="layui-input-inline">
-                            <input class="layui-input" type="text" name="appName"  placeholder="请输入 Docker 配置" required th:value="${app?.appName}">
+                            <textarea class="layui-textarea" name="startScript" placeholder="请输入启动脚本" required th:value="${app?.appName}"></textarea>
                         </div>
                     </div>
                 </td>
@@ -200,15 +197,7 @@
                 <td>
                     <div class="layui-form-item">
                         <div class="layui-input-inline">
-                            <input class="layui-input" type="text" name="appName"  placeholder="请输入启动目录" required th:value="${app?.appName}">
-                        </div>
-                    </div>
-                </td>
-                <th>启动脚本</th>
-                <td>
-                    <div class="layui-form-item">
-                        <div class="layui-input-inline">
-                            <input class="layui-input" type="text" name="appName"  placeholder="请输入启动脚本" required th:value="${app?.appName}">
+                            <input class="layui-input" type="text" name="startHome"  placeholder="请输入启动目录" required th:value="${app?.appName}">
                         </div>
                     </div>
                 </td>

+ 11 - 13
dmaster/src/main/resources/templates/app/config/app/detail.html

@@ -47,27 +47,27 @@
             </tr>
             <tr>
                 <th>仓库类型</th>
-                <td th:text="${app.buildConfig.repoAuthConfig.type}"></td>
+                <td th:text="${app.repoAuthConfig.type}"></td>
                 <th>仓库名字</th>
-                <td th:text="${app.buildConfig.repoAuthConfig.name}"></td>
+                <td th:text="${app.repoAuthConfig.name}"></td>
                 <th>认证类型</th>
-                <td th:text="${app.buildConfig.repoAuthConfig.authType}"></td>
+                <td th:text="${app.repoAuthConfig.authType}"></td>
             </tr>
             <tr>
                 <th>编译器类型</th>
-                <td th:text="${app.buildConfig.compilerConfig.type}"></td>
+                <td th:text="${app.compilerConfig.type}"></td>
                 <th>编译器名字</th>
-                <td th:text="${app.buildConfig.compilerConfig.name}"></td>
+                <td th:text="${app.compilerConfig.name}"></td>
                 <th>编译脚本</th>
-                <td th:text="${app.buildConfig.compilerConfig.compileCmd}"></td>
+                <td th:text="${app.compilerConfig.compileCmd}"></td>
             </tr>
             <tr>
                 <th>打包类型</th>
-                <td th:text="${app.buildConfig.packerConfig.type}"></td>
+                <td th:text="${app.packerConfig.type}"></td>
                 <th>打包名字</th>
-                <td th:text="${app.buildConfig.packerConfig.name}"></td>
+                <td th:text="${app.packerConfig.name}"></td>
                 <th>打包路径</th>
-                <td th:text="${app.buildConfig.packerConfig.targetPath}"></td>
+                <td th:text="${app.packerConfig.targetPath}"></td>
             </tr>
             </tbody>
         </table>
@@ -81,12 +81,10 @@
                 <td th:text="${item.machineIpv4}"></td>
                 <th>打包类型</th>
                 <td th:text="${item.packerType}"></td>
+                <th>启动脚本</th>
+                <td th:text="${item.startScript}"></td>
                 <th th:if="${item?.packerType} != 'docker'">启动目录</th>
                 <td th:if="${item?.packerType} != 'docker'" th:text="${item.startHome}"></td>
-                <th th:if="${item?.packerType} != 'docker'">启动脚本</th>
-                <td th:if="${item?.packerType} != 'docker'" th:text="${item.startScript}"></td>
-                <th th:if="${item?.packerType} eq 'docker'">docker 配置</th>
-                <td th:if="${item?.packerType} eq 'docker'" th:text="${item.dockerConfig}"></td>
             </tr>
             </tbody>
         </table>