recorder

package
v0.2.0-alpha.0 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2019 License: Apache-2.0 Imports: 1 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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"

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

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

func main() {
	// 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!")
}
Example (Eventf)
package main

import (
	corev1 "k8s.io/api/core/v1"

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

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

func main() {
	// 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)
}
Example (PastEventf)
package main

import (
	"time"

	corev1 "k8s.io/api/core/v1"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

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

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

func main() {
	// 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

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Provider

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.

Jump to

Keyboard shortcuts

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