1use serde::{Deserialize, Serialize};
2use std::collections::HashMap;
3
4#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
6pub enum ExecutionMethod {
7 #[serde(rename = "ssh")]
8 SSH,
9 #[serde(rename = "websocket")]
10 WebSocket,
11}
12
13#[derive(Debug, Clone, Serialize, Deserialize)]
15pub struct SshConfig {
16 pub host: String,
17 pub port: u16,
18 pub username: String,
19 pub password: Option<String>,
20 pub private_key_path: Option<String>,
21 pub session_timeout_seconds: Option<u64>,
22 pub timeout_seconds: Option<u64>,
23}
24
25#[derive(Debug, Clone, Serialize, Deserialize)]
27pub struct WebSocketConfig {
28 pub url: String,
29 pub timeout_seconds: Option<u64>,
30}
31
32#[derive(Debug, Clone, Serialize, Deserialize)]
34pub struct ClientConfig {
35 pub name: String,
36 pub execution_method: ExecutionMethod,
37 pub ssh_config: Option<SshConfig>,
38 pub websocket_config: Option<WebSocketConfig>,
39}
40
41#[derive(Debug, Clone, Serialize, Deserialize)]
43pub struct ExtractRule {
44 pub name: String,
45 pub patterns: Vec<String>, pub source: String, #[serde(default = "default_cascade")]
48 pub cascade: bool, }
50
51fn default_cascade() -> bool {
53 true
54}
55
56#[derive(Debug, Clone, Serialize, Deserialize, Default)]
58pub struct Step {
59 pub title: Option<String>,
60 pub name: String,
61 pub script: String,
62 #[serde(default)]
63 pub servers: Vec<String>,
64 pub timeout_seconds: Option<u64>,
65 pub extract: Option<Vec<ExtractRule>>,
66 #[serde(default)]
67 pub variables: Option<HashMap<String, String>>,
68}
69
70#[derive(Debug, Clone, Serialize, Deserialize)]
72pub struct Pipeline {
73 pub name: String,
74 pub title: Option<String>,
75 pub script: Option<String>,
76 pub steps: Vec<Step>,
77}
78
79#[derive(Debug, Clone, Serialize, Deserialize)]
81pub struct RemoteExecutionConfig {
82 pub variables: Option<HashMap<String, String>>,
83 pub clients: HashMap<String, ClientConfig>,
84 pub pipelines: Vec<Pipeline>,
85 pub default_timeout: Option<u64>,
86 pub global_scripts:Vec<String>
87}
88
89#[derive(Debug, Clone)]
91pub enum OutputType {
92 Stdout,
93 Stderr,
94 Log,
95 StepStarted, StepCompleted, }
98
99#[derive(Debug, Clone)]
101pub struct OutputEvent {
102 pub pipeline_name: String,
103 pub server_name: String,
104 pub step: Step, pub output_type: OutputType,
106 pub script_path:String,
107 pub content: String,
108 pub timestamp: std::time::Instant,
109 pub variables: HashMap<String, String>, }
111
112pub type OutputCallback = std::sync::Arc<dyn Fn(OutputEvent) + Send + Sync>;
114
115#[derive(Debug, Clone, Serialize, Deserialize)]
117pub struct ExecutionResult {
118 pub success: bool,
119 pub stdout: String,
120 pub stderr: String,
121 pub script: String,
122 pub exit_code: i32,
123 pub execution_time_ms: u64,
124 pub error_message: Option<String>,
125}
126
127#[derive(Debug, Clone, Serialize, Deserialize)]
129pub struct StepExecutionResult {
130 pub title: String,
131 pub step_name: String,
132 pub server_name: String,
133 pub execution_result: ExecutionResult,
134 pub overall_success: bool,
135 pub scritp_path:String,
136 pub execution_time_ms: u64,
137}
138
139#[derive(Debug, Clone, Serialize, Deserialize)]
141pub struct PipelineExecutionResult {
142 pub pipeline_name: String,
143 pub title: String,
144 pub step_results: Vec<StepExecutionResult>,
145 pub overall_success: bool,
146 pub total_execution_time_ms: u64,
147}
148
149#[derive(Debug, Clone, Serialize, Deserialize)]
151pub struct ShellExecutionResult {
152 pub pipeline_results: Vec<PipelineExecutionResult>,
153 pub success: bool,
154 pub reason: String,
155}