xbp_deploy/cloudflare.rs
1//! Cloudflare deploy adapter trait (injected by CLI).
2//!
3//! The deploy engine stays free of Wrangler / CLI I/O; the CLI crate implements
4//! this trait by calling the existing `xbp cloudflare deploy` workflow.
5
6use async_trait::async_trait;
7use serde::{Deserialize, Serialize};
8
9/// Request to deploy one service via Cloudflare Worker / Containers.
10#[derive(Debug, Clone, Serialize, Deserialize)]
11pub struct CloudflareServiceDeployRequest {
12 pub service_name: String,
13 /// Worker app name (`workers[].name`), defaults to service name when unset.
14 pub worker_app: String,
15 pub dry_run: bool,
16 /// `immediate` | `gradual` (or empty for worker default).
17 pub rollout: Option<String>,
18 pub skip_deploy: bool,
19 pub allow_unchanged_container_image: bool,
20 pub prune_old_images: bool,
21 /// Pre-build the container Dockerfile with local Docker before Wrangler deploy.
22 #[serde(default)]
23 pub local_build: bool,
24 /// Only run the local Docker build (no Wrangler deploy / registry push).
25 #[serde(default)]
26 pub local_build_only: bool,
27}
28
29/// Pluggable Cloudflare deploy backend.
30#[async_trait]
31pub trait CloudflareDeployAdapter: Send + Sync {
32 async fn deploy_service(
33 &self,
34 request: CloudflareServiceDeployRequest,
35 ) -> Result<Vec<String>, String>;
36}