helpers

package
v2.7.0 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type K8sObject added in v2.2.0

type K8sObject interface {
	metav1.Object
	runtime.Object
}

K8sObject represents a full Kubernetes object. If a Kubernetes Object is not known or doesn't satisfy both interfaces, it should use `Unstructured` (e.g: pod/exec like `corev1.PodExecOptions`).

type ObjectCreator

type ObjectCreator interface {
	NewObject(raw []byte) (K8sObject, error)
}

ObjectCreator knows how to create objects from Raw JSON or YAML data into specific Kubernetes types that are compatible with runtime.Object and metav1.Object, if not it will fallback to `unstructured.Unstructured`.

func NewDynamicObjectCreator

func NewDynamicObjectCreator() ObjectCreator

NewDynamicObjectCreator returns a object creator that knows how to return objects from raw JSON data without the need of knowing the type.

To be able to infer the types the types need to be registered on the global client Scheme. Normally when a user tries casting the metav1.Object to a specific type, the object is already registered. In case the type is not registered and the object can't be created it will fallback to an `Unstructured` type.

Some types like pod/exec (`corev1.PodExecOptions`) implement `runtime.Object` however they don't implement `metav1.Object`. In that case we also fallback to `Unstructured`.

Useful to make dynamic webhooks that expect multiple or unknown types.

func NewStaticObjectCreator

func NewStaticObjectCreator(obj metav1.Object) ObjectCreator

NewStaticObjectCreator doesn't need to infer the type, it will create a new schema and create a new object with the same type from the received object type.

Jump to

Keyboard shortcuts

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