Documentation
¶
Overview ¶
Package metautils provides utilities to work with objects on the meta layer.
Index ¶
- func ConvertAndSetList(scheme *runtime.Scheme, list runtime.Object, objs []runtime.Object) error
- func DeleteAnnotation(obj ObjectAnnotations, key string)
- func DeleteAnnotations(obj ObjectAnnotations, keys []string)
- func DeleteLabel(obj ObjectLabels, key string)
- func DeleteLabels(obj ObjectLabels, keys []string)
- func EachListItem(list client.ObjectList, f func(obj client.Object) error) error
- func ExtractList(obj client.ObjectList) ([]client.Object, error)
- func ExtractObjectSlice(slice interface{}) ([]client.Object, error)
- func ExtractObjectSlicePointer(slicePtr interface{}) ([]client.Object, error)
- func FilterControlledBy(scheme *runtime.Scheme, owner client.Object, objects []client.Object) ([]client.Object, error)
- func FilterList(list client.ObjectList, f func(obj client.Object) bool) error
- func GVKForList(scheme *runtime.Scheme, list runtime.Object) (schema.GroupVersionKind, error)
- func HasAnnotation(obj ObjectAnnotations, key string) bool
- func HasLabel(obj ObjectLabels, key string) bool
- func IsControlledBy(scheme *runtime.Scheme, owner, controlled client.Object) (bool, error)
- func ListElementType(list runtime.Object) (reflect.Type, error)
- func MustExtractList(obj client.ObjectList) []client.Object
- func MustExtractObjectSlice(slice interface{}) []client.Object
- func MustExtractObjectSlicePointer(slicePtr interface{}) []client.Object
- func MustSetList(list client.ObjectList, objects []client.Object)
- func MustSetObjectSlice(slicePtr interface{}, objects []client.Object)
- func NewListForGVK(scheme *runtime.Scheme, gvk schema.GroupVersionKind) (client.ObjectList, error)
- func NewListForObject(scheme *runtime.Scheme, obj client.Object) (schema.GroupVersionKind, client.ObjectList, error)
- func SetAnnotation(obj ObjectAnnotations, key, value string)
- func SetAnnotations(obj ObjectAnnotations, set map[string]string)
- func SetLabel(obj ObjectLabels, key, value string)
- func SetLabels(obj ObjectLabels, set map[string]string)
- func SetList(list client.ObjectList, objects []client.Object) error
- func SetObjectSlice(slicePtr interface{}, objects []client.Object) error
- type ObjectAnnotations
- type ObjectLabels
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertAndSetList ¶
ConvertAndSetList converts the given runtime.Objects into the item type of the list and sets the list items to be the converted items.
func DeleteAnnotation ¶
func DeleteAnnotation(obj ObjectAnnotations, key string)
DeleteAnnotation deletes the annotation with the given key from the object.
func DeleteAnnotations ¶
func DeleteAnnotations(obj ObjectAnnotations, keys []string)
DeleteAnnotations deletes the annotations with the given keys from the object.
func DeleteLabel ¶
func DeleteLabel(obj ObjectLabels, key string)
DeleteLabel deletes the label with the given key from the object.
func DeleteLabels ¶
func DeleteLabels(obj ObjectLabels, keys []string)
DeleteLabels deletes the labels with the given keys from the object.
func EachListItem ¶
EachListItem traverses over all items of the client.ObjectList.
func ExtractList ¶
func ExtractList(obj client.ObjectList) ([]client.Object, error)
ExtractList extracts the items of a list into a slice of client.Object.
func ExtractObjectSlice ¶
ExtractObjectSlice extracts client.Object from a given slice.
func ExtractObjectSlicePointer ¶
ExtractObjectSlicePointer extracts client.Object from a given slice pointer.
func FilterControlledBy ¶
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 FilterList ¶
FilterList filters the list with the given function, mutating it in-place with the filtered objects.
func GVKForList ¶
GVKForList determines the schema.GroupVersionKind for the given list. Effectively, this strips a 'List' suffix from the kind, if it exists.
func HasAnnotation ¶
func HasAnnotation(obj ObjectAnnotations, key string) bool
HasAnnotation checks if the object has an annotation with the given key.
func HasLabel ¶
func HasLabel(obj ObjectLabels, key string) bool
HasLabel checks if the object has a label with the given key.
func IsControlledBy ¶
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 ¶
ListElementType returns the element type of the list. For instance, for an appsv1.DeploymentList, the element type is appsv1.Deployment.
func MustExtractList ¶
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 ¶
MustExtractObjectSlice extracts client.Object from a given slice. It panics if it cannot extract the objects from the slice.
func MustExtractObjectSlicePointer ¶
MustExtractObjectSlicePointer extracts client.Object from a given slice pointer. It panics if it cannot extract the objects from the slice pointer.
func MustSetList ¶
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 ¶
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 ¶
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 ¶
func NewListForObject(scheme *runtime.Scheme, obj client.Object) (schema.GroupVersionKind, client.ObjectList, error)
NewListForObject creates a new client.ObjectList for the given singular client.Object.
This method disambiguates depending on the type of the given object: * If the given object is *unstructured.Unstructured, an *unstructured.UnstructuredList will be returned. * If the given object is *metav1.PartialObjectMetadata, a *metav1.PartialObjectMetadataList will be returned. * For all other cases, a new object with the corresponding kind will be created using scheme.New().
func SetAnnotation ¶
func SetAnnotation(obj ObjectAnnotations, key, value string)
SetAnnotation sets the given annotation on the object.
func SetAnnotations ¶
func SetAnnotations(obj ObjectAnnotations, set map[string]string)
SetAnnotations sets the given annotations on the object.
func SetLabel ¶
func SetLabel(obj ObjectLabels, key, value string)
SetLabel sets the given label on the object.
func SetLabels ¶
func SetLabels(obj ObjectLabels, set map[string]string)
SetLabels sets the given labels on the object.
func SetList ¶
func SetList(list client.ObjectList, objects []client.Object) error
SetList sets the items in a client.ObjectList to the given objects.
func SetObjectSlice ¶
SetObjectSlice sets a slice pointer's values to the given objects.