updater

package
v0.0.16 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2024 License: Apache-2.0 Imports: 4 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewStatusUpdater

func NewStatusUpdater[S Status[S]](rsrc resource[S]) *statusUpdater[S]

NewStatusUpdater returns a status updater meant for updating the status of the supplied resource when the updater is closed. Typically users will want to create a status updater early on in a controller's Reconcile() method and add a deferred method to close the updater when returning from reconcile.

i.e.

func (r *myController) Reconcile(ctx context.Context, req ctrl.Request) (res ctrl.Result, err error) {
	rsrc := &MyResource{}
	if err := r.Get(ctx, req.NamespacedName, rsrc); err != nil {
		return err
	}

	updater := NewStatusUpdater[*MyResourceStatus](rsrc)
	defer func() {
		if err == nil {
			err = updater.Close(ctx, r)
		}
	}()

	...

Types

type Status

type Status[T any] interface {
	DeepCopy() T
}

Status provides an interface for copying the status T

Jump to

Keyboard shortcuts

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