events

package
v0.13.0-rc.4 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2021 License: Apache-2.0 Imports: 10 Imported by: 32

Documentation

Overview

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

Index

Constants

View Source
const (
	// EventSeverityTrace represents a trace event, usually
	// informing about actions taken during reconciliation.
	EventSeverityTrace string = "trace"
	// EventSeverityInfo represents an informational event, usually
	// informing about changes.
	EventSeverityInfo string = "info"
	// EventSeverityError represent an error event, usually a warning
	// that something goes wrong.
	EventSeverityError string = "error"
)

These constants define valid event severity values.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	// The object that this event is about.
	// +required
	InvolvedObject corev1.ObjectReference `json:"involvedObject"`

	// Severity type of this event (trace, info, error)
	// +kubebuilder:validation:Enum=trace,info;error
	// +required
	Severity string `json:"severity"`

	// The time at which this event was recorded.
	// +required
	Timestamp metav1.Time `json:"timestamp"`

	// A human-readable description of this event.
	// Maximum length 39,000 characters.
	// +kubebuilder:validation:MaxLength=39000
	// +required
	Message string `json:"message"`

	// A machine understandable string that gives the reason
	// for the transition into the object's current status.
	// +required
	Reason string `json:"reason"`

	// Metadata of this event, e.g. apply change set.
	// +optional
	Metadata map[string]string `json:"metadata,omitempty"`

	// Name of the controller that emitted this event, e.g. `source-controller`.
	// +required
	ReportingController string `json:"reportingController"`

	// ID of the controller instance, e.g. `source-controller-xyzf`.
	// +optional
	ReportingInstance string `json:"reportingInstance,omitempty"`
}

Event is a report of an event issued by a controller. +kubebuilder:object:generate=true

func (*Event) DeepCopy added in v0.9.0

func (in *Event) DeepCopy() *Event

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Event.

func (*Event) DeepCopyInto added in v0.9.0

func (in *Event) DeepCopyInto(out *Event)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

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
}

Recorder posts events to the webhook address.

func NewRecorder

func NewRecorder(webhook, reportingController string) (*Recorder, error)

NewRecorder creates an event Recorder with default settings. The recorder performs automatic retries for connection errors and 500-range response codes.

func (*Recorder) EventErrorf

func (r *Recorder) EventErrorf(
	object corev1.ObjectReference,
	metadata map[string]string,
	reason string, messageFmt string, args ...interface{}) error

EventErrorf records an event with error severity.

func (*Recorder) EventInfof

func (r *Recorder) EventInfof(
	object corev1.ObjectReference,
	metadata map[string]string,
	reason string, messageFmt string, args ...interface{}) error

EventInfof records an event with information severity.

func (*Recorder) Eventf

func (r *Recorder) Eventf(
	object corev1.ObjectReference,
	metadata map[string]string,
	severity, reason string,
	messageFmt string, args ...interface{}) error

Eventf constructs an event from the given information and performs a HTTP POST to the webhook address.

Jump to

Keyboard shortcuts

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