Version: v0.0.0-...-405c343 Latest Latest

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

Go to latest
Published: Sep 27, 2023 License: Apache-2.0 Imports: 16 Imported by: 522




This section is empty.


This section is empty.


func GetControllerReferenceForCurrentPod

func GetControllerReferenceForCurrentPod(ctx context.Context, client kubernetes.Interface, targetNamespace string, reference *corev1.ObjectReference) (*corev1.ObjectReference, error)

GetControllerReferenceForCurrentPod provides an object reference to a controller managing the pod/container where this process runs. The pod name must be provided via the POD_NAME name. Even if this method returns an error, it always return valid reference to the namespace. It allows the callers to control the logging and decide to fail or accept the namespace.

func RecommendedClusterSingletonCorrelatorOptions

func RecommendedClusterSingletonCorrelatorOptions() record.CorrelatorOptions

RecommendedClusterSingletonCorrelatorOptions provides recommended event correlator options for components that produce many events (like operators).


type InMemoryRecorder

type InMemoryRecorder interface {
	Events() []*corev1.Event

func NewInMemoryRecorder

func NewInMemoryRecorder(sourceComponent string) InMemoryRecorder

NewInMemoryRecorder provides event recorder that stores all events recorded in memory and allow to replay them using the Events() method. This recorder should be only used in unit tests.

type LoggingEventRecorder

type LoggingEventRecorder struct {
	// contains filtered or unexported fields

func (*LoggingEventRecorder) ComponentName

func (r *LoggingEventRecorder) ComponentName() string

func (*LoggingEventRecorder) Event

func (r *LoggingEventRecorder) Event(reason, message string)

func (*LoggingEventRecorder) Eventf

func (r *LoggingEventRecorder) Eventf(reason, messageFmt string, args ...interface{})

func (*LoggingEventRecorder) ForComponent

func (r *LoggingEventRecorder) ForComponent(component string) Recorder

func (*LoggingEventRecorder) Shutdown

func (r *LoggingEventRecorder) Shutdown()

func (*LoggingEventRecorder) Warning

func (r *LoggingEventRecorder) Warning(reason, message string)

func (*LoggingEventRecorder) Warningf

func (r *LoggingEventRecorder) Warningf(reason, messageFmt string, args ...interface{})

func (*LoggingEventRecorder) WithComponentSuffix

func (r *LoggingEventRecorder) WithComponentSuffix(suffix string) Recorder

func (*LoggingEventRecorder) WithContext

func (r *LoggingEventRecorder) WithContext(ctx context.Context) Recorder

type Recorder

type Recorder interface {
	Event(reason, message string)
	Eventf(reason, messageFmt string, args ...interface{})
	Warning(reason, message string)
	Warningf(reason, messageFmt string, args ...interface{})

	// ForComponent allows to fiddle the component name before sending the event to sink.
	// Making more unique components will prevent the spam filter in upstream event sink from dropping
	// events.
	ForComponent(componentName string) Recorder

	// WithComponentSuffix is similar to ForComponent except it just suffix the current component name instead of overriding.
	WithComponentSuffix(componentNameSuffix string) Recorder

	// WithContext allows to set a context for event create API calls.
	WithContext(ctx context.Context) Recorder

	// ComponentName returns the current source component name for the event.
	// This allows to suffix the original component name with 'sub-component'.
	ComponentName() string


Recorder is a simple event recording interface.

func NewKubeRecorder

func NewKubeRecorder(client corev1client.EventInterface, sourceComponentName string, involvedObjectRef *corev1.ObjectReference) Recorder

NewKubeRecorder returns new event recorder with default correlator options.

func NewKubeRecorderWithOptions

func NewKubeRecorderWithOptions(client corev1client.EventInterface, options record.CorrelatorOptions, sourceComponentName string, involvedObjectRef *corev1.ObjectReference) Recorder

NewKubeRecorder returns new event recorder with tweaked correlator options.

func NewLoggingEventRecorder

func NewLoggingEventRecorder(component string) Recorder

NewLoggingEventRecorder provides event recorder that will log all recorded events via klog.

func NewRecorder

func NewRecorder(client corev1client.EventInterface, sourceComponentName string, involvedObjectRef *corev1.ObjectReference) Recorder

NewRecorder returns new event recorder.


Path Synopsis

Jump to

Keyboard shortcuts

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