feat(unifi): converge-unifi — codify the WAN :443 port-forward (#221/#102) - #225
Merged
Conversation
…102) Add a `converge-unifi` engine command that reconciles a declarative UniFi network desired-state (Infrastructure/unifi/network.yaml, kind: UnifiNetwork) via UnifiSharp's legacy write adapter — codifying the WAN :443 → 10.10.0.13:443 port-forward to Pangolin that ADR-0007 stood up by hand. This is the UniFi half of #221 (the Cloudflare wildcard DNS half is #223); unblocks #102. - Infrastructure/unifi/network.yaml: declares the pangolin-https port-forward. - Unifi/UnifiNetworkSpec + UnifiConverge: YAML model + a pure, add-only planner (create declared rules missing by name; never delete hand-managed ones — same guardrail as the Cloudflare reconcile) + ToLegacy mapping + apply. - Program.cs: `converge-unifi <file> [--apply]` — dry-run by default. Auth is the classic controller session (UNIFI_LEGACY_BASE_URL / UNIFI_USERNAME / PASSWORD). - Pin UnifiSharp 0.1.0-preview.27 (exact, like ProxmoxSharp) — the preview with the Legacy namespace; bump the vendored submodule to the matching merged commit. - Tests: 5 unit (add-only plan, case-insensitive match, no-delete, mapping, YAML load). Verified end-to-end against .containers/unifi: dry-run → --apply (created) → re-plan (present, idempotent). 89 engine tests green. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The ValidateShapes CI gate runs `validate` over Infrastructure/ + stacks/, so the new Infrastructure/unifi/network.yaml must satisfy shape.schema.json. Add the UnifiNetwork kind + a strict unifiNetworkSpec (portForwards). Port fields accept string|integer because the validator's YAML→JSON bridge coerces digit-strings to integers; the engine model reads them as strings (allowing ranges like 8080-8090). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Completes the UniFi half of #221 — codifies the WAN
:443→10.10.0.13:443port-forward to Pangolin that ADR-0007 stood up by hand. (The Cloudflare wildcard-DNS half is #223; #221 closes when both land.) Unblocks the write-path goal of #102.What
A new
converge-unifiengine command reconciles a declarative UniFi network desired-state via UnifiSharp's legacy write adapter (merged in UnifiSharp#12; the official integration API can't write port-forwards yet).Infrastructure/unifi/network.yaml(kind: UnifiNetwork) — declares thepangolin-httpsport-forward. Pairs with the grey-cloud*.lab/*.arrA-records from feat(converge): wire wildcard grey-cloud A records into Pangolin (#221) #223: DNS points the hostnames at the home WAN IP, this forwards:443in.Unifi/UnifiNetworkSpec+UnifiConverge— YAML model, a pure add-only planner (creates declared rules missing by name; never deletes hand-managed ones — same guardrail as the Cloudflare reconcile, CLAUDE.md),ToLegacymapping, and apply.converge-unifi <file> [--apply]— dry-run by default;--applywrites. Auth is the classic controller session (UNIFI_LEGACY_BASE_URL/UNIFI_USERNAME/UNIFI_PASSWORD).Legacynamespace) and bump the vendored submodule to the matching merged commit.Verified end-to-end (against
.containers/unifi)Plus 5 unit tests (add-only plan, case-insensitive match, never-delete-unmanaged, field mapping, YAML load). 89 engine tests green.
Auth note for live use
The reconcile uses session auth (proven against the test container). To run it against the live Cloud Gateway, set
UNIFI_LEGACY_BASE_URL+ a local-adminUNIFI_USERNAME/UNIFI_PASSWORD. (The live gateway also accepts itsX-API-KEYon the legacy API; adding optional X-API-KEY auth to the adapter is a clean future follow-up if you'd rather reuse the existingUNIFI_API_KEY.) Like #223, this PR codifies + proves the reconcile without applying to the live gateway.🤖 Generated with Claude Code