helpers

package
v1.5.1 Latest Latest
Warning

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

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

Documentation

Overview

Package helpers contains helper functions

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Diff

func Diff(want, got any) string

Diff prints the diff between two structs. It is useful in testing to compare two structs when they are large. In such a case, without Diff it will be difficult to pinpoint the difference between the two structs.

func EqualPointers added in v1.3.0

func EqualPointers[T comparable](p1, p2 *T) bool

EqualPointers returns whether two pointers are equal. Pointers are considered equal if one of the following is true: - They are both nil. - One is nil and the other is empty (e.g. nil string and ""). - They are both non-nil, and their values are the same.

func GetPointer

func GetPointer[T any](v T) *T

GetPointer takes a value of any type and returns a pointer to it.

func MustCastObject added in v1.3.0

func MustCastObject[T client.Object](object client.Object) T

MustCastObject casts the client.Object to the specified type that implements it.

func MustExecuteTemplate added in v1.3.0

func MustExecuteTemplate(templ *template.Template, data interface{}) []byte

MustExecuteTemplate executes the template with the given data.

func PrepareTimeForFakeClient

func PrepareTimeForFakeClient(t metav1.Time) metav1.Time

PrepareTimeForFakeClient processes the time similarly to the fake client from sigs.k8s.io/controller-runtime/pkg/client/fake making it is possible to use it in tests when comparing against values returned by the fake client. It panics if it fails to process the time.

Types

This section is empty.

Jump to

Keyboard shortcuts

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