util

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

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

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

func ConvertStringSlice

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

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

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

func NewObjectListFromGVK

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

func ObjectKey

func ObjectKey(o client.Object) types.NamespacedName

func Pointer

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

Returns a pointer of any type

func ResourceDefaulter

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

Types

type Defaulter

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
JackTT - Gopher 🇻🇳