Commit c157a2a
committed
8dcbbc9 fix: [#300] workaround for clippy large_stack_arrays by commenting tests (Jose Celano)
3ea8c65 refactor: [#300] Phase 3 Port Topology Template Integration (P3.4) (Jose Celano)
Pull request description:
## Summary
Integrates the `PortBinding` domain types (created in #298) into the Docker Compose template rendering, completing Phase 3 of the topology refactoring.
## Changes
### Port Derivation (`port_derivation.rs`)
- Implements PORT-01 through PORT-11 rules from the refactoring plan
- `derive_tracker_ports()` - UDP always exposed, HTTP/API only when no TLS
- `derive_caddy_ports()` - Always exposes 80, 443, 443/udp
- `derive_prometheus_ports()` - 9090 on localhost only
- `derive_grafana_ports()` - 3000 only when no TLS
- `derive_mysql_ports()` - No exposed ports
### Port Definition DTO (`port_definition.rs`)
- `PortDefinition` struct with `binding` and `description` fields
- `From<&PortBinding>` trait for idiomatic conversion
- Serializable for Tera template context
### Service Context Updates
- Added `ports: Vec<PortDefinition>` to all service configs
- Tracker, Caddy, Prometheus, Grafana, MySQL all derive their ports
### Template Simplification (`docker-compose.yml.tera`)
- Replaced conditional port logic with simple loops
- Added description comments using `# {{ port.description }}`
- Removed `needs_ports_section` checks (replaced by `ports | length > 0`)
### Validation
- `try_build()` method on `DockerComposeContextBuilder` validates port uniqueness
- `PortConflictError` with `help()` method for actionable error messages
- DDD "always valid" pattern: `DockerComposeTopology::new()` returns `Result`
### Documentation
- Created Issue #301 spec for Phase 4 (DDD Layer Alignment - future work)
- Updated Epic #287 with Phase 4 tasks
## Testing
- 15 unit tests for port derivation functions
- Unit tests for `PortDefinition` conversion
- Tests for `try_build()` validation
- All E2E tests pass
## Rendered Output Example
```yaml
services:
tracker:
ports:
# BitTorrent UDP announce
- "6969:6969/udp"
# HTTP tracker announce
- "7070:7070"
# HTTP API (stats/whitelist)
- "1212:1212"
```
## Checklist
- [x] Pre-commit checks pass: `./scripts/pre-commit.sh`
- [x] All PORT-* rules implemented in port derivation functions
- [x] Port descriptions render as YAML comments in generated output
- [x] Template uses loops over `service.ports`
- [x] Cross-service port conflicts detected before rendering via `try_build()`
- [x] All existing E2E tests pass
## Related
- **Issue**: #300
- **Epic**: #287 - Docker Compose Topology Domain Model Refactoring
- **Foundation PR**: #299 (merged)
- **Spec**: `docs/issues/300-phase-3-port-topology-template-integration.md`
ACKs for top commit:
josecelano:
ACK 8dcbbc9
Tree-SHA512: 2a71fd13df0353e57d5800210a9e4aeded11e1550f6a5c65b4ff3ae50b6cd111389cc9504bdff4229681c79cbfc639e55720f69e4f4d402d2cbfe5fdaae1ebaf
14 files changed
Lines changed: 1719 additions & 297 deletions
File tree
- docs/issues
- src
- domain/topology
- infrastructure/templating/docker_compose/template/wrappers/docker_compose/context
- templates/docker-compose
Lines changed: 14 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
51 | 61 | | |
52 | 62 | | |
53 | 63 | | |
| |||
66 | 76 | | |
67 | 77 | | |
68 | 78 | | |
69 | | - | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
70 | 83 | | |
71 | 84 | | |
72 | 85 | | |
| |||
Lines changed: 37 additions & 36 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
100 | | - | |
| 100 | + | |
101 | 101 | | |
102 | | - | |
103 | | - | |
| 102 | + | |
| 103 | + | |
104 | 104 | | |
105 | 105 | | |
106 | | - | |
| 106 | + | |
107 | 107 | | |
108 | | - | |
109 | | - | |
| 108 | + | |
| 109 | + | |
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
115 | | - | |
| 115 | + | |
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
| |||
121 | 121 | | |
122 | 122 | | |
123 | 123 | | |
124 | | - | |
125 | | - | |
| 124 | + | |
| 125 | + | |
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
135 | 135 | | |
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
139 | 139 | | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
144 | 144 | | |
145 | 145 | | |
146 | 146 | | |
147 | | - | |
148 | | - | |
149 | | - | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
150 | 151 | | |
151 | 152 | | |
152 | 153 | | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
160 | 161 | | |
161 | 162 | | |
162 | 163 | | |
163 | 164 | | |
164 | 165 | | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
169 | 170 | | |
170 | 171 | | |
171 | 172 | | |
172 | | - | |
173 | | - | |
174 | | - | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
175 | 176 | | |
176 | 177 | | |
177 | 178 | | |
178 | | - | |
179 | | - | |
| 179 | + | |
| 180 | + | |
180 | 181 | | |
181 | 182 | | |
182 | 183 | | |
| |||
0 commit comments