git-gate: ExtraHosts on bottle.git entries #12

Merged
didericis merged 3 commits from git-gate-extra-hosts into main 2026-05-12 23:22:27 -04:00
Owner

Summary

Follow-up to #11. bottle.git entries take an optional ExtraHosts: { hostname: ip } map that the docker backend surfaces as --add-host on the gate sidecar. This is for upstreams whose default container DNS doesn't resolve to the reachable IP (e.g. a Tailscale-only host whose public A record points elsewhere): the gate's /etc/hosts gets the override while the agent's insteadOf rewrite still keys off the original hostname, so Upstream URLs in the manifest stay human-readable.

These commits were authored against the git-gate branch but missed the push before #11 merged, so this PR lands them on main as the same three commits cherry-picked. Covered by new unit tests for manifest parsing (default empty, valid map, type / value rejections) and the aggregator that merges per-entry maps and dies on same-host different-IP conflicts.

## Summary Follow-up to #11. `bottle.git` entries take an optional `ExtraHosts: { hostname: ip }` map that the docker backend surfaces as `--add-host` on the gate sidecar. This is for upstreams whose default container DNS doesn't resolve to the reachable IP (e.g. a Tailscale-only host whose public A record points elsewhere): the gate's `/etc/hosts` gets the override while the agent's `insteadOf` rewrite still keys off the original hostname, so `Upstream` URLs in the manifest stay human-readable. These commits were authored against the `git-gate` branch but missed the push before #11 merged, so this PR lands them on main as the same three commits cherry-picked. Covered by new unit tests for manifest parsing (default empty, valid map, type / value rejections) and the aggregator that merges per-entry maps and dies on same-host different-IP conflicts.
didericis added 3 commits 2026-05-12 23:19:23 -04:00
Optional `ExtraHosts: { hostname: ip }` map per git entry. The
docker backend will surface these to the gate sidecar via
--add-host so the gate can resolve upstreams whose default
container DNS doesn't point at the reachable IP (e.g.
Tailscale-only hosts with a public DNS A record pointed
elsewhere). The agent-side insteadOf rewrite still keys off
the original hostname, so the manifest's Upstream URL stays
human-readable.
GitGateUpstream carries each entry's extra_hosts; a new
git_gate_aggregate_extra_hosts() merges them into one map for the
gate container's /etc/hosts. Same host -> same IP is harmless
duplication; same host -> different IPs is a manifest bug
(/etc/hosts is per-container, not per-upstream) and dies with
the conflicting upstream names.

DockerGitGate.start passes one --add-host host:ip per merged
entry on docker create. Empty map (the default) emits no flags
and is a no-op for bottles that don't need DNS overrides.
docs(git-gate): document ExtraHosts on bottle.git entries
test / unit (pull_request) Successful in 12s
test / integration (pull_request) Successful in 19s
9b7bcc0149
- example manifest swaps the gitea-dev bottle from ssh: to git:
  and shows ExtraHosts pinning gitea.dideric.is to its Tailscale IP
- README's git-gate paragraph names the field and the case it
  solves (upstream resolvable on the host but not from the gate
  container's default DNS)
- PRD 0008's manifest-field bullet mentions the field for parity
didericis merged commit 86637453c4 into main 2026-05-12 23:22:27 -04:00
Sign in to join this conversation.