xbp_cli/data/
athena_disabled.rs1use crate::logging::LogEntry;
7use crate::strategies::XbpConfig;
8use serde_json::Value;
9use std::path::Path;
10
11#[derive(Debug, Clone, PartialEq, Eq)]
12pub struct AthenaRuntimeConfig {
13 pub backend: String,
14 pub url: String,
15 pub key: String,
16 pub schema: String,
17}
18
19pub async fn persist_project_snapshot(
20 _project_root: &Path,
21 _config: &XbpConfig,
22 _config_kind: Option<&str>,
23) {
24}
25
26pub async fn persist_log_entry(_entry: &LogEntry) {}
27
28pub async fn persist_nginx_config_snapshot(
29 _domain: &str,
30 _config_path: &Path,
31 _content: &str,
32 _upstream_ports: &[u16],
33 _listen_ports: &[u16],
34 _source: &str,
35) {
36}
37
38pub async fn persist_nginx_log(
39 _domain: Option<&str>,
40 _action: &str,
41 _success: bool,
42 _message: &str,
43 _details: Option<&str>,
44 _metadata: Value,
45) {
46}
47
48pub async fn persist_nginx_edit_audit_log(
49 _domain: Option<&str>,
50 _config_path: Option<&Path>,
51 _actor: Option<&str>,
52 _action: &str,
53 _old_content: Option<&str>,
54 _new_content: Option<&str>,
55 _metadata: Value,
56) {
57}
58
59pub async fn persist_docker_container_snapshot(
60 _container_id: &str,
61 _container_name: &str,
62 _status: Option<&str>,
63 _ports: Option<&str>,
64 _metadata: Value,
65) {
66}
67
68pub async fn persist_docker_log(
69 _container_id: Option<&str>,
70 _command: Option<&str>,
71 _stream: &str,
72 _message: &str,
73 _metadata: Value,
74) {
75}
76
77pub async fn persist_schedule(
78 _schedule_type: &str,
79 _target_kind: &str,
80 _target_ref: Option<&str>,
81 _expression: &str,
82 _enabled: bool,
83 _metadata: Value,
84) {
85}
86
87pub fn extract_cron_restart_expression(args: &[String]) -> Option<String> {
89 for (index, arg) in args.iter().enumerate() {
90 if arg == "--cron-restart" {
91 if let Some(value) = args.get(index + 1) {
92 let value = value.trim();
93 if !value.is_empty() {
94 return Some(value.to_string());
95 }
96 }
97 } else if let Some(value) = arg.strip_prefix("--cron-restart=") {
98 let value = value.trim();
99 if !value.is_empty() {
100 return Some(value.to_string());
101 }
102 }
103 }
104 None
105}
106
107pub fn resolve_runtime_config(_config: Option<&XbpConfig>) -> Option<AthenaRuntimeConfig> {
108 None
109}
110
111pub fn sql_literal(value: &Value) -> String {
112 match value {
113 Value::Null => "NULL".to_string(),
114 Value::Bool(boolean) => boolean.to_string(),
115 Value::Number(number) => number.to_string(),
116 Value::String(text) => format!("'{}'", text.replace('\'', "''")),
117 Value::Array(_) | Value::Object(_) => {
118 format!("'{}'::jsonb", value.to_string().replace('\'', "''"))
119 }
120 }
121}
122
123#[cfg(test)]
124mod tests {
125 use super::extract_cron_restart_expression;
126
127 #[test]
128 fn extract_cron_restart_expression_parses_space_and_equals_forms() {
129 let spaced = vec![
130 "npm".to_string(),
131 "start".to_string(),
132 "--cron-restart".to_string(),
133 "0 * * * *".to_string(),
134 ];
135 assert_eq!(
136 extract_cron_restart_expression(&spaced).as_deref(),
137 Some("0 * * * *")
138 );
139
140 let equals = vec![
141 "npm".to_string(),
142 "start".to_string(),
143 "--cron-restart=15 * * * *".to_string(),
144 ];
145 assert_eq!(
146 extract_cron_restart_expression(&equals).as_deref(),
147 Some("15 * * * *")
148 );
149 }
150}