events

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2021 License: Apache-2.0 Imports: 8 Imported by: 32

Documentation

Index

Constants

View Source
const (
	// Information only and will not cause any problems.
	EventSeverityInfo string = "info"
	// These events are to warn that something might go wrong.
	EventSeverityError string = "error"
)

Valid values for event severity.

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 (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
	// +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.

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 code.

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 an HTTP POST to the webhook address.

Jump to

Keyboard shortcuts

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