structuredreporting

package
v1.151.0 Latest Latest
Warning

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

Go to latest
Published: May 12, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContextWithListener

func ContextWithListener(ctx context.Context, listener Listener) context.Context

func FormatAny added in v1.150.0

func FormatAny(obj any) string

FormatAny is a utility function that will render a string representation of a protobuf message, or any other object.

func ReportDiff

func ReportDiff(ctx context.Context, diff *Diff)

ReportDiff should be called by a controller when it detects diffs

func ReportError

func ReportError(ctx context.Context, err error, args ...any)

func ReportReconcileEnd added in v1.134.0

func ReportReconcileEnd(ctx context.Context, u *unstructured.Unstructured, result reconcile.Result, err error, t k8s.ReconcilerType)

func ReportReconcileStart

func ReportReconcileStart(ctx context.Context, u *unstructured.Unstructured, t k8s.ReconcilerType)

Types

type DebugLogListener added in v1.141.0

type DebugLogListener struct {
}

DebugLogListener is a Listener that logs structured reporting events

func (*DebugLogListener) OnDiff added in v1.141.0

func (l *DebugLogListener) OnDiff(ctx context.Context, diffs *Diff)

OnDiff is called when a controller calls ReportDiffs

func (*DebugLogListener) OnError added in v1.141.0

func (l *DebugLogListener) OnError(ctx context.Context, err error, args ...any)

OnError is called when a controller calls ReportError

func (*DebugLogListener) OnReconcileEnd added in v1.141.0

func (l *DebugLogListener) OnReconcileEnd(ctx context.Context, u *unstructured.Unstructured, result reconcile.Result, err error, t k8s.ReconcilerType)

OnReconcileEnd is called when a controller calls ReportReconcileEnd

func (*DebugLogListener) OnReconcileStart added in v1.141.0

OnReconcileStart is called when a controller calls ReportReconcileStart

type Diff

type Diff struct {
	Object *unstructured.Unstructured

	// Fields contains field-level diffs
	// Likely empty if NewObject is true
	Fields []DiffField

	// IsNewObject is true if the object does not exist in GCP
	IsNewObject bool
}

Diff allows reporting of a detected difference

func (*Diff) AddDiff added in v1.137.0

func (d *Diff) AddDiff(other *Diff) *Diff

func (*Diff) AddField added in v1.132.1

func (d *Diff) AddField(id string, old any, new any)

AddField adds the data for a changed field

func (*Diff) AddProtoField added in v1.150.0

func (d *Diff) AddProtoField(id string, fd protoreflect.FieldDescriptor, old any, new any)

AddProtoField adds the data for a changed field where we know the proto field descriptor.

func (*Diff) FieldIDs added in v1.141.0

func (d *Diff) FieldIDs() []string

FieldIDs returns the sorted list of field IDs that differ in this Diff

func (*Diff) HasDiff added in v1.137.0

func (d *Diff) HasDiff() bool

HasDiff returns true if the diff has any fields that differ.

type DiffField

type DiffField struct {
	// ID is the identity of the field.  Note that this might be the proto or terraform name.
	ID string

	// ProtoFieldDescriptor is the proto fieldDescriptor of the field, if known.
	ProtoFieldDescriptor protoreflect.FieldDescriptor

	Old any
	New any
}

type Listener

type Listener interface {
	// OnError is called when a controller calls ReportError
	OnError(ctx context.Context, err error, args ...any)
	// OnDiff is called when a controller calls ReportDiffs
	OnDiff(ctx context.Context, diffs *Diff)
	// OnReconcileStart is called when a controller calls ReportReconcileStart
	OnReconcileStart(ctx context.Context, u *unstructured.Unstructured, t k8s.ReconcilerType)
	// OnReconcileEnd is called when a controller calls ReportReconcileEnd
	OnReconcileEnd(ctx context.Context, u *unstructured.Unstructured, result reconcile.Result, err error, t k8s.ReconcilerType)
}

Listener is implemented by listeners to the "structured reporting" event stream. Note: these methods are called from performance-sensitive code. If you are doing substantial processing (in production paths), consider copying the arguments and sending them to another goroutine for any heavy lifting.

func GetListenerFromContext

func GetListenerFromContext(ctx context.Context) (Listener, bool)

type LogFieldUpdates added in v1.141.0

type LogFieldUpdates struct {
}

LogFieldUpdates is a Listener that logs updated fields during reconciliation, only when objects are being updated.

func (*LogFieldUpdates) OnDiff added in v1.141.0

func (l *LogFieldUpdates) OnDiff(ctx context.Context, diffs *Diff)

OnDiff is called when a controller calls ReportDiffs

func (*LogFieldUpdates) OnError added in v1.141.0

func (l *LogFieldUpdates) OnError(ctx context.Context, err error, args ...any)

OnError is called when a controller calls ReportError

func (*LogFieldUpdates) OnReconcileEnd added in v1.141.0

func (l *LogFieldUpdates) OnReconcileEnd(ctx context.Context, u *unstructured.Unstructured, result reconcile.Result, err error, t k8s.ReconcilerType)

OnReconcileEnd is called when a controller calls ReportReconcileEnd

func (*LogFieldUpdates) OnReconcileStart added in v1.141.0

func (l *LogFieldUpdates) OnReconcileStart(ctx context.Context, u *unstructured.Unstructured, t k8s.ReconcilerType)

OnReconcileStart is called when a controller calls ReportReconcileStart

Jump to

Keyboard shortcuts

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