events

package
v0.30.5 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2024 License: Apache-2.0 Imports: 30 Imported by: 181

Documentation

Overview

Package events has all client logic for recording and reporting "k8s.io/api/events/v1".Event events.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetFieldSelector added in v0.22.0

func GetFieldSelector(eventsGroupVersion schema.GroupVersion, regardingGroupVersionKind schema.GroupVersionKind, regardingName string, regardingUID types.UID) (fields.Selector, error)

GetFieldSelector returns the appropriate field selector based on the API version being used to communicate with the server. The returned field selector can be used with List and Watch to filter desired events.

Types

type EventBroadcaster

type EventBroadcaster interface {
	// StartRecordingToSink starts sending events received from the specified eventBroadcaster.
	// Deprecated: use StartRecordingToSinkWithContext instead.
	StartRecordingToSink(stopCh <-chan struct{})

	// StartRecordingToSink starts sending events received from the specified eventBroadcaster.
	StartRecordingToSinkWithContext(ctx context.Context) error

	// NewRecorder returns an EventRecorder that can be used to send events to this EventBroadcaster
	// with the event source set to the given event source.
	NewRecorder(scheme *runtime.Scheme, reportingController string) EventRecorderLogger

	// StartEventWatcher enables you to watch for emitted events without usage
	// of StartRecordingToSink. This lets you also process events in a custom way (e.g. in tests).
	// NOTE: events received on your eventHandler should be copied before being used.
	// TODO: figure out if this can be removed.
	StartEventWatcher(eventHandler func(event runtime.Object)) (func(), error)

	// StartStructuredLogging starts sending events received from this EventBroadcaster to the structured
	// logging function. The return value can be ignored or used to stop recording, if desired.
	// Deprecated: use StartLogging instead.
	StartStructuredLogging(verbosity klog.Level) func()

	// StartLogging starts sending events received from this EventBroadcaster to the structured logger.
	// To adjust verbosity, use the logger's V method (i.e. pass `logger.V(3)` instead of `logger`).
	// The returned function can be ignored or used to stop recording, if desired.
	StartLogging(logger klog.Logger) (func(), error)

	// Shutdown shuts down the broadcaster
	Shutdown()
}

EventBroadcaster knows how to receive events and send them to any EventSink, watcher, or log.

func NewBroadcaster

func NewBroadcaster(sink EventSink) EventBroadcaster

NewBroadcaster Creates a new event broadcaster.

type EventBroadcasterAdapter deprecated added in v0.19.0

type EventBroadcasterAdapter interface {
	// StartRecordingToSink starts sending events received from the specified eventBroadcaster.
	StartRecordingToSink(stopCh <-chan struct{})

	// NewRecorder creates a new Event Recorder with specified name.
	NewRecorder(name string) EventRecorderLogger

	// DeprecatedNewLegacyRecorder creates a legacy Event Recorder with specific name.
	DeprecatedNewLegacyRecorder(name string) record.EventRecorderLogger

	// Shutdown shuts down the broadcaster.
	Shutdown()
}

EventBroadcasterAdapter is a auxiliary interface to simplify migration to the new events API. It is a wrapper around new and legacy broadcasters that smartly chooses which one to use.

Deprecated: This interface will be removed once migration is completed.

func NewEventBroadcasterAdapter added in v0.19.0

func NewEventBroadcasterAdapter(client clientset.Interface) EventBroadcasterAdapter

NewEventBroadcasterAdapter creates a wrapper around new and legacy broadcasters to simplify migration of individual components to the new Event API.

func NewEventBroadcasterAdapterWithContext added in v0.30.0

func NewEventBroadcasterAdapterWithContext(ctx context.Context, client clientset.Interface) EventBroadcasterAdapter

NewEventBroadcasterAdapterWithContext creates a wrapper around new and legacy broadcasters to simplify migration of individual components to the new Event API.

type EventRecorder

type EventRecorder = internalevents.EventRecorder

type EventRecorderLogger added in v0.29.0

type EventRecorderLogger = internalevents.EventRecorderLogger

type EventSink

type EventSink interface {
	Create(ctx context.Context, event *eventsv1.Event) (*eventsv1.Event, error)
	Update(ctx context.Context, event *eventsv1.Event) (*eventsv1.Event, error)
	Patch(ctx context.Context, oldEvent *eventsv1.Event, data []byte) (*eventsv1.Event, error)
}

EventSink knows how to store events (client-go implements it.) EventSink must respect the namespace that will be embedded in 'event'. It is assumed that EventSink will return the same sorts of errors as client-go's REST client.

type EventSinkImpl

type EventSinkImpl struct {
	Interface typedeventsv1.EventsV1Interface
}

EventSinkImpl wraps EventsV1Interface to implement EventSink. TODO: this makes it easier for testing purpose and masks the logic of performing API calls. Note that rollbacking to raw clientset should also be transparent.

func (*EventSinkImpl) Create

func (e *EventSinkImpl) Create(ctx context.Context, event *eventsv1.Event) (*eventsv1.Event, error)

Create takes the representation of a event and creates it. Returns the server's representation of the event, and an error, if there is any.

func (*EventSinkImpl) Patch

func (e *EventSinkImpl) Patch(ctx context.Context, event *eventsv1.Event, data []byte) (*eventsv1.Event, error)

Patch applies the patch and returns the patched event, and an error, if there is any.

func (*EventSinkImpl) Update

func (e *EventSinkImpl) Update(ctx context.Context, event *eventsv1.Event) (*eventsv1.Event, error)

Update takes the representation of a event and updates it. Returns the server's representation of the event, and an error, if there is any.

type FakeRecorder added in v0.16.4

type FakeRecorder struct {
	Events chan string
}

FakeRecorder is used as a fake during tests. It is thread safe. It is usable when created manually and not by NewFakeRecorder, however all events may be thrown away in this case.

func NewFakeRecorder added in v0.16.4

func NewFakeRecorder(bufferSize int) *FakeRecorder

NewFakeRecorder creates new fake event recorder with event channel with buffer of given size.

func (*FakeRecorder) Eventf added in v0.16.4

func (f *FakeRecorder) Eventf(regarding runtime.Object, related runtime.Object, eventtype, reason, action, note string, args ...interface{})

Eventf emits an event

func (*FakeRecorder) WithLogger added in v0.29.0

func (f *FakeRecorder) WithLogger(logger klog.Logger) EventRecorderLogger

Jump to

Keyboard shortcuts

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