Documentation
¶
Overview ¶
Package ssa provides helpers for Server-Side Apply (SSA) workflows, including TypeConverter initialisation, diff-before-apply, and structured-merge-diff-based object merging.
Index ¶
- Constants
- func ApplyIfChanged(ctx context.Context, logger logr.Logger, cl client.Client, ...) (op.Result, error)
- func ApplyStatusIfChanged(ctx context.Context, logger logr.Logger, cl client.Client, ...) (op.Result, error)
- func MergeObjects(tc managedfields.TypeConverter, base, userOverlay runtime.Object) (*unstructured.Unstructured, error)
- func NewTypeConverter(mgr ctrl.Manager, groupVersions []schema.GroupVersion) (managedfields.TypeConverter, error)
Constants ¶
const FieldManager = "gateway-operator"
FieldManager is the field manager name used by the operator for Server-Side Apply operations.
Variables ¶
This section is empty.
Functions ¶
func ApplyIfChanged ¶
func ApplyIfChanged( ctx context.Context, logger logr.Logger, cl client.Client, tc managedfields.TypeConverter, desired client.Object, fieldManager string, ) (op.Result, error)
ApplyIfChanged performs a diff-before-apply using structured-merge-diff:
- Fetch the existing object from the API server.
- Convert both existing and desired to typed.TypedValue via TypeConverter.
- Compare using TypedValue.Compare().
- Issue a Server-Side Apply only when a difference is detected.
This prevents infinite reconcile loops on API server versions that incorrectly bump resourceVersion on no-op SSA patches.
func ApplyStatusIfChanged ¶
func ApplyStatusIfChanged( ctx context.Context, logger logr.Logger, cl client.Client, tc managedfields.TypeConverter, desired client.Object, fieldManager string, ) (op.Result, error)
ApplyStatusIfChanged is like ApplyIfChanged but operates on the status subresource. It compares fields owned by fieldManager under the "status" subresource via SMD and issues a Status().Apply only when a difference is detected, preventing spurious status patches on every reconcile.
func MergeObjects ¶
func MergeObjects(tc managedfields.TypeConverter, base, userOverlay runtime.Object) (*unstructured.Unstructured, error)
MergeObjects merges userOverlay into base using structured-merge-diff. User-provided values in userOverlay win on conflicts; the base supplies default values for fields the user has not specified. Returns an *unstructured.Unstructured so the caller can use the result directly with ApplyIfChanged or convert it to a typed struct.
func NewTypeConverter ¶
func NewTypeConverter(mgr ctrl.Manager, groupVersions []schema.GroupVersion) (managedfields.TypeConverter, error)
NewTypeConverter builds a TypeConverter from the API server's live OpenAPI v3 schemas. Only schemas for the specified GroupVersions are fetched, reducing startup latency compared to downloading the full schema set.
groupVersions should list every GV whose objects will be passed to MergeObjects or ApplyIfChanged. For core types use schema.GroupVersion{Group: "", Version: "v1"}. Call this once during SetupWithManager.
Types ¶
This section is empty.