utils

package
v0.6.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrQueueEmpty = errors.New("queue is empty")

Functions

func AddFinalizer

func AddFinalizer(obj client.Object) bool

AddFinalizer adds a k8syncer finalizer to the object, if it doesn't already have one. Returns true if the finalizers changed.

func GVKToString

func GVKToString(gvk schema.GroupVersionKind, suppressDotSuffix bool) string

GVKToString reverts a GroupVersionKind back to a string in the format <resource>.<version>.<group> If suppressDotSuffix is set to true, the trailing dot will be cut off if the group is empty.

func HasFinalizer

func HasFinalizer(obj client.Object) bool

HasFinalizer returns true if the given object has a k8syncer finalizer.

func ParseSimpleJSONPath

func ParseSimpleJSONPath(path string) []string

ParseSimpleJSONPath splits a string into single fields. '.' is used as separator. To include '.' in a field, escape it with a preceding '\'. To have a field end on '\', escape the final '\' with an additional '\'. Note that escaping happens only for '\' which directly precede a '.'. Examples: a.b.c => a b c a\.b.c => a.b c a\\.b.c => a\ b c a\a.b.c\ => a\a b c\

func Ptr

func Ptr[T any](value T) *T

Ptr returns a pointer to the given object.

func RemoveFinalizer

func RemoveFinalizer(obj client.Object) bool

RemoveFinalizer removes all k8syncer finalizers from the object. Returns true if the finalizers changed.

Types

type BasicQueue

type BasicQueue[T any] struct {
	// contains filtered or unexported fields
}

func (*BasicQueue[T]) Clear

func (q *BasicQueue[T]) Clear()

Clear removes all elements from the queue.

func (*BasicQueue[T]) Peek

func (q *BasicQueue[T]) Peek() (T, error)

Peek returns the first element without removing it. Returns an error if the queue is empty.

func (*BasicQueue[T]) Poll

func (q *BasicQueue[T]) Poll() (T, error)

Poll returns the first element and removes it from the queue. Returns an error if the queue is empty.

func (*BasicQueue[T]) Push

func (q *BasicQueue[T]) Push(elems ...T)

Push adds the given elements to the queue in the given order.

func (*BasicQueue[T]) Size

func (q *BasicQueue[T]) Size() int

Size returns the amount of elements currently in the queue.

type ErrorList

type ErrorList struct {
	Errs []error
}

func NewErrorList

func NewErrorList(errs ...error) *ErrorList

func (*ErrorList) Aggregate

func (el *ErrorList) Aggregate() error

Aggregate aggregates all errors in the ErrorList into a single error. Returns nil if the ErrorList is either nil or empty. If the list contains a single error, that error is returned. Otherwise, a new error is constructed by appending all contained errors' messages.

func (*ErrorList) Append

func (el *ErrorList) Append(errs ...error) *ErrorList

Append appends all given errors to the ErrorList. This modifies the receiver object. nil pointers in the arguments are ignored. Returns the receiver for chaining.

type Queue

type Queue[T any] interface {
	// Size returns the amount of elements currently in the queue.
	Size() int
	// Peek returns the first element without removing it.
	// Returns an error if the queue is empty.
	Peek() (T, error)
	// Poll returns the first element and removes it from the queue.
	// Returns an error if the queue is empty.
	Poll() (T, error)
	// Push adds the given elements to the queue in the given order.
	Push(...T)
	// Clear removes all elements from the queue.
	Clear()
}

func NewQueue

func NewQueue[T any](elems ...T) Queue[T]

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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