Documentation
¶
Overview ¶
Package object extends the Kubernetes unstructured object API with enhanced support for Δ-controller view objects and delta operations.
Key components:
- Object: Enhanced Kubernetes unstructured object interface with view support.
- Delta: Represents changes to objects (Added, Updated, Deleted, etc.).
- Patch utilities: JSON patch implementation.
- View object constructors: Create view objects with proper GVK.
- Object utilities: Deep copy, comparison, content manipulation.
Example usage:
obj := object.NewViewObject("test", "MyView") object.SetName(obj, "default", "my-instance") object.SetContent(obj, map[string]any{"spec": data}) delta := object.Delta{ Type: object.Added, Object: obj, }
Index ¶
- Constants
- Variables
- func ApplyStrategicMergePatch(original, patch *unstructured.Unstructured) (*unstructured.Unstructured, error)
- func ConvertRuntimeObjectToClientObject(runtimeObj runtime.Object) (client.Object, error)
- func DeepCopyAny(value any) any
- func DeepCopyInto(in, out Object)
- func DeepEqual(a, b Object) bool
- func Dump(obj Object) string
- func GetBaseScheme() *runtime.Scheme
- func GetOperator(obj Object) string
- func MergeAny(a, b any) (any, error)
- func Patch(obj Object, m map[string]any) error
- func SetContent(obj Object, content map[string]any)
- func SetName(obj Object, ns, name string)
- type Delta
- type DeltaType
- type Object
- type ObjectList
Constants ¶
const ( Added = DeltaType(toolscache.Added) Deleted = DeltaType(toolscache.Deleted) Updated = DeltaType(toolscache.Updated) Replaced = DeltaType(toolscache.Replaced) Sync = DeltaType(toolscache.Sync) Upserted = DeltaType("Upserted") // for events that are either an update/replace or an add )
Variables ¶
var NilDelta = Delta{Object: nil}
NilDelta is a placeholder for a delta that means no change.
Functions ¶
func ApplyStrategicMergePatch ¶
func ApplyStrategicMergePatch(original, patch *unstructured.Unstructured) (*unstructured.Unstructured, error)
ApplyStrategicMergePatch is a partial local re-implementation of strategic merge patches.
func ConvertRuntimeObjectToClientObject ¶
ConvertRuntimeObjectToClientObject converts a core runtime objects into a full client.Object.
func DeepCopyInto ¶
func DeepCopyInto(in, out Object)
DeepCopyInto copies an Object into another one.
func GetBaseScheme ¶
GetBaseScheme returns a base scheme. Used mostly for testing.
func GetOperator ¶
GetOperator returns the operator namespace the object belongs to.
func SetContent ¶
SetContent is similar to SetUnstructuredContent but it preserves the GVK, the name and the namespace and deep-copies the content.
Types ¶
type Delta ¶
Delta registers a change (addition, deletion, etc) on an object. By convention, Object is nil if no change occurs.
func (Delta) IsUnchanged ¶
IsUnchanged checks of a delta indicates a change.
type Object ¶
type Object = *unstructured.Unstructured
Object is an alias for a Kubernetes unstructured object used internally as an object representation.
func NewViewObject ¶
NewViewObject initializes an empty object in the given view and sets the GVK.
type ObjectList ¶
type ObjectList = *unstructured.UnstructuredList //nolint:revive
ObjectList is an alias for a Kubernetes unstructured lists.