Skip to content

Commit 5b44fb4

Browse files
V VV V
authored andcommitted
feat: control plane supports static (SSG) deploys
- Make bundle field optional (serde default) for static deploys - Add static: bool flag to DeployRequest - Skip bundle validation when static=true - Forward static flag and assets to platform node - SSR deploys unchanged
1 parent 293b9f4 commit 5b44fb4

1 file changed

Lines changed: 19 additions & 9 deletions

File tree

  • rs/crates/magnetic-control-plane/src

rs/crates/magnetic-control-plane/src/server.rs

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,12 @@ struct CreateKeyResponse {
8181
#[derive(Deserialize)]
8282
pub struct DeployRequest {
8383
pub name: Option<String>,
84+
#[serde(default)]
8485
pub bundle: String,
8586
pub assets: Option<HashMap<String, String>>,
8687
pub config: Option<String>,
88+
#[serde(default)]
89+
pub r#static: bool,
8790
}
8891

8992
#[derive(Serialize)]
@@ -242,12 +245,12 @@ async fn deploy(
242245
AuthUser(user): AuthUser,
243246
Json(req): Json<DeployRequest>,
244247
) -> Result<(StatusCode, Json<DeployResponse>), AppError> {
245-
if req.bundle.is_empty() {
246-
return Err(AppError::BadRequest("bundle is required".into()));
248+
if !req.r#static && req.bundle.is_empty() {
249+
return Err(AppError::BadRequest("bundle is required (or set static: true)".into()));
247250
}
248251

249-
// Bundle size limit: 5MB
250-
if req.bundle.len() > 5 * 1024 * 1024 {
252+
// Bundle size limit: 5MB (skip for static deploys which have no bundle)
253+
if !req.r#static && req.bundle.len() > 5 * 1024 * 1024 {
251254
return Err(AppError::BadRequest("bundle exceeds 5MB limit".into()));
252255
}
253256

@@ -333,11 +336,18 @@ async fn deploy(
333336
deploy_url, bundle_len, asset_count, has_config
334337
);
335338

336-
let deploy_payload = serde_json::json!({
337-
"bundle": req.bundle,
338-
"assets": req.assets.as_ref().unwrap_or(&HashMap::new()),
339-
"config": req.config.as_deref().unwrap_or(""),
340-
});
339+
let deploy_payload = if req.r#static {
340+
serde_json::json!({
341+
"static": true,
342+
"assets": req.assets.as_ref().unwrap_or(&HashMap::new()),
343+
})
344+
} else {
345+
serde_json::json!({
346+
"bundle": req.bundle,
347+
"assets": req.assets.as_ref().unwrap_or(&HashMap::new()),
348+
"config": req.config.as_deref().unwrap_or(""),
349+
})
350+
};
341351

342352
let t0 = std::time::Instant::now();
343353
let resp = state

0 commit comments

Comments
 (0)