Help us shape the future of Go! Take the 2026 Go Developer Survey

ssa

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Overview

Package ssa manages the server-side apply lifecycle of rendered resources.

Index

Constants

View Source
const ConditionNotMet = "ConditionNotMet: apply skipped"

Variables

This section is empty.

Functions

func ReplicationOwnerCandidates

func ReplicationOwnerCandidates(ctx context.Context, indexed client.Reader, prefix string) ([]client.Object, error)

ReplicationOwnerCandidates uses the stable parent identity index. Callers must verify current parent UID, status, and exact field ownership before trusting it.

func ReplicationOwnerPrefixes

func ReplicationOwnerPrefixes(target client.Object, departing string) map[string]struct{}

ReplicationOwnerPrefixes selects legacy replication identities from managed fields. It supplies lookup keys, never proof of ownership.

Types

type ApplyOptions

type ApplyOptions struct {
	Condition string

	FieldOwner        string
	Force             bool
	Adopt             bool
	Protect           bool
	DryRun            bool
	OwnerReference    *metav1.OwnerReference
	PreviouslyCreated bool
}

ApplyOptions configures one server-side apply operation.

type ApplyResult

type ApplyResult struct {
	LastApply *metav1.Time
	Created   bool
	Skipped   bool
	// PolicyReconciled means a skipped target is owned by this field manager
	// and its lifecycle metadata reflects the requested policy.
	PolicyReconciled bool
}

ApplyResult describes the resource after a successful apply.

type Manager

type Manager struct {
	Reader            client.Reader
	Mapper            k8smeta.RESTMapper
	Metadata          Metadata
	Conditions        celruntime.ResourceConditionCompiler
	ReplicationOwners ReplicationOwnerResolver
}

Manager applies and prunes resources with server-side apply.

func (Manager) Apply

Apply creates a resource or acquires ownership of the desired fields on an existing resource. Existing resources must explicitly allow adoption.

func (Manager) Disown

func (m Manager) Disown(
	ctx context.Context,
	c client.Client,
	obj *unstructured.Unstructured,
	fieldOwner string,
	ownerReference *metav1.OwnerReference,
) error

Disown removes metadata which is not part of the caller's SSA field set. This retains rendered fields and requires live ownership of the target. Prune releases this metadata before relinquishing that ownership proof.

func (Manager) Orphan

func (m Manager) Orphan(
	ctx context.Context,
	c client.Client,
	obj *unstructured.Unstructured,
	fieldOwner string,
	ownerReference *metav1.OwnerReference,
) error

Orphan stops lifecycle management without removing the resource or relinquishing the fields applied by the previous manager. Capsule tracking metadata is removed only when no other Capsule resource field owner remains. Protection is removed only when no other owner of this controller remains.

func (Manager) Prune

func (m Manager) Prune(
	ctx context.Context,
	c client.Client,
	obj *unstructured.Unstructured,
	opts PruneOptions,
) (deleted bool, err error)

Prune relinquishes the fields owned by FieldOwner. Resources known to have been created for the manager are deleted; adopted resources retain all fields owned by other managers.

func (Manager) ResolveResourceID

func (m Manager) ResolveResourceID(
	obj *unstructured.Unstructured,
	tenant string,
	origin string,
) (gvk.ResourceID, bool, error)

ResolveResourceID returns the canonical identity and scope of a resource as it will be managed. In particular, a namespace rendered onto a cluster-scoped resource is removed from the returned identity.

type Metadata

type Metadata struct {
	CreatedByValue   string
	ManagedByValue   string
	ProtectedByValue string
	// ProtectionFieldOwnerPrefix scopes a shared protection marker to its controller family.
	// Empty retains conservative ownership checks.
	ProtectionFieldOwnerPrefix          string
	ProtectedByServiceAccount           string
	ProtectedByServiceAccountAnnotation string
	AppManagedByValue                   string
	LegacyCreatedLabel                  string
}

Metadata configures the labels used to track resources managed by a Manager.

type PruneOptions

type PruneOptions struct {
	FieldOwner        string
	PreviouslyCreated bool
	OwnerReference    *metav1.OwnerReference
}

PruneOptions configures one server-side apply prune operation.

type ReplicationOwnerResolver

type ReplicationOwnerResolver func(context.Context, *unstructured.Unstructured, string) (map[string]struct{}, error)

ReplicationOwnerResolver resolves recorded replication managers for a target.

func NewReplicationOwnerResolver

func NewReplicationOwnerResolver(indexed, reader client.Reader) ReplicationOwnerResolver

NewReplicationOwnerResolver indexes parent identities, which are immutable and present in the manager cache before the replication controllers can apply any targets. Unlike a target-status index, this cannot miss a newly recorded item on an existing parent. Read current status directly; cache status is only a candidate source and must not decide whether protection can be removed. Neither reader is the impersonated client used to apply the target.

Jump to

Keyboard shortcuts

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