controller-runtime: sigs.k8s.io/controller-runtime/pkg/recorder Index | Examples | Files

package recorder

import "sigs.k8s.io/controller-runtime/pkg/recorder"

Package recorder defines interfaces for working with Kubernetes event recorders.

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

Code:

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

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

Code:

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

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

Code:

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

// emit a backdated event (potentially with variable message)
recorder.PastEventf(somePod, metav1.Time{Time: time.Now().Add(-5 * time.Minute)},
    corev1.EventTypeWarning, "ForgottenCrackers",
    "Crackers, Gromit!  We forgot the crackers!")

Index

Examples

Package Files

recorder.go

type Provider Uses

type Provider interface {
    // NewRecorder returns an EventRecorder with given name.
    GetEventRecorderFor(name string) record.EventRecorder
}

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

Package recorder imports 1 packages (graph) and is imported by 13 packages. Updated 2019-02-25. Refresh now. Tools for package owners.