Documentation
¶
Overview ¶
Package rollup maintains the all-time FindingRollup statistics and the TTL deletion of completed findings — causally ordered: nothing is deleted before its spend is aggregated into every scope.
Exactly-once accounting: every Investigation/Remediation child contributes one immutable stage delta per scope (ledger key i:<uid> / r:<uid>); every Finding contributes terminal-phase counts to the total and repository scopes (ledger key f:<uid>:<seq>). A revival (retry, approval) reverses those counts at seq+1 — the finding is back in flight, so only spend-like sums (attempts, the monthly trend) stay put — and a later completion counts it again. A per-scope condition marks aggregation on the contributing object, and the matching rollup finalizer is removed only when the object is deleting and its scope condition is true — kubectl delete can never lose un-aggregated spend, and remaining finalizers show exactly which scopes are owed.
Index ¶
- Constants
- type Reconciler
- func (r *Reconciler) ReconcileFinding(ctx context.Context, req ctrl.Request) (ctrl.Result, error)
- func (r *Reconciler) ReconcileInvestigation(ctx context.Context, req ctrl.Request) (ctrl.Result, error)
- func (r *Reconciler) ReconcileRemediation(ctx context.Context, req ctrl.Request) (ctrl.Result, error)
- func (r *Reconciler) SetupWithManager(mgr ctrl.Manager) error
Constants ¶
const DefaultTTL = 336 * time.Hour
DefaultTTL keeps completed findings for 14 days.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Reconciler ¶
type Reconciler struct {
client.Client
// Namespace the CRs live in.
Namespace string
// TTL after completedAt before a finding is deleted; 0 keeps forever.
TTL time.Duration
// Now is the clock seam; nil means time.Now.
Now func() time.Time
// Log receives diagnostics; nil discards.
Log *slog.Logger
}
Reconciler aggregates rollups and enforces the finding TTL.
func (*Reconciler) ReconcileFinding ¶
ReconcileFinding aggregates terminal-phase counts, applies revival corrections, releases finalizers on deletion, and enforces the TTL.
func (*Reconciler) ReconcileInvestigation ¶
func (r *Reconciler) ReconcileInvestigation(ctx context.Context, req ctrl.Request) (ctrl.Result, error)
ReconcileInvestigation aggregates one investigation run.
func (*Reconciler) ReconcileRemediation ¶
func (r *Reconciler) ReconcileRemediation(ctx context.Context, req ctrl.Request) (ctrl.Result, error)
ReconcileRemediation aggregates one remediation run.
func (*Reconciler) SetupWithManager ¶
func (r *Reconciler) SetupWithManager(mgr ctrl.Manager) error
SetupWithManager registers the three aggregation controllers.