Documentation
¶
Overview ¶
Package context is the context-controller's engine. It reacts to newly opened Findings, runs the enhancer chain (CMDB ownership and infrastructure context, as pkg/enhance plugins), records each contribution as an enrichment on the Finding's status, and advances Opened → Enhanced. It holds no tracking-system credential: integration-controller projects enrichments as issue comments.
Enhancement is best-effort. A failing enhancer is logged and skipped, and the transition happens anyway, because enrichment must never block the pipeline.
Index ¶
- func AWSTagsConfigSource(r client.Reader, namespace string) enhancers.AWSConfigSource
- func AssetConfigSource(r client.Reader, namespace string) enhancers.ConfigSource
- func AzureTagsConfigSource(r client.Reader, namespace string) enhancers.AzureConfigSource
- func CachedGenericSource(src enhancers.GenericConfigSource, ttl time.Duration, now func() time.Time) enhancers.GenericConfigSource
- func GenericEnhancerConfigSource(r client.Reader, secrets client.Reader, namespace string, log *slog.Logger) enhancers.GenericConfigSource
- type FindingReconciler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AWSTagsConfigSource ¶ added in v0.9.0
func AWSTagsConfigSource(r client.Reader, namespace string) enhancers.AWSConfigSource
AWSTagsConfigSource reads the resourceTags capability off the namespace's aws Integration, under the same rules as AssetConfigSource: per enhancement through the informer cache, nil when unconfigured, an error on ambiguity.
func AssetConfigSource ¶ added in v0.9.0
func AssetConfigSource(r client.Reader, namespace string) enhancers.ConfigSource
AssetConfigSource reads the cloudAssetInventory capability off the namespace's google-cloud Integration, through the manager's informer cache. Read per enhancement rather than captured at startup, so an operator changing the Integration needs no controller restart. The receiver applies the same rule to webhook secrets.
No capability configured is a nil config (the enhancer stands aside); two Integrations claiming it is an error (the singleton rule), which fails the enhancement closed into a hold rather than picking one arbitrarily.
func AzureTagsConfigSource ¶ added in v0.9.0
func AzureTagsConfigSource(r client.Reader, namespace string) enhancers.AzureConfigSource
AzureTagsConfigSource reads the resourceTags capability off the namespace's azure Integration, under the same rules as AssetConfigSource: per enhancement through the informer cache, nil when unconfigured, an error on ambiguity.
func CachedGenericSource ¶ added in v0.10.0
func CachedGenericSource( src enhancers.GenericConfigSource, ttl time.Duration, now func() time.Time, ) enhancers.GenericConfigSource
CachedGenericSource caches src's answer for ttl. The generic source is the one config source whose read is not free. Every call re-Lists the Integrations and re-reads each signing Secret through the API reader (Secrets are never cached, the cluster-wide rule), and it runs once per enhanced finding, which a brownfield backlog turns into an API-server hammer. The cloud config sources read only the informer cache and stay uncached.
A miss refreshes under the lock, so concurrent reconciles share one upstream read (free singleflight). Errors are never cached: the next caller retries a failed read. Secret rotation propagates within ttl; ttl<=0 disables caching entirely. now tells time; nil means time.Now.
func GenericEnhancerConfigSource ¶ added in v0.9.1
func GenericEnhancerConfigSource( r client.Reader, secrets client.Reader, namespace string, log *slog.Logger, ) enhancers.GenericConfigSource
GenericEnhancerConfigSource reads every enabled generic enhancer endpoint in the namespace: the Integration list through the informer cache, each signing secret through the API reader (Secrets are never cached, the cluster-wide rule). Generic is the one capability exempt from the singleton rule, so this Lists rather than Selects: every enabled integration enhances, each under its own name.
A Secret that cannot be read does not drop its integration from the list: the config is returned secret-less, the call fails for that endpoint alone, and the per-endpoint error carries the integration's name. One broken Secret must not silently skip an enhancer, nor take down the rest.
Types ¶
type FindingReconciler ¶
type FindingReconciler struct {
client.Client
// Enhancers run in order; each contributes at most one enrichment.
Enhancers []enhance.Enhancer
// Concurrency is the number of findings enhanced in parallel (each still
// runs its own chain serially); <=1 means serial. The chain's enhancers
// are concurrency-safe: the cloud wrappers memoize their clients under a
// mutex, and the generic fan-out builds a fresh signed request per call.
Concurrency int
// RetryAfter paces retries of a cloud finding's repository lookup; zero
// means defaultRetryAfter.
RetryAfter time.Duration
// Now tells time; nil means time.Now.
Now func() time.Time
// Log receives diagnostics; nil discards.
Log *slog.Logger
}
FindingReconciler runs the enhancer chain over newly opened Findings. It writes Finding status (enrichments, owners, the ContextEnhanced condition, and the Opened→Enhanced edge) and exactly one spec field: spec.repository, set once for a cloud finding that arrived without one. It holds no tracking-system credential (integration-controller projects comments), though an enhancer may hold a read-only credential for whatever it looks findings up in.
func (*FindingReconciler) SetupWithManager ¶
func (r *FindingReconciler) SetupWithManager(mgr ctrl.Manager) error
SetupWithManager wires the reconciler.