1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//! Optional OCI image build/push adapter (CLI injects docker buildx).
use async_trait::async_trait;
use serde::{Deserialize, Serialize};
use std::path::PathBuf;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct OciBuildRequest {
pub service: String,
/// Full image reference including tag (e.g. `ghcr.io/org/app:1.2.3`).
pub image_ref: String,
pub dockerfile: Option<String>,
/// Build context directory (absolute or relative to project root; adapter resolves).
pub context: PathBuf,
pub platforms: Vec<String>,
pub dry_run: bool,
pub project_root: PathBuf,
pub service_root: Option<PathBuf>,
/// When true, build into the local Docker engine only (`docker build` /
/// `buildx --load`) and **do not** push to a remote registry.
#[serde(default)]
pub local_image: bool,
}
/// Result of a successful (or dry-run) build/push.
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct OciBuildResult {
pub lines: Vec<String>,
/// Registry digest after push (`sha256:…`) when known.
pub digest: Option<String>,
/// Image reference best used for deploy (digest form when available).
pub image_ref: Option<String>,
/// True when the image was only loaded locally (no registry push).
#[serde(default)]
pub local_only: bool,
}
/// Build and push (or load locally) service images before apply/rollout.
#[async_trait]
pub trait OciBuildAdapter: Send + Sync {
async fn build_and_push(&self, request: OciBuildRequest) -> Result<OciBuildResult, String>;
}