mecha10-deploy 0.6.2

Mecha10 deploy services — Docker management, binary distribution, remote deployment
Documentation
//! Deployment service types

use mecha10_core::enum_str_method;
use std::path::PathBuf;
use std::str::FromStr;

/// Deployment configuration
#[derive(Debug, Clone)]
pub struct DeployConfig {
    pub host: String,
    pub user: String,
    pub port: u16,
    pub ssh_key: Option<PathBuf>,
    pub remote_dir: String,
    pub service_name: String,
    pub backup_dir: String,
    pub health_check_timeout: u64,
    pub health_check_retries: u32,
}

impl Default for DeployConfig {
    fn default() -> Self {
        Self {
            host: "robot.local".to_string(),
            user: "mecha10".to_string(),
            port: 22,
            ssh_key: None,
            remote_dir: "/opt/mecha10".to_string(),
            service_name: "mecha10-robot".to_string(),
            backup_dir: "/opt/mecha10/backups".to_string(),
            health_check_timeout: 30,
            health_check_retries: 3,
        }
    }
}

/// Deployment strategy
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum DeployStrategy {
    Direct,
    Canary,
    Rolling,
    BlueGreen,
}

impl FromStr for DeployStrategy {
    type Err = String;

    fn from_str(s: &str) -> Result<Self, Self::Err> {
        match s {
            "direct" => Ok(DeployStrategy::Direct),
            "canary" => Ok(DeployStrategy::Canary),
            "rolling" => Ok(DeployStrategy::Rolling),
            "blue-green" | "bluegreen" => Ok(DeployStrategy::BlueGreen),
            _ => Err(format!("Invalid deployment strategy: {}", s)),
        }
    }
}

enum_str_method!(
    pub fn as_str(DeployStrategy) -> &str {
        Direct => "direct",
        Canary => "canary",
        Rolling => "rolling",
        BlueGreen => "blue-green",
    }
);

/// Deployment result
#[derive(Debug, Clone)]
pub struct DeployResult {
    pub success: bool,
    pub message: String,
    pub health_check_passed: bool,
    pub backup_created: bool,
}