watcher

package
v0.2.220 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: Apache-2.0 Imports: 60 Imported by: 0

Documentation

Index

Constants

View Source
const NamespaceFiltersKey = "namespaceFilters.json"

Variables

View Source
var (
	ErrMissingWLID          = fmt.Errorf("missing WLID")
	ErrMissingWlid          = ErrMissingWLID // alias used by SBOM watcher retry path
	ErrMissingSlug          = fmt.Errorf("missing slug")
	ErrMissingImageTag      = fmt.Errorf("missing image tag")
	ErrMissingImageID       = fmt.Errorf("missing image ID")
	ErrMissingInstanceID    = fmt.Errorf("missing instanceID")
	ErrMissingContainerName = fmt.Errorf("missing container name")
	ErrUnsupportedObject    = errors.New("unsupported object type")
)

Functions

func ConvertUnstructuredToOperatorCommand added in v0.2.40

func ConvertUnstructuredToOperatorCommand(un *unstructured.Unstructured) (*v1alpha1.OperatorCommand, error)

func DropGoneVersion added in v0.2.220

func DropGoneVersion(opts *metav1.ListOptions, err error)

DropGoneVersion forgets the resume version when err says the server no longer has it, whether the server said so in an event or by refusing the watch request itself.

func ResumeFrom added in v0.2.220

func ResumeFrom(opts *metav1.ListOptions, event watch.Event)

ResumeFrom records where the next watch resumes, the way client-go's RetryWatcher does: at the version of the last object received, so a reconnect carries on from there, or from the current state when the server says that version is gone, since nothing else can follow it. An error event carries a Status, not an object; its empty version is not a place to resume, and taking it for one restarted the watch from scratch after any error, replaying every object.

Types

type CommandWatchHandler added in v0.2.40

type CommandWatchHandler struct {
	// contains filtered or unexported fields
}

func NewCommandWatchHandler added in v0.2.40

func NewCommandWatchHandler(k8sAPI *k8sinterface.KubernetesApi, config config.IConfig) *CommandWatchHandler

func (*CommandWatchHandler) AddHandler added in v0.2.40

func (cwh *CommandWatchHandler) AddHandler(obj runtime.Object)

func (*CommandWatchHandler) CommandWatch added in v0.2.40

func (cwh *CommandWatchHandler) CommandWatch(ctx context.Context)

func (*CommandWatchHandler) RegisterForCommands added in v0.2.40

func (cwh *CommandWatchHandler) RegisterForCommands(receiver chan v1alpha1.OperatorCommand)

type CooldownQueue added in v0.2.4

type CooldownQueue struct {
	ResultChan <-chan watch.Event
	// contains filtered or unexported fields
}

CooldownQueue is a queue that lets clients put events into it with a cooldown

When a client puts an event into a queue, it waits for a cooldown period before the event is forwarded to the consumer. If an event for the same key is put into the queue again before the cooldown period is over, the event is overridden and the cooldown period is reset.

func NewCooldownQueue added in v0.2.4

func NewCooldownQueue() *CooldownQueue

NewCooldownQueue returns a new Cooldown Queue

func NewCooldownQueueWithParams added in v0.2.63

func NewCooldownQueueWithParams(expiration, interval time.Duration) *CooldownQueue

func (*CooldownQueue) Closed added in v0.2.4

func (q *CooldownQueue) Closed() bool

func (*CooldownQueue) Enqueue added in v0.2.4

func (q *CooldownQueue) Enqueue(e watch.Event)

Enqueue enqueues an event in the Cooldown Queue

func (*CooldownQueue) Stop added in v0.2.4

func (q *CooldownQueue) Stop()

type NamespaceFilterWatcher added in v0.2.181

type NamespaceFilterWatcher struct {
	// contains filtered or unexported fields
}

NamespaceFilterWatcher owns the live namespace filter source. Run and WaitForReady must use the process context, including during startup.

func NewNamespaceFilterWatcher added in v0.2.181

func NewNamespaceFilterWatcher(client kubernetes.Interface, cfg *config.OperatorConfig, name string) (*NamespaceFilterWatcher, error)

func (*NamespaceFilterWatcher) Run added in v0.2.181

Run blocks until cancellation. The informer relists and reconnects on API failures; failures never replace the last successfully validated snapshot.

func (*NamespaceFilterWatcher) WaitForReady added in v0.2.181

func (w *NamespaceFilterWatcher) WaitForReady(ctx context.Context) error

type OperatorCommandsHandler added in v0.2.63

type OperatorCommandsHandler struct {
	// contains filtered or unexported fields
}

func NewOperatorCommandsHandler added in v0.2.63

func NewOperatorCommandsHandler(ctx context.Context, pool *ants.PoolWithFunc, k8sAPI *k8sinterface.KubernetesApi, commandsWatcher *CommandWatchHandler, config config.IConfig) *OperatorCommandsHandler

func (*OperatorCommandsHandler) Start added in v0.2.63

func (ch *OperatorCommandsHandler) Start()

type RegistryCommandsHandler added in v0.2.40

type RegistryCommandsHandler struct {
	// contains filtered or unexported fields
}

func NewRegistryCommandsHandler added in v0.2.40

func NewRegistryCommandsHandler(ctx context.Context, k8sAPI *k8sinterface.KubernetesApi, commandsWatcher *CommandWatchHandler, config config.IConfig) *RegistryCommandsHandler

func (*RegistryCommandsHandler) Start added in v0.2.40

func (ch *RegistryCommandsHandler) Start()

type SBOMObserver added in v0.2.220

type SBOMObserver interface {
	ObservePod(eventType watch.EventType, pod *corev1.Pod)
	ObserveSBOM(eventType watch.EventType, sbom *spdxv1beta1.SBOMSyft)
}

SBOMObserver is told about the pod and SBOM events SBOMWatch receives, such as the SBOM exporter.

type SecurityExceptionWatchHandler added in v0.2.158

type SecurityExceptionWatchHandler struct {
	// contains filtered or unexported fields
}

SecurityExceptionWatchHandler watches SecurityException and ClusterSecurityException CRDs and dispatches enabled cluster scans whenever an exception is created, changed, removed, or expires — so results reflect the current set of exceptions without waiting for the next scheduled scan.

func NewSecurityExceptionWatchHandler added in v0.2.158

func NewSecurityExceptionWatchHandler(cfg config.IConfig, dynamicClient dynamic.Interface, workerPool *ants.PoolWithFunc) *SecurityExceptionWatchHandler

NewSecurityExceptionWatchHandler returns a handler that dispatches rescans onto the given worker pool.

func (*SecurityExceptionWatchHandler) SecurityExceptionWatch added in v0.2.158

func (wh *SecurityExceptionWatchHandler) SecurityExceptionWatch(ctx context.Context)

SecurityExceptionWatch starts the informers, the expiry sweep and the rescan dispatcher. It blocks until ctx is cancelled.

type WatchHandler

type WatchHandler struct {
	ImageToContainerData maps.SafeMap[string, utils.ContainerData] // map of <hash> : <container data>
	SlugToImageID        maps.SafeMap[string, string]              // map of <Slug> : string <image ID>
	WlidAndImageID       mapset.Set[string]                        // set of <wlid+imageID>
	// contains filtered or unexported fields
}

func NewWatchHandler

func NewWatchHandler(cfg config.IConfig, k8sAPI *k8sinterface.KubernetesApi, storageClient kssc.Interface, eventQueue *CooldownQueue) *WatchHandler

NewWatchHandler creates a new WatchHandler, initializes the maps and returns it

func (*WatchHandler) ContainerProfileWatch added in v0.2.109

func (wh *WatchHandler) ContainerProfileWatch(ctx context.Context, workerPool *ants.PoolWithFunc)

ContainerProfileWatch watches and processes changes on ContainerProfile resources

func (*WatchHandler) DisableImageScans added in v0.2.220

func (wh *WatchHandler) DisableImageScans()

DisableImageScans stops SBOMWatch from sending scan commands, for when it runs only for an SBOMObserver.

func (*WatchHandler) HandleContainerProfileEvents added in v0.2.109

func (wh *WatchHandler) HandleContainerProfileEvents(eventQueue *CooldownQueue, producedCommands chan<- *apis.Command, errorCh chan<- error)

func (*WatchHandler) HandleSBOMEvents

func (wh *WatchHandler) HandleSBOMEvents(eventQueue *CooldownQueue, producedCommands chan<- *apis.Command, errorCh chan<- error)

HandleSBOMEvents passes SBOMSyft events to the SBOM observer, if any, and, unless image scans are disabled, turns them into vulnerability scan commands.

func (*WatchHandler) PodWatch

func (wh *WatchHandler) PodWatch(ctx context.Context, workerPool *ants.PoolWithFunc)

func (*WatchHandler) SBOMWatch

func (wh *WatchHandler) SBOMWatch(ctx context.Context, workerPool *ants.PoolWithFunc)

SBOMWatch watches and processes changes on SBOMs

func (*WatchHandler) SetSBOMObserver added in v0.2.220

func (wh *WatchHandler) SetSBOMObserver(o SBOMObserver)

SetSBOMObserver makes SBOMWatch pass its pod and SBOM events to o.

Jump to

Keyboard shortcuts

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