Documentation
¶
Overview ¶
Package source is the source-controller's engine: the reconcilers for the Forge and Repository kinds. The Forge reconciler validates credentials and stamps readiness; the Repository reconciler resolves the covering Forge, pins the head SHA exactly once, downloads the forge's tarball archive at that SHA (pure HTTP; controllers carry no git binary), and publishes it through the artifact store for agent jobs to fetch credential-lessly. It holds an artifact only while the owning Finding can launch a run (it watches Findings for phase changes), keeps the Repository's Ready condition in step with what the store actually serves, and writes status only when it changes.
Index ¶
Constants ¶
const ( // ReasonInactive: the owning finding is in a phase that cannot launch a // run, so no artifact is held. ReasonInactive = "Inactive" // ReasonArtifactMissing: the status named an artifact the store no // longer holds (the source-controller restarted); it is being fetched // again. ReasonArtifactMissing = "ArtifactMissing" )
Ready condition reasons for a Repository with no artifact to serve.
const DefaultMaxArtifactBytes = int64(1) << 30 // 1 GiB
DefaultMaxArtifactBytes caps a stored tarball; larger repositories stall the Repository instead of exhausting artifact storage.
const RepositoryOwnerIndex = "metadata.ownerFindings"
RepositoryOwnerIndex is the field index over the names of the Findings that own a Repository, which a Finding's phase change is mapped through.
Variables ¶
This section is empty.
Functions ¶
func FindingCacheTransform ¶ added in v0.16.3
FindingCacheTransform trims a cached Finding to what the Repository reconciler reads: identity, spec.retry and status.phase. The source-controller never writes Findings, and a full Finding (alerts, enrichments, phase history) would otherwise cost it the same informer memory the finding-heavy controllers pay.
func FindingChangePredicate ¶ added in v0.16.3
FindingChangePredicate passes the Finding updates the Repository reconciler acts on: a phase change, or a new spec.retry. Creates and deletes pass nothing: a new finding has no Repository yet, and a deleted one takes its Repository with it (whose own delete event cleans up).
func RepositoryOwnerIndexer ¶ added in v0.16.3
RepositoryOwnerIndexer extracts the index values: the names of the Repository's Finding owners. Exported so fake-client tests register the same recipe.
Types ¶
type ForgeReconciler ¶
type ForgeReconciler struct {
client.Client
// Forges mints and validates credentials (shared with the Repository
// reconciler).
Forges *forge.Store
// Log receives reconcile diagnostics; nil discards.
Log *slog.Logger
}
ForgeReconciler validates Forge credentials and maintains the Ready condition.
func (*ForgeReconciler) SetupWithManager ¶
func (r *ForgeReconciler) SetupWithManager(mgr ctrl.Manager) error
SetupWithManager wires the reconciler.
type RepositoryReconciler ¶
type RepositoryReconciler struct {
client.Client
// Forges resolves and authenticates forge access.
Forges *forge.Store
// Artifacts stores and serves the tarballs.
Artifacts *artifact.Store
// MaxArtifactBytes caps a tarball; zero means DefaultMaxArtifactBytes.
MaxArtifactBytes int64
// ClientFor returns the forge API client for a resolution; nil uses the
// Forges store (tests substitute a fake).
ClientFor func(ctx context.Context, res *forge.Resolved) (forgeClient, error)
// ForgeRetry decides how long a failing fetch is retried before the
// Repository stalls for a human retry.
ForgeRetry forgeerr.Policy
// Now tells time; nil means time.Now.
Now func() time.Time
// Log receives reconcile diagnostics; nil discards.
Log *slog.Logger
// contains filtered or unexported fields
}
RepositoryReconciler produces the SHA-pinned tarball artifact for each Repository: resolve the covering Forge, pin the head SHA once, download the archive, publish it through the artifact store.
func (*RepositoryReconciler) Reconcile ¶
func (r *RepositoryReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)
Reconcile implements the Repository control loop.
func (*RepositoryReconciler) SetupWithManager ¶
func (r *RepositoryReconciler) SetupWithManager(mgr ctrl.Manager) error
SetupWithManager wires the reconciler: its own kind; a Forge watch that re-queues every Repository in the namespace (a Forge created or re-scoped after ingest must resolve previously-unresolvable repositories without human action); and a Finding watch that re-queues a finding's Repository when its phase or retry changes, so the artifact is fetched as the finding becomes able to launch a run and dropped when it no longer is.