resource

package
v0.1.35 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2025 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compare added in v0.1.7

func Compare(a, b *unstructured.Unstructured) bool

Compare compares two unstructured resources while ignoring: - Managed field metadata not controlled by Eno - Resource version - Generation - Status

This should only be used to compare canonical apiserver representations of the resource i.e. the unmodified response from gets or patch/update dryruns.

func MergeEnoManagedFields added in v0.1.7

func MergeEnoManagedFields(prev, current, next []metav1.ManagedFieldsEntry) (copy []metav1.ManagedFieldsEntry, fields string, modified bool)

MergeEnoManagedFields corrects managed fields drift to ensure Eno can remove fields that are no longer set by the synthesizer, even when another client corrupts the managed fields metadata. Returns corrected managed fields, affected field paths, and whether correction was needed.

func Slice

func Slice(comp *apiv1.Composition, previous []*apiv1.ResourceSlice, outputs []*unstructured.Unstructured, maxJsonBytes int) ([]*apiv1.ResourceSlice, error)

Slice builds a new set of resource slices by merging a new set of resources onto an old set of slices. - New and updated resources are partitioned across slices per maxJsonBytes - Removed resources are converted into "tombstones" i.e. manifests with Deleted == true

Types

type Cache added in v0.0.48

type Cache struct {
	ResourceFilter cel.Program
	// contains filtered or unexported fields
}

Cache caches resources indexed and logically grouped by the UUID of the synthesis that produced them. Kind of like an informer but optimized for Eno.

func (*Cache) Fill added in v0.0.48

func (c *Cache) Fill(ctx context.Context, comp *apiv1.Composition, synUUID string, items []apiv1.ResourceSlice)

Fill populates the cache with resources from a synthesis. Call Visit first to see if filling the cache is necessary. Get the resource slices from the API - not the informers, which prune out the manifests to save memory.

func (*Cache) Get added in v0.0.48

func (c *Cache) Get(ctx context.Context, synthesisUUID string, ref Ref) (res *Resource, visible, found bool)

func (*Cache) Purge added in v0.0.48

func (c *Cache) Purge(ctx context.Context, compNSN types.NamespacedName, comp *apiv1.Composition)

Purge removes all syntheses from the cache that are not part of the given composition. If comp is nil, all syntheses will be purged.

func (*Cache) SetQueue added in v0.0.48

func (c *Cache) SetQueue(queue workqueue.TypedRateLimitingInterface[Request])

func (*Cache) Visit added in v0.0.48

func (c *Cache) Visit(ctx context.Context, comp *apiv1.Composition, synUUID string, items []apiv1.ResourceSlice) bool

Visit takes a set of resource slices from the informers and updates the resource status in the cache. Return false if the synthesis is not in the cache.

type ManifestRef added in v0.0.7

type ManifestRef struct {
	Slice types.NamespacedName
	Index int // position of this manifest within the slice
}

ManifestRef references a particular resource manifest within a resource slice.

type Ref

type Ref struct {
	Name, Namespace, Group, Kind string
}

Ref refers to a specific synthesized resource.

func (*Ref) String added in v0.0.47

func (r *Ref) String() string

type Request added in v0.0.48

type Request struct {
	Resource    Ref
	Composition types.NamespacedName
}

type Resource

type Resource struct {
	Ref             Ref
	ManifestRef     ManifestRef
	GVK             schema.GroupVersionKind
	ReadinessChecks readiness.Checks
	Labels          map[string]string
	FailOpen        *bool

	// DefinedGroupKind is set on CRDs to represent the resource type they define.
	DefinedGroupKind *schema.GroupKind
	// contains filtered or unexported fields
}

Resource is the controller's internal representation of a single resource out of a ResourceSlice.

func FromSlice added in v0.1.31

func FromSlice(ctx context.Context, comp *apiv1.Composition, slice *apiv1.ResourceSlice, index int) (*Resource, error)

FromSlice constructs a resource out of the given resource slice. Some invalid metadata is tolerated. See FromUnstructured for strict validation.

func FromUnstructured added in v0.1.31

func FromUnstructured(parsed *unstructured.Unstructured) (*Resource, error)

FromUnstructured constructs a new resource with strict validation of any Eno metadata such as annotations.

func (*Resource) Less added in v0.0.47

func (r *Resource) Less(than *Resource) bool

Less returns true when r < than. Used to establish determinstic ordering for conflicting resources.

func (*Resource) Snapshot added in v0.1.22

func (r *Resource) Snapshot(ctx context.Context, comp *apiv1.Composition, actual *unstructured.Unstructured) (*Snapshot, error)

Snapshot evaluates the resource against its current/actual state and returns the resulting "snapshot".

The snapshot should only be used to progress the resource's state from the given resourceVersion. Call this function again to get an updated snapshot with the latest state if applying the current snapshot results in a conflict.

func (*Resource) SnapshotWithOverrides added in v0.1.29

func (r *Resource) SnapshotWithOverrides(ctx context.Context, comp *apiv1.Composition, actual *unstructured.Unstructured, overrideRes *Resource) (*Snapshot, error)

SnapshotWithOverrides is identical to Snapshot but applies the overrides from another resource (presumably a newer version of the same object).

func (*Resource) State added in v0.1.0

func (r *Resource) State() *apiv1.ResourceState

type Snapshot added in v0.1.22

type Snapshot struct {
	*Resource

	ReconcileInterval  *metav1.Duration
	Disable            bool
	DisableUpdates     bool
	Replace            bool
	Orphan             bool
	ForegroundDeletion bool
	// contains filtered or unexported fields
}

Snapshot is a representation of a resource in the context of its current state. Practically speaking this means it's a Resource that has had any overrides applied.

func (*Snapshot) Deleted added in v0.1.22

func (r *Snapshot) Deleted() bool

func (*Snapshot) OverrideStatus added in v0.1.33

func (r *Snapshot) OverrideStatus() string

func (*Snapshot) Patch added in v0.1.25

func (r *Snapshot) Patch() ([]byte, bool, error)

func (*Snapshot) Unstructured added in v0.1.22

func (r *Snapshot) Unstructured() *unstructured.Unstructured

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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