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