mecha10_cli/services/deployment/
types.rs

1//! Deployment service types
2
3use std::path::PathBuf;
4use std::str::FromStr;
5
6/// Deployment configuration
7#[derive(Debug, Clone)]
8pub struct DeployConfig {
9    pub host: String,
10    pub user: String,
11    pub port: u16,
12    pub ssh_key: Option<PathBuf>,
13    pub remote_dir: String,
14    pub service_name: String,
15    pub backup_dir: String,
16    pub health_check_timeout: u64,
17    pub health_check_retries: u32,
18}
19
20impl Default for DeployConfig {
21    fn default() -> Self {
22        Self {
23            host: "robot.local".to_string(),
24            user: "mecha10".to_string(),
25            port: 22,
26            ssh_key: None,
27            remote_dir: "/opt/mecha10".to_string(),
28            service_name: "mecha10-robot".to_string(),
29            backup_dir: "/opt/mecha10/backups".to_string(),
30            health_check_timeout: 30,
31            health_check_retries: 3,
32        }
33    }
34}
35
36/// Deployment strategy
37#[derive(Debug, Clone, Copy, PartialEq, Eq)]
38pub enum DeployStrategy {
39    Direct,
40    Canary,
41    Rolling,
42    BlueGreen,
43}
44
45impl FromStr for DeployStrategy {
46    type Err = String;
47
48    fn from_str(s: &str) -> Result<Self, Self::Err> {
49        match s {
50            "direct" => Ok(DeployStrategy::Direct),
51            "canary" => Ok(DeployStrategy::Canary),
52            "rolling" => Ok(DeployStrategy::Rolling),
53            "blue-green" | "bluegreen" => Ok(DeployStrategy::BlueGreen),
54            _ => Err(format!("Invalid deployment strategy: {}", s)),
55        }
56    }
57}
58
59impl DeployStrategy {
60    pub fn as_str(&self) -> &str {
61        match self {
62            DeployStrategy::Direct => "direct",
63            DeployStrategy::Canary => "canary",
64            DeployStrategy::Rolling => "rolling",
65            DeployStrategy::BlueGreen => "blue-green",
66        }
67    }
68}
69
70/// Deployment result
71#[derive(Debug, Clone)]
72pub struct DeployResult {
73    pub success: bool,
74    pub message: String,
75    pub health_check_passed: bool,
76    pub backup_created: bool,
77}