xbp-deploy 10.46.0

Service-centric declarative deploy engine for XBP.
Documentation
use serde::{Deserialize, Serialize};

use crate::types::{DeployTarget, ProjectConfig};

/// Exactly one deploy mode (CLI must enforce exclusivity).
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum DeployMode {
    Plan,
    Run,
    Verify,
    Promote,
    Status,
    History,
}

#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct DeployFlags {
    pub dry_run: bool,
    pub skip_oci: bool,
    pub skip_apply: bool,
    pub skip_rollout: bool,
    pub skip_health: bool,
    pub yes: bool,
    pub json: bool,
    pub namespace: Option<String>,
    pub context: Option<String>,
    pub promote_tag: Option<String>,
    pub history_limit: usize,
    pub output: Option<std::path::PathBuf>,
}

/// Everything the engine needs; built by CLI, consumed by planner/runner/verifier.
#[derive(Debug, Clone)]
pub struct DeployContext {
    pub env: String,
    pub target: DeployTarget,
    pub config: ProjectConfig,
    pub flags: DeployFlags,
    pub mode: DeployMode,
}

impl DeployContext {
    pub fn require_confirmation(&self) -> bool {
        if self.flags.yes || self.flags.dry_run {
            return false;
        }
        self.config
            .kubernetes
            .as_ref()
            .map(|k| k.require_context_confirmation_for_apply)
            .unwrap_or(true)
    }
}