provision

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package provision builds registry entries from repo coordinates, resolving the per-repo engine and GitHub client through the app bootstrap layer. It is the shared path used by both server startup and runtime repo onboarding, so the two can't drift in how they wire an engine, broadcaster, and ref watcher.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildEntry

func BuildEntry(ctx context.Context, p EntryParams) (*registry.RepoEntry, error)

BuildEntry resolves p into a runtime context via app.GetContext and returns a ready registry.RepoEntry — broadcaster and ref watcher started, logger close hook attached. The caller adds it to the registry. An empty Path falls back to git discovery from the process working directory, matching the single-repo startup shortcut.

func EnsureClone

func EnsureClone(ctx context.Context, p CloneParams) error

EnsureClone clones CloneURL into Dest unless Dest is already a git checkout. It is idempotent: an existing checkout is treated as success and left untouched, so re-onboarding a repo or restarting after a partial run is safe.

The token is supplied through GIT_CONFIG_* env vars as an http.extraHeader, not embedded in the remote URL — so a per-session user token is not persisted to .git/config where it would outlive the session and leak to disk.

func EnsureInitialized

func EnsureInitialized(ctx context.Context, repoRoot, trunk string) error

EnsureInitialized makes repoRoot a stackit repo if it is not one already, so a freshly cloned checkout can be served (app.GetContext refuses uninitialized repos). trunk is the preferred trunk branch — typically the GitHub default branch — and is inferred when empty or absent locally. Initializing an already-initialized repo is a no-op, so this is safe on the boot path too.

func MirrorFetch

func MirrorFetch(ctx context.Context, repoRoot, remote, token string) error

MirrorFetch updates a server-managed checkout to mirror its remote: it force-updates local branch heads and stackit metadata refs from the remote and prunes refs deleted upstream, so the served stack graph and stack descriptions reflect GitHub.

The checkout's HEAD is detached first because git refuses to fetch into the currently checked-out branch; a managed mirror has no working branch, and the server reads refs (not the working tree), so a frozen tree is harmless.

token authenticates the fetch — a GitHub App installation token for private repos; empty fetches without auth (public repos).

Types

type CloneParams

type CloneParams struct {
	// CloneURL is the source to clone from (e.g. https://github.com/owner/name.git).
	CloneURL string
	// Token authenticates the clone. It is passed to git via environment so it
	// never appears in argv (visible to `ps`) and is never written to the
	// cloned repo's config. Empty clones without authentication (public repos).
	Token string
	// Dest is the absolute checkout path, typically <reposRoot>/<owner>/<name>.
	Dest string
}

CloneParams describes a repository to clone for serving.

type EntryParams

type EntryParams struct {
	ID          string
	DisplayName string
	Path        string
	Remote      string
	// AddedBy is the GitHub login of the user who onboarded this repo, or
	// empty for operator-seeded repos. Carried onto the registry entry for
	// per-user visibility scoping.
	AddedBy string
	// Managed marks a server-owned mirror checkout the sync loop may
	// mirror-fetch (see registry.EntryConfig.Managed).
	Managed bool
	// Owner and Name are the GitHub coordinates carried onto the entry so the
	// sync loop can resolve an installation token.
	Owner string
	Name  string
}

EntryParams is the resolved input needed to build a registry entry: a URL-safe ID, a display label, the on-disk checkout Path, and the git Remote name. Coordinate resolution (owner/name → <reposRoot>/<owner>/<name>) happens in the caller, before BuildEntry.

Jump to

Keyboard shortcuts

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