git

package
v0.6.5 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2026 License: AGPL-3.0 Imports: 26 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package git implements the source.Fetcher for KindGitRepository.

File map:

fetcher.go    — Fetcher type, Fetch entry, fetch + fetchViaMirror, authIdentity
remotebase.go — FetchRemoteBase: anonymous kustomize remote git base
auth.go       — SecretRef → transport.AuthMethod resolution
tls.go        — spec.secretRef.ca.crt → *tls.Config
ssh.go        — SSH host-key callbacks (known_hosts / insecure)
checkout.go   — checkoutRef + updateSubmodules
resolve.go    — ref → commit hash (mirror path)
marker.go     — slot revision sidecar (.flate-meta.json) + 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

	// RestrictSchemes rejects GitRepository URLs whose transport is not
	// https/ssh — file:// (local repo read), git:// (plaintext), http://,
	// and bare paths. It is the untrusted-render guard for #743: a fork-PR
	// GitRepository{ url: file:///some/path } would otherwise clone an
	// arbitrary in-pod git repo and surface its manifests in the diff.
	// Set from Config.RestrictEgress (the same --restrict-egress switch
	// that arms the SSRF guard), so trusted renders keep file:// working
	// (local fixtures, the synthetic self-source — which is pre-seeded and
	// never reaches this fetch path anyway). Default false.
	RestrictSchemes bool

	// ForceGeneric skips the provider gate, sending non-generic providers
	// down the generic SecretRef path. That path works offline when static
	// credentials are supplied, and otherwise fails on the missing secret.
	ForceGeneric bool
}

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) FetchRemoteBase added in v0.3.4

func (f *Fetcher) FetchRemoteBase(ctx context.Context, repoURL, ref string) (*store.SourceArtifact, error)

FetchRemoteBase fetches a public kustomize remote git base: repoURL at a bare, undifferentiated ref (tag, branch, commit, or "" for the default branch), anonymously, returning a SourceArtifact whose LocalPath is a materialized worktree directory (no .git). It is a lean sibling of fetchViaMirror for the one job kustomize remote bases need.

Unlike Fetch — which takes a Flux GitRepository CR with EXCLUSIVE ref fields (Tag XOR Branch XOR Commit XOR …) and a NARROW per-field mirror fetch — kustomize's ?ref= is a single opaque string with `git checkout <ref>` semantics: it may be a tag, branch, or commit SHA and the caller cannot know which. So FetchRemoteBase fetches the mirror BROADLY (empty FetchPlan → +refs/*:refs/*, all heads+tags+HEAD) and resolves the string through resolveRefHash's Name branch, which delegates to go-git ResolveRevision — git rev-parse order over refs/tags then refs/heads then a hash prefix, peeling annotated tags. One call covers every ref kind with no field-guessing; an empty ref resolves to the mirror's HEAD.

Anonymous only (no SecretRef/proxy/TLS/verification/submodules/sparse): kustomize remote bases are public bases; an authenticated base belongs in a real GitRepository CR. Requires Mirrors and Cache. The materialized worktree is cached per (repoURL, ref) in a slot whose ref label is namespaced so it never collides with a real GitRepository CR's slot for the same URL, and is reused on warm runs via the revision recorded in the slot's .flate-meta.json sidecar.

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.

Jump to

Keyboard shortcuts

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