Commit 803f078
committed
Merge #240: refactor: improve database configuration type safety and module organization
b2bf805 refactor: extract driver name constants in domain database module (Jose Celano)
21d9254 refactor: convert docker_compose context to directory module with builder improvements (Jose Celano)
bc39c9c refactor: rename DockerComposeContextBuilder::new to with_sqlite (Jose Celano)
b97d446 refactor: rename MysqlConfig to MysqlSetupConfig in docker_compose context (Jose Celano)
634a1e7 refactor: convert database.rs into folder module with separate driver modules (Jose Celano)
0057ea3 refactor: extract SqliteConfig and MysqlConfig from DatabaseConfig enum (Jose Celano)
Pull request description:
## Summary
This PR refactors the database configuration structure across the application to improve type safety, eliminate magic strings, and enhance module organization.
## Changes
### 1. Database Configuration Type Extraction
- Extracted `SqliteConfig` and `MysqlConfig` from the `DatabaseConfig` enum
- Converted `database.rs` to `database/` folder module with separate driver modules
- Improved type safety and modularity
### 2. Infrastructure Layer Improvements
- Renamed `MysqlConfig` → `MysqlSetupConfig` in docker_compose context (clearer naming for initialization)
- Converted `docker_compose/context.rs` to directory module with submodules:
- `builder.rs` - Builder pattern implementation
- `database.rs` - Database configuration and constants
- `ports.rs` - Port configuration
- Renamed `DockerComposeContextBuilder::with_sqlite()` → `::new()` (SQLite is the default)
### 3. Builder API Enhancements
- Simplified `with_mysql()` to accept `MysqlSetupConfig` struct instead of 5 individual parameters
- Extracted driver name constants: `DRIVER_SQLITE = "sqlite3"`, `DRIVER_MYSQL = "mysql"`
- Eliminated magic strings throughout the codebase
### 4. Domain Layer Consistency
- Added driver name constants to `domain/tracker/database/mod.rs`
- Updated `driver_name()` method to use constants
- Ensures consistency between domain and infrastructure layers
## Testing
All pre-commit checks passed:
- ✅ 1,515 unit tests
- ✅ 8 E2E integration tests
- ✅ 373 doctests
- ✅ Linting (clippy, rustfmt, shellcheck, markdown, yaml, toml, cspell)
- ✅ E2E infrastructure lifecycle tests
- ✅ E2E deployment workflow tests
## Benefits
- **Type Safety**: Stronger typing with dedicated config structs
- **Maintainability**: Eliminated magic strings with constants
- **Clarity**: Better module organization and clearer naming
- **Consistency**: Unified approach across domain and infrastructure layers
- **Usability**: Simpler builder API with struct parameters
## Migration
No breaking changes for end users. Internal refactoring only.
ACKs for top commit:
josecelano:
ACK b2bf805
Tree-SHA512: 6fe279891b0a28b212938a33e91fe38f0f5b4dcb1c6bc6b92e22069bcbbb6032e1416aa989436853f0c317e8eee837025d412e3d5bccb32d212e8803b52cd8dbFile tree
19 files changed
+472
-318
lines changed- src
- application
- command_handlers/create/config/tracker
- steps/rendering
- domain
- environment
- tracker
- database
- infrastructure/templating
- ansible/template/wrappers/variables
- docker_compose/template
- renderer
- wrappers/docker_compose
- context
- tracker/template
- renderer
- wrapper/tracker_config
19 files changed
+472
-318
lines changedLines changed: 9 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
72 | | - | |
| 72 | + | |
73 | 73 | | |
74 | | - | |
| 74 | + | |
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
81 | | - | |
| 81 | + | |
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
87 | | - | |
| 87 | + | |
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
| |||
143 | 143 | | |
144 | 144 | | |
145 | 145 | | |
146 | | - | |
| 146 | + | |
147 | 147 | | |
148 | | - | |
| 148 | + | |
149 | 149 | | |
150 | 150 | | |
151 | 151 | | |
| |||
217 | 217 | | |
218 | 218 | | |
219 | 219 | | |
220 | | - | |
| 220 | + | |
221 | 221 | | |
222 | 222 | | |
223 | 223 | | |
224 | 224 | | |
225 | 225 | | |
226 | | - | |
| 226 | + | |
227 | 227 | | |
228 | 228 | | |
229 | 229 | | |
| |||
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
126 | | - | |
| 126 | + | |
127 | 127 | | |
128 | 128 | | |
129 | 129 | | |
| |||
150 | 150 | | |
151 | 151 | | |
152 | 152 | | |
153 | | - | |
| 153 | + | |
154 | 154 | | |
155 | | - | |
| 155 | + | |
156 | 156 | | |
157 | 157 | | |
158 | 158 | | |
| |||
Lines changed: 13 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
| 36 | + | |
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| |||
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
| 114 | + | |
| 115 | + | |
122 | 116 | | |
123 | 117 | | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
128 | 122 | | |
129 | 123 | | |
130 | 124 | | |
| |||
191 | 185 | | |
192 | 186 | | |
193 | 187 | | |
194 | | - | |
| 188 | + | |
195 | 189 | | |
196 | | - | |
197 | | - | |
| 190 | + | |
| 191 | + | |
198 | 192 | | |
199 | 193 | | |
200 | | - | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
201 | 197 | | |
202 | 198 | | |
203 | 199 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
127 | 127 | | |
128 | 128 | | |
129 | 129 | | |
130 | | - | |
131 | | - | |
| 130 | + | |
| 131 | + | |
132 | 132 | | |
133 | 133 | | |
134 | 134 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
28 | 28 | | |
29 | | - | |
| 29 | + | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| |||
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
119 | | - | |
| 119 | + | |
120 | 120 | | |
121 | | - | |
| 121 | + | |
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
| |||
158 | 158 | | |
159 | 159 | | |
160 | 160 | | |
161 | | - | |
| 161 | + | |
162 | 162 | | |
163 | | - | |
| 163 | + | |
164 | 164 | | |
165 | 165 | | |
166 | 166 | | |
| |||
185 | 185 | | |
186 | 186 | | |
187 | 187 | | |
188 | | - | |
| 188 | + | |
189 | 189 | | |
190 | | - | |
| 190 | + | |
191 | 191 | | |
192 | 192 | | |
193 | 193 | | |
| |||
0 commit comments