Skip to content

Commit 22ef8ae

Browse files
committed
refactor: reorganize docker_compose context module following conventions
- Grouped imports properly (external → internal) - Main type (DockerComposeContext) with implementation comes first - Helper types (TrackerPorts, DatabaseConfig, MysqlConfig) follow with their implementations - Tests remain at the end Follows docs/contributing/module-organization.md conventions: - Imports always first - Public before private - High-level before low-level - Important before secondary
1 parent cbeac26 commit 22ef8ae

File tree

1 file changed

+38
-36
lines changed
  • src/infrastructure/templating/docker_compose/template/wrappers/docker_compose

1 file changed

+38
-36
lines changed

src/infrastructure/templating/docker_compose/template/wrappers/docker_compose/context.rs

Lines changed: 38 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -3,46 +3,12 @@
33
//! This module defines the structure and validation for Docker Compose services
44
//! that will be rendered into the docker-compose.yml file.
55
6+
// External crates
67
use serde::Serialize;
78

9+
// Internal crate
810
use crate::domain::prometheus::PrometheusConfig;
911

10-
/// Tracker port configuration
11-
#[derive(Debug, Clone)]
12-
pub struct TrackerPorts {
13-
/// UDP tracker ports
14-
pub udp_tracker_ports: Vec<u16>,
15-
/// HTTP tracker ports
16-
pub http_tracker_ports: Vec<u16>,
17-
/// HTTP API port
18-
pub http_api_port: u16,
19-
}
20-
21-
/// Database configuration for docker-compose template
22-
#[derive(Serialize, Debug, Clone)]
23-
pub struct DatabaseConfig {
24-
/// Database driver: "sqlite3" or "mysql"
25-
pub driver: String,
26-
/// MySQL-specific configuration (only present when driver == "mysql")
27-
#[serde(skip_serializing_if = "Option::is_none")]
28-
pub mysql: Option<MysqlConfig>,
29-
}
30-
31-
/// `MySQL`-specific configuration
32-
#[derive(Serialize, Debug, Clone)]
33-
pub struct MysqlConfig {
34-
/// `MySQL` root password
35-
pub root_password: String,
36-
/// `MySQL` database name
37-
pub database: String,
38-
/// `MySQL` user
39-
pub user: String,
40-
/// `MySQL` password
41-
pub password: String,
42-
/// `MySQL` port
43-
pub port: u16,
44-
}
45-
4612
/// Context for rendering the docker-compose.yml template
4713
///
4814
/// Contains all variables needed for the Docker Compose service configuration.
@@ -195,6 +161,27 @@ impl DockerComposeContext {
195161
}
196162
}
197163

164+
/// Tracker port configuration
165+
#[derive(Debug, Clone)]
166+
pub struct TrackerPorts {
167+
/// UDP tracker ports
168+
pub udp_tracker_ports: Vec<u16>,
169+
/// HTTP tracker ports
170+
pub http_tracker_ports: Vec<u16>,
171+
/// HTTP API port
172+
pub http_api_port: u16,
173+
}
174+
175+
/// Database configuration for docker-compose template
176+
#[derive(Serialize, Debug, Clone)]
177+
pub struct DatabaseConfig {
178+
/// Database driver: "sqlite3" or "mysql"
179+
pub driver: String,
180+
/// MySQL-specific configuration (only present when driver == "mysql")
181+
#[serde(skip_serializing_if = "Option::is_none")]
182+
pub mysql: Option<MysqlConfig>,
183+
}
184+
198185
impl DatabaseConfig {
199186
/// Get the database driver name
200187
#[must_use]
@@ -209,6 +196,21 @@ impl DatabaseConfig {
209196
}
210197
}
211198

199+
/// `MySQL`-specific configuration
200+
#[derive(Serialize, Debug, Clone)]
201+
pub struct MysqlConfig {
202+
/// `MySQL` root password
203+
pub root_password: String,
204+
/// `MySQL` database name
205+
pub database: String,
206+
/// `MySQL` user
207+
pub user: String,
208+
/// `MySQL` password
209+
pub password: String,
210+
/// `MySQL` port
211+
pub port: u16,
212+
}
213+
212214
#[cfg(test)]
213215
mod tests {
214216
use super::*;

0 commit comments

Comments
 (0)