metautils

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2022 License: Apache-2.0 Imports: 11 Imported by: 15

Documentation

Overview

Package metautils provides utilities to work with objects on the meta layer.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertAndSetList

func ConvertAndSetList(scheme *runtime.Scheme, list runtime.Object, objs []runtime.Object) error

ConvertAndSetList converts the given runtime.Objects into the item type of the list and sets the list items to be the converted items.

func EachListItem added in v0.6.1

func EachListItem(list client.ObjectList, f func(obj client.Object) error) error

EachListItem traverses over all items of the client.ObjectList.

func ExtractList added in v0.3.5

func ExtractList(obj client.ObjectList) ([]client.Object, error)

ExtractList extracts the items of a list into a slice of client.Object.

func ExtractObjectSlice added in v0.3.5

func ExtractObjectSlice(slice interface{}) ([]client.Object, error)

ExtractObjectSlice extracts client.Object from a given slice.

func ExtractObjectSlicePointer added in v0.3.5

func ExtractObjectSlicePointer(slicePtr interface{}) ([]client.Object, error)

ExtractObjectSlicePointer extracts client.Object from a given slice pointer.

func FilterControlledBy added in v0.3.5

func FilterControlledBy(scheme *runtime.Scheme, owner client.Object, objects []client.Object) ([]client.Object, error)

FilterControlledBy filters multiple objects by using IsControlledBy on each item.

func GVKForList

func GVKForList(scheme *runtime.Scheme, list runtime.Object) (schema.GroupVersionKind, error)

GVKForList determines the schema.GroupVersionKind for the given list. Effectively, this strips a 'List' suffix from the kind, if it exists.

func IsControlledBy added in v0.3.3

func IsControlledBy(scheme *runtime.Scheme, owner, controlled client.Object) (bool, error)

IsControlledBy checks if controlled is controlled by owner. An object is considered to be controlled if there is a controller (via metav1.GetControllerOf) whose GVK, name and UID match with the controller object.

func ListElementType

func ListElementType(list runtime.Object) (reflect.Type, error)

ListElementType returns the element type of the list. For instance, for an appsv1.DeploymentList, the element type is appsv1.Deployment.

func MustExtractList added in v0.5.4

func MustExtractList(obj client.ObjectList) []client.Object

MustExtractList extracts the items of a list into a slice of client.Object. It panics if it cannot extract the list.

func MustExtractObjectSlice added in v0.5.4

func MustExtractObjectSlice(slice interface{}) []client.Object

MustExtractObjectSlice extracts client.Object from a given slice. It panics if it cannot extract the objects from the slice.

func MustExtractObjectSlicePointer added in v0.5.4

func MustExtractObjectSlicePointer(slicePtr interface{}) []client.Object

MustExtractObjectSlicePointer extracts client.Object from a given slice pointer. It panics if it cannot extract the objects from the slice pointer.

func MustSetList added in v0.5.4

func MustSetList(list client.ObjectList, objects []client.Object)

MustSetList sets the items in a client.ObjectList to the given objects. It panics if it cannot set the items in the client.ObjectList.

func MustSetObjectSlice added in v0.5.4

func MustSetObjectSlice(slicePtr interface{}, objects []client.Object)

MustSetObjectSlice sets a slice pointer's values to the given objects. It panics if it cannot set the slice pointer values to the given objects.

func NewListForGVK added in v0.6.1

func NewListForGVK(scheme *runtime.Scheme, gvk schema.GroupVersionKind) (client.ObjectList, error)

NewListForGVK creates a new client.ObjectList for the given singular schema.GroupVersionKind.

func NewListForObject added in v0.6.1

func NewListForObject(scheme *runtime.Scheme, obj client.Object) (client.ObjectList, error)

NewListForObject creates a new client.ObjectList for the given singular client.Object.

func SetAnnotation added in v0.6.1

func SetAnnotation(obj metav1.Object, key, value string)

SetAnnotation sets the given annotation on the object.

func SetAnnotations added in v0.6.1

func SetAnnotations(obj metav1.Object, set map[string]string)

SetAnnotations sets the given annotations on the object.

func SetLabel added in v0.6.1

func SetLabel(obj metav1.Object, key, value string)

SetLabel sets the given label on the object.

func SetLabels added in v0.6.1

func SetLabels(obj metav1.Object, set map[string]string)

SetLabels sets the given labels on the object.

func SetList added in v0.3.5

func SetList(list client.ObjectList, objects []client.Object) error

SetList sets the items in a client.ObjectList to the given objects.

func SetObjectSlice added in v0.3.5

func SetObjectSlice(slicePtr interface{}, objects []client.Object) error

SetObjectSlice sets a slice pointer's values to the given objects.

Types

This section is empty.

Jump to

Keyboard shortcuts

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