git

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2026 License: AGPL-3.0 Imports: 31 Imported by: 0

Documentation

Overview

Package git implements the source.Fetcher for KindGitRepository.

File map:

fetcher.go    — Fetcher type, Fetch entry, fetch + fetchViaMirror, authIdentity
auth.go       — SecretRef → transport.AuthMethod resolution
tls.go        — spec.secretRef.ca.crt → *tls.Config
ssh.go        — SSH URL / user extraction
checkout.go   — checkoutRef + updateSubmodules
resolve.go    — ref → commit hash (mirror path)
materialize.go — gittree.Materialize bridge
marker.go     — .flate-git-revision slot marker + worktree HEAD lookup

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Fetcher

type Fetcher struct {
	Cache   *source.Cache
	Secrets source.SecretGetter
	Mirrors *mirror.Cache

	// Depth caps the clone/fetch history depth for both the bare mirror
	// and the legacy clone path. 0 (the zero value) clones full history,
	// so library embedders are unaffected; the CLI defaults it to 1
	// (opt-out via --git-depth=0). Shallow is forced off for commit-pinned
	// refs (see effectiveDepth) and, in the legacy path, for submodule
	// recursion. The worktree materialization only needs the resolved
	// tip's tree, which a shallow clone provides in full.
	Depth int
}

Fetcher is the source.Fetcher implementation for KindGitRepository. It owns a shared Cache so multiple GitRepository CRs writing to the same cache root serialize on slot allocation correctly. Secrets is optional; required when a GitRepository sets spec.secretRef.

Mirrors, when set, switches the default fetch path to an incremental bare-mirror-plus-worktree strategy: one bare clone per upstream URL (kept warm across runs and across refs), and per-slot worktrees are materialized by walking the commit tree out of the mirror. The legacy full PlainClone-into-slot path still runs for repos that need submodule recursion or sparse checkout — neither feature is expressible against a bare mirror without a separate fetch that defeats the cache. Leave nil to keep the legacy path everywhere.

func (*Fetcher) Fetch

Fetch implements source.TypedFetcher[*manifest.GitRepository]. The typed signature is wrapped via source.Wrap at orchestrator registration — a payload mismatch returns ErrInput once at the adapter site rather than panicking here.

func (*Fetcher) Prewarm

func (f *Fetcher) Prewarm(ctx context.Context, repo *manifest.GitRepository) error

Prewarm runs the mirror update (OpenOrFetch) for repo without allocating a cache slot or materializing a worktree. Intended to be called in parallel with controller startup so the network I/O for bulky repos overlaps with the orchestrator's cheap listener-replay work — by the time the source controller's reconcile lands on this GitRepository, the per-URL mirror lock is uncontested and OpenOrFetch returns instantly (incremental Fetch sees NoErrAlreadyUpToDate).

Returns nil when the Fetcher has no Mirrors configured or when repo cannot use the mirror path (submodules / sparse checkout) — the normal Fetch path will run unchanged. Resolves auth, TLS, and proxy the same way Fetch does so a misconfigured GitRepository surfaces the same error here as it would during reconcile.

Pre-warm errors are intended to be logged by the caller, not returned to the user — the real Fetch path will hit the same error and produce the canonical status update.

Directories

Path Synopsis
internal
gittransport
Package gittransport carries the shared HTTPS-transport install lock serialized across git.Fetcher and the bare-mirror cache.
Package gittransport carries the shared HTTPS-transport install lock serialized across git.Fetcher and the bare-mirror cache.
Package mirror implements the bare-clone object store shared across GitRepository fetches.
Package mirror implements the bare-clone object store shared across GitRepository fetches.
Package verify performs PGP signature verification against a freshly cloned GitRepository's HEAD commit and/or referenced tag, matching source-controller's spec.verify behavior.
Package verify performs PGP signature verification against a freshly cloned GitRepository's HEAD commit and/or referenced tag, matching source-controller's spec.verify behavior.

Jump to

Keyboard shortcuts

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