瀏覽代碼

更新 CompilerController 接口

reghao 1 天之前
父節點
當前提交
8b6e30b9f1

+ 22 - 2
mgr/src/main/java/cn/reghao/devops/mgr/ops/build/controller/CompilerController.java

@@ -61,6 +61,7 @@ public class CompilerController {
     @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);
@@ -80,15 +81,34 @@ public class CompilerController {
         return WebResult.success();
     }
 
-    @Operation(summary = "docker 编译器映射目录页面", description = "N")
+    @Operation(summary = "编译器的容器映射目录页面", description = "N")
     @GetMapping(value = "/bind/list", produces = MediaType.APPLICATION_JSON_VALUE)
     public String compilerBindPage(@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");
+    }
 
-        return WebResult.failWithMsg("compiler not docker type");
+    @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 = "编译器的 dockerfile 变量页面", description = "N")
+    @GetMapping(value = "/dockerfile/list", produces = MediaType.APPLICATION_JSON_VALUE)
+    public String compilerDockerfilePage(@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("compiler not dockerBuild type");
     }
 
     @Operation(summary = "添加编译配置", description = "N")

+ 1 - 1
mgr/src/main/java/cn/reghao/devops/mgr/ops/build/model/constant/CompileType.java

@@ -7,7 +7,7 @@ package cn.reghao.devops.mgr.ops.build.model.constant;
  * @date 2019-10-18 14:31:29
  */
 public enum CompileType {
-    none, shell, maven, dockerRun, dockerBuild;
+    none, shell, dockerRun, dockerBuild;
 
     public String getName() {
         return this.name();

+ 21 - 0
mgr/src/main/java/cn/reghao/devops/mgr/ops/build/model/po/CompilerArg.java

@@ -0,0 +1,21 @@
+package cn.reghao.devops.mgr.ops.build.model.po;
+
+import jakarta.persistence.Embeddable;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+
+/**
+ * @author reghao
+ * @date 2026-03-20 18:03:24
+ */
+@AllArgsConstructor
+@NoArgsConstructor
+@Setter
+@Getter
+@Embeddable
+public class CompilerArg {
+    private String argName;
+    private String argValue;
+}

+ 7 - 3
mgr/src/main/java/cn/reghao/devops/mgr/ops/build/model/po/CompilerConfig.java

@@ -44,7 +44,7 @@ public class CompilerConfig extends BaseEntity {
     @NotBlank(groups = { ShellCompiler.class}, message = "编译器版本命令不能为空")
     @Length(max = 1000, message = "编译器版本命令长度不能超过 1000 个字符")
     private String versionCmd;
-    @NotBlank(groups = { DockerCompiler.class}, message = "编译器版本命令不能为空")
+    @NotBlank(groups = { DockerRunCompiler.class}, message = "编译器版本命令不能为空")
     private String compilerImage;
     @ElementCollection(targetClass = CompilerBind.class)
     @LazyCollection(LazyCollectionOption.FALSE)
@@ -54,6 +54,10 @@ public class CompilerConfig extends BaseEntity {
     @LazyCollection(LazyCollectionOption.FALSE)
     @CollectionTable(name = "devops_compiler_config_envs")
     private List<CompilerEnv> compilerEnvs;
+    @ElementCollection(targetClass = CompilerEnv.class)
+    @LazyCollection(LazyCollectionOption.FALSE)
+    @CollectionTable(name = "devops_compiler_config_args")
+    private List<CompilerArg> compilerArgs;
 
     public interface NoneCompiler {
     }
@@ -61,10 +65,10 @@ public class CompilerConfig extends BaseEntity {
     public interface ShellCompiler {
     }
 
-    public interface MavenCompiler {
+    public interface DockerBuildCompiler {
     }
 
-    public interface DockerCompiler {
+    public interface DockerRunCompiler {
     }
 
     public CompilerDto getCompilerDto() {

+ 4 - 2
mgr/src/main/java/cn/reghao/devops/mgr/ops/build/model/provider/CompilerConfigGroupSequenceProvider.java

@@ -23,8 +23,10 @@ public class CompilerConfigGroupSequenceProvider implements DefaultGroupSequence
                 defaultGroupSequence.add(CompilerConfig.NoneCompiler.class);
             } else if (compileType.equals(CompileType.shell.getName())) {
                 defaultGroupSequence.add(CompilerConfig.ShellCompiler.class);
-            } else if (compileType.equals(CompileType.maven.getName())) {
-                defaultGroupSequence.add(CompilerConfig.MavenCompiler.class);
+            } else if (compileType.equals(CompileType.dockerBuild.getName())) {
+                defaultGroupSequence.add(CompilerConfig.DockerBuildCompiler.class);
+            } else if (compileType.equals(CompileType.dockerRun.getName())) {
+                defaultGroupSequence.add(CompilerConfig.DockerRunCompiler.class);
             }
         }
 

+ 1 - 2
mgr/src/main/java/cn/reghao/devops/mgr/ops/builder/tool/compiler/MavenCompiler.java

@@ -19,7 +19,6 @@ import java.util.Collections;
 
 
 @Slf4j
-@Component
 public class MavenCompiler implements CodeCompiler {
     private final MavenXpp3Reader reader;
     private final Invoker invoker;
@@ -122,6 +121,6 @@ public class MavenCompiler implements CodeCompiler {
 
     @Override
     public String supportType() {
-        return CompileType.maven.getName();
+        return CompileType.none.getName();
     }
 }