utils

package
v0.8.3 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendIfNotExists

func AppendIfNotExists(list []string, item string) []string

AppendIfNotExists adds an item to the provided list if it not exists.

func RemoveIfExists

func RemoveIfExists(list []string, item string) []string

RemoveIfExists removes an item from the provided list if it exists.

func UpdateResource

func UpdateResource(
	ctx context.Context,
	logger logr.Logger,
	c client.Writer,
	object client.Object,
	name string,
) error

UpdateResource tries to update the provided object by using the client.Writer. If the update fails, it automatically logs to the provided logger.

func UpdateResourceStatus added in v0.5.0

func UpdateResourceStatus(
	ctx context.Context,
	logger logr.Logger,
	c client.StatusWriter,
	object client.Object,
	name string,
) error

UpdateResourceStatus tries to update the provided object by using the client.StatusWriter. If the update fails, it automatically logs to the provided logger.

Types

type SafeRecorder added in v0.5.0

type SafeRecorder struct {
	// contains filtered or unexported fields
}

func NewSafeRecorder added in v0.5.0

func NewSafeRecorder(recorder record.EventRecorder) *SafeRecorder

func (*SafeRecorder) AnnotatedEventf added in v0.5.0

func (sr *SafeRecorder) AnnotatedEventf(
	object runtime.Object,
	annotations map[string]string,
	eventtype, reason, messageFmt string,
	args ...interface{},
)

AnnotatedEventf is just like eventf, but with annotations attached.

func (*SafeRecorder) Event added in v0.5.0

func (sr *SafeRecorder) Event(object runtime.Object, eventtype, reason, message string)

func (*SafeRecorder) Eventf added in v0.5.0

func (sr *SafeRecorder) Eventf(object runtime.Object, eventtype, reason, messageFmt string, args ...interface{})

Eventf is just like Event, but with Sprintf for the message field.

Jump to

Keyboard shortcuts

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