Commit 18e9aee
committed
14a27e4 fix: [#304] add crate-level allow for clippy::large_stack_arrays false positive (Jose Celano)
2f3314a fix(domain): [#301] re-enable aggregate tests with clippy allow attribute (Jose Celano)
1962386 refactor(infrastructure): [#301] extract ServiceTopology shared type (Jose Celano)
195c80e refactor(infrastructure): [#301] remove unused fields from Grafana/Prometheus ServiceContext (Jose Celano)
e87b7ae refactor(infrastructure): [#301] remove legacy fields from TrackerServiceContext (Jose Celano)
f47326f docs: [#301] update Phase 4 progress - Step 7.5 complete (Jose Celano)
8452fb5 refactor(infrastructure): [#301] remove TrackerPorts type alias (Jose Celano)
7a9d035 refactor(infrastructure): [#301] rename service configs to *Context (Jose Celano)
1e28b43 refactor(domain): [#301] replace fixed_ports.rs with domain types for Caddy/MySQL (Jose Celano)
d98df1e docs: [#301] mark Phase 4 acceptance criteria complete (Jose Celano)
49a9eef docs: [#301] update Phase 4 progress - all main goals complete (Jose Celano)
30eb4a1 refactor(domain): [#301] add NetworkDerivation trait and EnabledServices abstraction (Jose Celano)
17a526e refactor: [#301] rename PrometheusServiceConfig and GrafanaServiceConfig constructors (Jose Celano)
9da19b6 refactor: [#301] complete DDD migration - remove TrackerServiceConfig::new() (Jose Celano)
15ae4c9 refactor: [#301] add fixed port functions for Caddy and MySQL in domain (Jose Celano)
62e02ff refactor: [#301] implement PortDerivation for TrackerConfig (Jose Celano)
cdbbda6 refactor: [#301] implement PortDerivation for GrafanaConfig (Jose Celano)
b8db37f refactor: [#301] implement PortDerivation for PrometheusConfig (Jose Celano)
894da3c refactor: [#301] add PortDerivation trait in domain topology (Jose Celano)
Pull request description:
## Summary
Closes #301
This PR completes Phase 4 of the Docker Compose Topology Domain Model Refactoring by extracting a shared `ServiceTopology` type to formalize the architectural pattern discovered during cleanup.
## Problem
After Phase 3 cleanup that removed unused fields from all ServiceContext types, we observed that all 5 types (`TrackerServiceContext`, `GrafanaServiceContext`, `PrometheusServiceContext`, `CaddyServiceContext`, `MysqlServiceContext`) now share identical fields:
```rust
pub ports: Vec<PortDefinition>
pub networks: Vec<Network>
```
This wasn't just coincidence - it represents a clear architectural pattern:
- **Topology data** (ports/networks) → needed for `docker-compose.yml` template (inter-service relationships)
- **Configuration data** (credentials, intervals) → injected via `.env` files (internal service config)
## Solution
Extract a shared `ServiceTopology` type to make this pattern explicit:
```rust
#[derive(Serialize, Debug, Clone, PartialEq, Default)]
pub struct ServiceTopology {
pub ports: Vec<PortDefinition>,
pub networks: Vec<Network>,
}
```
All ServiceContext types now embed this with `#[serde(flatten)]` to maintain template compatibility (flat JSON structure).
## Changes
### New File
- `service_topology.rs` - Shared topology structure with documentation explaining the design rationale
### Updated ServiceContext Types
All now use the embedded `ServiceTopology` pattern:
- `TrackerServiceContext`
- `GrafanaServiceContext`
- `PrometheusServiceContext`
- `CaddyServiceContext`
- `MysqlServiceContext`
### API Changes
- Added `ports()` and `networks()` accessor methods to each ServiceContext
- Updated `builder.rs` to use accessor methods
- Updated all tests to use accessor methods
## Testing
- All 2075 library tests pass
- All E2E tests pass (infrastructure lifecycle + deployment workflow)
- Pre-commit checks pass (linting, formatting, spell check, clippy)
## Architecture Diagram
```
┌─────────────────────────────────────────────────────┐
│ ServiceContext (e.g., Tracker) │
├─────────────────────────────────────────────────────┤
│ #[serde(flatten)] │
│ pub topology: ServiceTopology │
│ ├── ports: Vec<PortDefinition> ─────┐ │
│ └── networks: Vec<Network> ────┼── JSON │
│ │ flat │
└───────────────────────────────────────────┴─────────┘
↓
docker-compose.yml.tera template
```
## Related
- Epic: #287 - Docker Compose Topology Domain Model Refactoring
- Predecessor: #300 - Phase 3 Port Topology Template Integration
- Plan: `docs/refactors/plans/docker-compose-topology-domain-model.md`
ACKs for top commit:
josecelano:
ACK 14a27e4
Tree-SHA512: 3712632ca6c1cad234d31c99e424d7031ea9924d8033b1d5ca2e3743d83f2cd36e6d7861a928b9f21ccfb5a8023d3bdc251f26c4ba152c99c31b5a6d61075bd4
29 files changed
Lines changed: 2620 additions & 1333 deletions
File tree
- docs/issues
- src
- application/steps/rendering
- domain
- caddy
- grafana
- mysql
- prometheus
- topology
- tracker/config
- infrastructure/templating/docker_compose/template
- renderer
- wrappers/docker_compose
- context
Lines changed: 124 additions & 69 deletions
Large diffs are not rendered by default.
Lines changed: 114 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
Lines changed: 25 additions & 60 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
33 | 32 | | |
34 | 33 | | |
35 | | - | |
| 34 | + | |
| 35 | + | |
36 | 36 | | |
37 | | - | |
| 37 | + | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| |||
155 | 155 | | |
156 | 156 | | |
157 | 157 | | |
158 | | - | |
| 158 | + | |
159 | 159 | | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | 160 | | |
165 | 161 | | |
166 | 162 | | |
| |||
169 | 165 | | |
170 | 166 | | |
171 | 167 | | |
| 168 | + | |
172 | 169 | | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
182 | 188 | | |
183 | 189 | | |
184 | 190 | | |
| |||
205 | 211 | | |
206 | 212 | | |
207 | 213 | | |
208 | | - | |
| 214 | + | |
209 | 215 | | |
210 | 216 | | |
211 | 217 | | |
| |||
215 | 221 | | |
216 | 222 | | |
217 | 223 | | |
218 | | - | |
| 224 | + | |
219 | 225 | | |
220 | 226 | | |
221 | 227 | | |
| |||
312 | 318 | | |
313 | 319 | | |
314 | 320 | | |
315 | | - | |
316 | | - | |
317 | | - | |
318 | | - | |
319 | | - | |
320 | | - | |
321 | | - | |
322 | | - | |
323 | | - | |
324 | | - | |
325 | | - | |
326 | | - | |
327 | | - | |
328 | | - | |
329 | | - | |
330 | | - | |
331 | | - | |
332 | | - | |
333 | | - | |
334 | | - | |
335 | | - | |
336 | | - | |
337 | | - | |
338 | | - | |
339 | | - | |
340 | | - | |
341 | | - | |
342 | | - | |
343 | | - | |
344 | | - | |
345 | | - | |
346 | | - | |
347 | | - | |
348 | | - | |
349 | | - | |
350 | | - | |
351 | | - | |
352 | | - | |
353 | | - | |
354 | | - | |
355 | | - | |
356 | 321 | | |
357 | 322 | | |
358 | 323 | | |
| |||
0 commit comments