upstream

package
v0.0.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 14, 2026 License: MIT Imports: 20 Imported by: 0

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

func InitBareRepo(gitBin, dir, name string) (string, error)

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

func New(opts Options) (*Upstream, error)

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

func Serve(t *testing.T, opts Options) *Upstream

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) Addr

func (u *Upstream) Addr() string

Addr returns the "host:port" the server is listening on.

func (*Upstream) BaseURL

func (u *Upstream) BaseURL() string

BaseURL returns "http://<addr>".

func (*Upstream) CertPEM

func (u *Upstream) CertPEM() []byte

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

func (u *Upstream) Close() error

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.

func (*Upstream) Dir

func (u *Upstream) Dir() string

Dir returns the parent directory bare repositories are stored under.

func (*Upstream) NewRepo

func (u *Upstream) NewRepo(name string) (string, error)

NewRepo creates (idempotently) a bare repository named name (".git" is appended if not already present) with `http.receivepack` enabled so clients can push to it over smart HTTP.

func (*Upstream) URL

func (u *Upstream) URL(name string) string

URL returns the clone URL for the named repo (".git" appended if not already present). It does not verify the repo exists; call NewRepo first.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL