xbp-deploy 10.57.0

Service-centric declarative deploy engine for XBP.
Documentation
//! 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>;
}