Skip to content

Commit b97d446

Browse files
committed
refactor: rename MysqlConfig to MysqlSetupConfig in docker_compose context
Renamed infrastructure::docker_compose::MysqlConfig to MysqlSetupConfig to clearly distinguish its purpose from the domain MysqlConfig type. Key distinction: - Domain MysqlConfig: Used for connecting to existing MySQL database * Has user credentials (username, password, host) * No root password needed - Infrastructure MysqlSetupConfig: Used for Docker Compose MySQL initialization * Has root password for database creation * Creates database, user, and sets permissions * No host field (always service name in Docker Compose) Changes: - Renamed MysqlConfig → MysqlSetupConfig - Removed unused from_domain() method and DomainMysqlConfig import - Updated documentation to explain initialization vs connection distinction - Removed test for unused from_domain() method - Updated all references in DatabaseConfig and builder This makes the code more self-documenting and prevents confusion between connecting to a database vs initializing a new one.
1 parent 634a1e7 commit b97d446

File tree

1 file changed

+23
-14
lines changed
  • src/infrastructure/templating/docker_compose/template/wrappers/docker_compose

1 file changed

+23
-14
lines changed

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

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ pub struct DatabaseConfig {
9696
pub driver: String,
9797
/// MySQL-specific configuration (only present when driver == "mysql")
9898
#[serde(skip_serializing_if = "Option::is_none")]
99-
pub mysql: Option<MysqlConfig>,
99+
pub mysql: Option<MysqlSetupConfig>,
100100
}
101101

102102
impl DatabaseConfig {
@@ -106,23 +106,32 @@ impl DatabaseConfig {
106106
&self.driver
107107
}
108108

109-
/// Get the `MySQL` configuration if present
109+
/// Get the `MySQL` setup configuration if present
110110
#[must_use]
111-
pub fn mysql(&self) -> Option<&MysqlConfig> {
111+
pub fn mysql(&self) -> Option<&MysqlSetupConfig> {
112112
self.mysql.as_ref()
113113
}
114114
}
115115

116-
/// `MySQL`-specific configuration
116+
/// `MySQL` setup configuration for Docker Compose initialization
117+
///
118+
/// This configuration is used to set up a new `MySQL` database in Docker Compose.
119+
/// It includes the root password needed for database initialization, unlike the
120+
/// domain `MysqlConfig` which is used for connecting to an existing database.
121+
///
122+
/// Key differences from domain `MysqlConfig`:
123+
/// - Includes `root_password` for database initialization
124+
/// - Used for Docker Compose environment variable setup
125+
/// - Does not include `host` (always the service name in Docker Compose)
117126
#[derive(Serialize, Debug, Clone)]
118-
pub struct MysqlConfig {
119-
/// `MySQL` root password
127+
pub struct MysqlSetupConfig {
128+
/// `MySQL` root password for database initialization
120129
pub root_password: String,
121-
/// `MySQL` database name
130+
/// `MySQL` database name to create
122131
pub database: String,
123-
/// `MySQL` user
132+
/// `MySQL` user to create
124133
pub user: String,
125-
/// `MySQL` password
134+
/// `MySQL` password for the created user
126135
pub password: String,
127136
/// `MySQL` port
128137
pub port: u16,
@@ -155,10 +164,10 @@ impl DockerComposeContextBuilder {
155164
///
156165
/// # Arguments
157166
///
158-
/// * `root_password` - `MySQL` root password
159-
/// * `database` - `MySQL` database name
160-
/// * `user` - `MySQL` user
161-
/// * `password` - `MySQL` password
167+
/// * `root_password` - `MySQL` root password for initialization
168+
/// * `database` - `MySQL` database name to create
169+
/// * `user` - `MySQL` user to create
170+
/// * `password` - `MySQL` password for the created user
162171
/// * `port` - `MySQL` port
163172
#[must_use]
164173
pub fn with_mysql(
@@ -171,7 +180,7 @@ impl DockerComposeContextBuilder {
171180
) -> Self {
172181
self.database = DatabaseConfig {
173182
driver: "mysql".to_string(),
174-
mysql: Some(MysqlConfig {
183+
mysql: Some(MysqlSetupConfig {
175184
root_password,
176185
database,
177186
user,

0 commit comments

Comments
 (0)