refactor(backend): split dockerNetworkProvider into focused modules#57
Merged
Conversation
Break the 974-line dockerNetworkProvider.ts (one 780-line applyPlan method) into pure, unit-tested modules for CIDR/gateway addressing, NAT route resolution, iptables rule building, and Nginx config generation, and decompose applyPlan into small named private methods. Dedupes a ~70-line iptables block that was copy-pasted for two gateway IPs. No behavior change: verified against real Docker that the generated iptables ruleset is identical before and after.
Derssa
approved these changes
Jul 14, 2026
OthmaneZ05
added a commit
that referenced
this pull request
Jul 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of Changes
dockerNetworkProvider.tswas a 974-line file dominated by a single 780-lineapplyPlanmethod (manual IPAM, NAT wiring, host iptables bypass, per-container firewall rules, Nginx config generation) with 5-6 levels of indentation and zero test coverage. This PR splits it into focused, unit-tested modules —subnetAddressing.ts(CIDR/gateway helpers),natResolution.ts(NAT route/endpoint lookup),firewallRules.ts(iptables rule builders, also deduping a ~70-line block that was copy-pasted verbatim for two different gateway IPs), andnginxConfigBuilder.ts(load-balancer Nginx config) — and decomposesapplyPlaninto small, named private methods onDockerNetworkProvider, which keeps the same public API. No behavior change.Types of Changes
Verification & Testing
Automated Checks
npm run lintsuccessfully with no errorsnpm run buildsuccessfully with no compilation errorsnpm testsuccessfully (all tests pass)Manual Verification
Ran the app against real Docker: created a project with two Ubuntu nodes in two subnets and a security-group rule, applied the network config, and compared the resulting
iptables -Sruleset and/etc/hostsoutput against the same scenario run with the original (pre-refactor) code — byte-for-byte identical.Checklist