Documentation
¶
Overview ¶
Package upstream provides a fixture git-over-HTTP server for boid's e2e tests. It serves real bare git repositories via `git http-backend` (Go's standard net/http/cgi + a real git binary), so e2e scenario projects can have a real, reachable origin remote instead of the placeholder response hardcoded in e2e/fixtures/hostbin/git's `config` handler.
See docs/plans/git-gateway-cutover.md, "e2e 戦略 (cutover より前に必要)" and "PR7: e2e" (PR7a): without this, cutover (PR6) would leave every e2e scenario's project without a reachable origin, and PR2's "origin の無い project は登録拒否" would make every scenario fail to dispatch.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InitBareRepo ¶
InitBareRepo creates (idempotently) a bare git repository at <dir>/<name>.git using gitBin (empty resolves to the same default New uses), with `http.receivepack` enabled. name may itself contain slashes (e.g. "owner/repo") to mirror a real host's /owner/repo.git URL shape — the parent directory is created first since `git init --bare` does not reliably create more than one missing path component on every git version. It is exported as a standalone function (not tied to a running Upstream) so both Upstream.NewRepo and the e2e harness's one-shot `boid-e2e upstream-serve` startup share one implementation.
Types ¶
type Options ¶
type Options struct {
// Dir is the parent directory bare repositories are created under. If
// empty, New creates a temp directory and removes it on Close.
Dir string
// Addr is the TCP listen address. Defaults to "127.0.0.1:0" (OS-assigned
// port) when empty.
Addr string
// GitBin is the real git binary to invoke. Defaults to /usr/bin/git
// when that exists, else whatever `git` resolves to on PATH. Getting
// this right matters inside the e2e harness, where plain PATH lookup
// would resolve to the fake host git shim instead of a real git.
GitBin string
}
Options configures a fixture upstream git server.
type Upstream ¶
type Upstream struct {
// contains filtered or unexported fields
}
Upstream is a fixture git-over-HTTPS server backed by real bare repositories.
func New ¶
New starts a fixture upstream server listening on opts.Addr (or an OS-assigned loopback port). The caller must call Close when done; tests should use Serve instead, which wires that up automatically.
func Serve ¶
Serve is the test-oriented constructor: it fails t via Fatalf on error and registers a t.Cleanup that closes the server (and removes its directory, when owned).
func (*Upstream) CertPEM ¶
CertPEM returns the PEM-encoded self-signed certificate this Upstream serves TLS with (never the private key). Callers that need clients (real git, or Go's own default cert pool via SSL_CERT_FILE) to trust this server write it to a file — see e2e/lib/common.sh's e2e_setup_fixture_upstream.
func (*Upstream) Close ¶
Close shuts the HTTP server down and, when the Upstream owns its directory (Options.Dir was empty), removes it. Safe to call more than once.