Publish AI workspace source through the isolated runtime
This commit is contained in:
1 parent
03169bd0f6
commit
d1d14f0f77
21 files changed
+487
-68
No files matched your search
@@ -16,10 +16,15 @@ import org.springframework.web.bind.annotation.*;
|
||||
public class HostingController {
|
||||
private final JdbcTemplate db;
|
||||
private final HostingService hosting;
|
||||
private final SandboxClient sandbox;
|
||||
private final RuntimeGateway runtime;
|
||||
|
||||
public HostingController(JdbcTemplate db, HostingService hosting) {
|
||||
public HostingController(
|
||||
JdbcTemplate db, HostingService hosting, SandboxClient sandbox, RuntimeGateway runtime) {
|
||||
this.db = db;
|
||||
this.hosting = hosting;
|
||||
this.sandbox = sandbox;
|
||||
this.runtime = runtime;
|
||||
}
|
||||
|
||||
public record Plan(
|
||||
@@ -38,6 +43,8 @@ public class HostingController {
|
||||
|
||||
public record Deploy(@NotBlank @Size(max = 200) String idempotencyKey, UUID rollbackId) {}
|
||||
|
||||
public record SourceDeploy(@NotBlank @Size(max = 200) String idempotencyKey) {}
|
||||
|
||||
public record ServiceSpec(
|
||||
@NotBlank @Pattern(regexp = "[a-z][a-z0-9-]{0,62}") String name,
|
||||
@NotBlank @Pattern(regexp = "[a-zA-Z0-9][a-zA-Z0-9._/:@-]{0,499}") String image,
|
||||
@@ -185,6 +192,19 @@ public class HostingController {
|
||||
return hosting.deployments(who.id(), project);
|
||||
}
|
||||
|
||||
@PostMapping("/projects/{project}/deployments/source")
|
||||
public Object deploySource(
|
||||
@AuthenticationPrincipal SecurityConfig.Identity who,
|
||||
@PathVariable UUID project,
|
||||
@Valid @RequestBody SourceDeploy request) {
|
||||
var existing = hosting.beforeSourceSnapshot(who.id(), project, request.idempotencyKey());
|
||||
if (existing != null) return existing;
|
||||
if (!runtime.request("/runtime/source-ready", null).path("ready").asBoolean(false))
|
||||
throw new ApiError.Failure(503, "源码发布运行环境尚未启用,请联系管理员");
|
||||
return hosting.deploySource(
|
||||
who.id(), project, request.idempotencyKey(), sandbox.releaseSnapshot(project));
|
||||
}
|
||||
|
||||
@GetMapping("/projects/{project}/deployments/{id}/events")
|
||||
public Object events(
|
||||
@AuthenticationPrincipal SecurityConfig.Identity who,
|
||||
|
||||
Reference in new issue
Block a user