recorder

package
v0.23.3 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2026 License: Apache-2.0 Imports: 2 Imported by: 83

Documentation

Overview

Package recorder defines interfaces for working with Kubernetes event recorders.

You can use these to emit Kubernetes events associated with a particular Kubernetes object.

Example (Event)
package main

import (
	corev1 "k8s.io/api/core/v1"
	"k8s.io/apimachinery/pkg/runtime"

	_ "github.com/onsi/ginkgo/v2"
	"sigs.k8s.io/controller-runtime/pkg/recorder"
)

var (
	recorderProvider recorder.Provider
	somePod          *corev1.Pod
)

func main() {
	// recorderProvider is a recorder.Provider
	deprecatedRecorder := recorderProvider.GetEventRecorderFor("my-controller")

	// emit an event with a fixed message
	deprecatedRecorder.Event(somePod, corev1.EventTypeWarning,
		"WrongTrousers", "It's the wrong trousers, Gromit!")
}
Example (Eventf)
package main

import (
	corev1 "k8s.io/api/core/v1"
	"k8s.io/apimachinery/pkg/runtime"

	_ "github.com/onsi/ginkgo/v2"
	"sigs.k8s.io/controller-runtime/pkg/recorder"
)

var (
	recorderProvider  recorder.Provider
	somePod           *corev1.Pod
	someRelatedObject runtime.Object
)

func main() {
	// recorderProvider is a recorder.Provider
	deprecatedRecorder := recorderProvider.GetEventRecorderFor("my-controller")

	// emit an event with a variable message
	mildCheese := "Wensleydale"
	deprecatedRecorder.Eventf(somePod, corev1.EventTypeNormal,
		"DislikesCheese", "Not even %s?", mildCheese)

	recorder := recorderProvider.GetEventRecorder("my-controller")

	// emit an event with a fixed message
	recorder.Eventf(somePod, someRelatedObject, corev1.EventTypeWarning,
		"WrongTrousers", "getting dressed", "It's the wrong trousers, Gromit!")
}

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Provider

type Provider interface {
	// GetEventRecorderFor returns an EventRecorder for the old events API.
	//
	// Deprecated: this uses the old events API and will be removed in a future release. Please use GetEventRecorder instead.
	GetEventRecorderFor(name string) record.EventRecorder
	// GetEventRecorder returns a EventRecorder with given name.
	GetEventRecorder(name string) events.EventRecorder
}

Provider knows how to generate new event recorders with given name.

Jump to

Keyboard shortcuts

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