build

package
v0.6.5 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package build (build-observer) is the side-channel reconciler for Build CRs. It owns two responsibilities that sit outside the main domain reconciliation engine ("environments-build" / pkg/build/api):

  • applyTriggers: mirrors the latest matching GitHubEvent's commit metadata onto the Build's annotations (trigger-type/ref/sha/source), so the execution hash computed in pkg/build/api picks up new commits.
  • applyRetry: counts existing BuildRuns against spec.contract.policy.retry and bumps the retry-attempt annotation to request another dispatch when the most recently observed attempt has failed.

Cross-namespace note: GitHubEvent CRs live in argo-events (created by the Argo Events Sensor); Build CRs live in default (or wherever GitOps places them). Both List calls below are deliberately namespace-unscoped — they rely on the environments.blanketops.dev/name label alone to correlate across namespaces. Do not add client.InNamespace(...) back to either query; doing so silently breaks the cross-namespace correlation (this happened once already — see commit history).

Race note: applyRetry only acts when build.Status.Contract.ExecutionRef matches the most recently created BuildRun. status.Contract is written asynchronously by buildrun-observer and can still reflect a prior attempt's outcome for a short window after a new BuildRun is dispatched but before it completes. Without this check, applyRetry can race ahead and dispatch a second retry before the first has even run.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Reconciler

type Reconciler struct {
	client.Client
	Status   *application.StatusWriter
	Recorder *events.EventRecorder
}

Reconciler mirrors trigger metadata and retry bookkeeping onto Build CRs. See the package doc for its two responsibilities (applyTriggers, applyRetry) and the cross-namespace/race caveats.

func (*Reconciler) Reconcile

func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)

Reconcile fetches the Build, resolves its contract, then applies trigger metadata and retry bookkeeping via applyTriggers/applyRetry.

func (*Reconciler) SetupWithManager

func (r *Reconciler) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager registers the Build observer with the controller manager, watching Build CRs directly and GitHubEvent CRs indirectly via mapGitHubEventToBuilds so a matching trigger event re-enqueues its Build.

Jump to

Keyboard shortcuts

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