events

package
v0.44.1 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2024 License: Apache-2.0 Imports: 18 Imported by: 32

Documentation

Overview

Package events provides a Recorder and additional helpers to record Kubernetes Events on an external HTTP endpoint.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Recorder

type Recorder struct {
	// URL address of the events endpoint.
	Webhook string

	// Name of the controller that emits events.
	ReportingController string

	// Retryable HTTP client.
	Client *retryablehttp.Client

	// EventRecorder is the Kubernetes event recorder.
	EventRecorder kuberecorder.EventRecorder

	// Scheme to look up the recorded objects.
	Scheme *runtime.Scheme

	// Log is the recorder logger.
	Log logr.Logger
}

Recorder posts events to the Kubernetes API and any other event recorder webhook address, like the GitOps Toolkit notification-controller.

Use it by embedding EventRecorder in reconciler struct:

import (
	...
	kuberecorder "k8s.io/client-go/tools/record"
	...
)

type MyTypeReconciler {
 	client.Client
	// ... etc.
	kuberecorder.EventRecorder
}

Use NewRecorder to create a working Recorder.

func NewRecorder

func NewRecorder(mgr ctrl.Manager, log logr.Logger, webhook, reportingController string) (*Recorder, error)

NewRecorder creates an event Recorder with a Kubernetes event recorder and an external event recorder based on the given webhook. The recorder performs automatic retries for connection errors and 500-range response codes from the external recorder.

func (*Recorder) AnnotatedEventf added in v0.13.0

func (r *Recorder) AnnotatedEventf(
	object runtime.Object,
	annotations map[string]string,
	eventtype, reason string,
	messageFmt string, args ...interface{})

AnnotatedEventf constructs an event from the given information and performs a HTTP POST to the webhook address. It also logs the event if debug logs are enabled in the logger.

func (*Recorder) Event added in v0.13.0

func (r *Recorder) Event(object runtime.Object, eventtype, reason, message string)

Event records an event in the webhook address.

func (*Recorder) Eventf

func (r *Recorder) Eventf(object runtime.Object, eventtype, reason, messageFmt string, args ...interface{})

Event records an event in the webhook address.

Jump to

Keyboard shortcuts

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