util

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: Apache-2.0 Imports: 13 Imported by: 26

Documentation

Overview

Package util contains utility functions used by other packages

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContainsBy added in v0.4.0

func ContainsBy[T any](collection []T, predicate func(item T) bool) bool

func ConvertStringSlice added in v0.4.0

func ConvertStringSlice[T1 ~string, T2 ~string](collection []T1) []T2

func GetItems

func GetItems(list client.ObjectList) []client.Object

this is an ugly function to retrieve the list of Items from a client.ObjectList because the interface doesn't have a GetItems method

func Hash

func Hash(o interface{}) string

Hash returns a hash of the passed object

func IgnoreProperty added in v0.4.0

func IgnoreProperty(p string) cmp.Option

func IsBeingDeleted

func IsBeingDeleted(o client.Object) bool

func MergeMaps

func MergeMaps(base map[string]string, merges ...map[string]string) map[string]string

MergeMaps merges a list maps into the first one. B overrides A if keys collide.

func NewObjectFromGVK added in v0.4.0

func NewObjectFromGVK(gvk schema.GroupVersionKind, s *runtime.Scheme) (client.Object, error)

func NewObjectListFromGVK added in v0.4.0

func NewObjectListFromGVK(gvk schema.GroupVersionKind, s *runtime.Scheme) (client.ObjectList, error)

func ObjectKey

func ObjectKey(o client.Object) types.NamespacedName

func ObjectReference added in v0.4.0

func ObjectReference(o client.Object, gvk schema.GroupVersionKind) *corev1.ObjectReference

func Pointer added in v0.4.0

func Pointer[T any](t T) *T

Returns a pointer of any type

func ResourceDefaulter added in v0.4.0

func ResourceDefaulter(o Defaulter) func(context.Context, client.Client, client.Object) error

func SetTypeMeta added in v0.5.1

func SetTypeMeta(o client.Object, gvk schema.GroupVersionKind) client.Object

Types

type Defaulter added in v0.4.0

type Defaulter interface {
	client.Object
	Default()
}

Defaulter defines functions for setting defaults on resources.

Jump to

Keyboard shortcuts

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