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

managedfields

package
v1.44.0 Latest Latest
Warning

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

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

Documentation

Overview

Package managedfields owns a declared set of fields on Calico resources that users also modify, through server-side apply.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Apply

func Apply[U any, T object[U]](ctx context.Context, m *FieldManager, declare DeclareFn[T]) (T, error)

Apply writes the fields the declaration asks for on the governed resource, and returns the whole resulting object.

func IsFieldConflict

func IsFieldConflict(err error) bool

IsFieldConflict reports whether err is another writer owning a field the operator declares. A caller reports those and carries on, rather than failing on them.

func JoinFieldConflicts

func JoinFieldConflicts(conflicts []error) error

JoinFieldConflicts folds the conflicts a caller stepped over into one error, dropping the repeats that come from declaring the same field at more than one write site.

Types

type ConflictPolicy

type ConflictPolicy string

ConflictPolicy resolves a field that both the operator and someone else set.

const (
	// ConflictError reports the conflict to the caller, which should degrade.
	ConflictError ConflictPolicy = "Error"

	// ConflictDefer leaves the other writer's value in place.
	ConflictDefer ConflictPolicy = "Defer"

	// ConflictOverride takes the field back and writes the operator's value.
	ConflictOverride ConflictPolicy = "Override"
)

type ConflictingFieldsError

type ConflictingFieldsError struct {
	Kind  string
	Paths []string
}

ConflictingFieldsError reports fields the operator declares that someone else owns.

func (*ConflictingFieldsError) Error

func (e *ConflictingFieldsError) Error() string

type Declaration

type Declaration[T client.Object] struct {
	// Manager is the field manager name, and has to stay the same across reconciles.
	Manager string

	// Owned carries the declared fields and nothing else. Fields left nil are not owned.
	Owned T

	// Policies is keyed by field path, e.g. "spec.healthPort". Every declared field needs an entry.
	Policies map[string]ConflictPolicy
}

Declaration is one field manager's statement of what it owns on a resource.

type DeclareFn

type DeclareFn[T client.Object] func(current T) (*Declaration[T], error)

DeclareFn states which fields the caller owns, given the current object.

type FieldManager

type FieldManager struct {
	// contains filtered or unexported fields
}

FieldManager owns a declared set of fields on shared Calico configuration resources.

func New

func New(c client.Client) *FieldManager

New returns a FieldManager that writes through the API group the client is configured for.

Jump to

Keyboard shortcuts

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