internal

package
v0.30.3 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Field indicates that the content of this path element is a field's name
	Field = "f"

	// Value indicates that the content of this path element is a field's value
	Value = "v"

	// Index indicates that the content of this path element is an index in an array
	Index = "i"

	// Key indicates that the content of this path element is a key value map
	Key = "k"

	// Separator separates the type of a path element from the contents
	Separator = ":"
)
View Source
const DefaultMaxUpdateManagers int = 10

DefaultMaxUpdateManagers defines the default maximum retained number of managedFields entries from updates if the number of update managers exceeds this, the oldest entries will be merged until the number is below the maximum. TODO(jennybuckley): Determine if this is really the best value. Ideally we wouldn't unnecessarily merge too many entries.

View Source
const DefaultTrackOnCreateProbability float32 = 1

DefaultTrackOnCreateProbability defines the default probability that the field management of an object starts being tracked from the object's creation, instead of from the first time the object is applied to.

View Source
const LastAppliedConfigAnnotation = "kubectl.kubernetes.io/last-applied-configuration"

LastAppliedConfigAnnotation is the annotation used to store the previous configuration of a resource for use in a three way diff by UpdateApplyAnnotation.

This is a copy of the corev1 annotation since we don't want to depend on the whole package.

Variables

View Source
var EmptyFields = func() metav1.FieldsV1 {
	f, err := SetToFields(*fieldpath.NewSet())
	if err != nil {
		panic("should never happen")
	}
	return f
}()

EmptyFields represents a set with no paths It looks like metav1.Fields{Raw: []byte("{}")}

Functions

func BuildManagerIdentifier

func BuildManagerIdentifier(encodedManager *metav1.ManagedFieldsEntry) (manager string, err error)

BuildManagerIdentifier creates a manager identifier string from a ManagedFieldsEntry

func EncodeObjectManagedFields

func EncodeObjectManagedFields(obj runtime.Object, managed ManagedInterface) error

EncodeObjectManagedFields converts and stores the fieldpathManagedFields into the objects ManagedFields

func FieldsToSet

func FieldsToSet(f metav1.FieldsV1) (s fieldpath.Set, err error)

FieldsToSet creates a set paths from an input trie of fields

func NewConflictError

func NewConflictError(conflicts merge.Conflicts) *errors.StatusError

NewConflictError returns an error including details on the requests apply conflicts

func NewNoCorrespondingTypeError

func NewNoCorrespondingTypeError(gvk schema.GroupVersionKind) error

func NewPathElement

func NewPathElement(s string) (fieldpath.PathElement, error)

NewPathElement parses a serialized path element

func PathElementString

func PathElementString(pe fieldpath.PathElement) (string, error)

PathElementString serializes a path element

func RemoveObjectManagedFields

func RemoveObjectManagedFields(obj runtime.Object)

RemoveObjectManagedFields removes the ManagedFields from the object before we merge so that it doesn't appear in the ManagedFields recursively.

func SetLastApplied

func SetLastApplied(obj runtime.Object, value string) error

SetLastApplied sets the last-applied annotation the given value in the object.

func SetToFields

func SetToFields(s fieldpath.Set) (f metav1.FieldsV1, err error)

SetToFields creates a trie of fields from an input set of paths

Types

type AtMostEvery

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

AtMostEvery will never run the method more than once every specified duration.

func NewAtMostEvery

func NewAtMostEvery(delay time.Duration) *AtMostEvery

NewAtMostEvery creates a new AtMostEvery, that will run the method at most every given duration.

func (*AtMostEvery) Do

func (s *AtMostEvery) Do(fn func()) bool

Do will run the method if enough time has passed, and return true. Otherwise, it does nothing and returns false.

type FieldManager

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

FieldManager updates the managed fields and merges applied configurations.

func NewDefaultFieldManager

func NewDefaultFieldManager(f Manager, typeConverter TypeConverter, objectConverter runtime.ObjectConvertor, objectCreater runtime.ObjectCreater, kind schema.GroupVersionKind, subresource string) *FieldManager

newDefaultFieldManager is a helper function which wraps a Manager with certain default logic.

func NewFieldManager

func NewFieldManager(f Manager, subresource string) *FieldManager

NewFieldManager creates a new FieldManager that decodes, manages, then re-encodes managedFields on update and apply requests.

func (*FieldManager) Apply

func (f *FieldManager) Apply(liveObj, appliedObj runtime.Object, manager string, force bool) (object runtime.Object, err error)

Apply is used when server-side apply is called, as it merges the object and updates the managed fields.

func (*FieldManager) Update

func (f *FieldManager) Update(liveObj, newObj runtime.Object, manager string) (object runtime.Object, err error)

Update is used when the object has already been merged (non-apply use-case), and simply updates the managed fields in the output object.

func (*FieldManager) UpdateNoErrors

func (f *FieldManager) UpdateNoErrors(liveObj, newObj runtime.Object, manager string) runtime.Object

UpdateNoErrors is the same as Update, but it will not return errors. If an error happens, the object is returned with managedFields cleared.

type Managed

type Managed interface {
	// Fields gets the fieldpath.ManagedFields.
	Fields() fieldpath.ManagedFields

	// Times gets the timestamps associated with each operation.
	Times() map[string]*metav1.Time
}

Managed groups a fieldpath.ManagedFields together with the timestamps associated with each operation.

type ManagedInterface

type ManagedInterface interface {
	// Fields gets the fieldpath.ManagedFields.
	Fields() fieldpath.ManagedFields

	// Times gets the timestamps associated with each operation.
	Times() map[string]*metav1.Time
}

ManagedInterface groups a fieldpath.ManagedFields together with the timestamps associated with each operation.

func DecodeManagedFields

func DecodeManagedFields(encodedManagedFields []metav1.ManagedFieldsEntry) (ManagedInterface, error)

DecodeManagedFields converts ManagedFields from the wire format (api format) to the format used by sigs.k8s.io/structured-merge-diff

func NewEmptyManaged

func NewEmptyManaged() ManagedInterface

NewEmptyManaged creates an empty ManagedInterface.

func NewManaged

NewManaged creates a ManagedInterface from a fieldpath.ManagedFields and the timestamps associated with each operation.

type Manager

type Manager interface {
	// Update is used when the object has already been merged (non-apply
	// use-case), and simply updates the managed fields in the output
	// object.
	//  * `liveObj` is not mutated by this function
	//  * `newObj` may be mutated by this function
	// Returns the new object with managedFields removed, and the object's new
	// proposed managedFields separately.
	Update(liveObj, newObj runtime.Object, managed Managed, manager string) (runtime.Object, Managed, error)

	// Apply is used when server-side apply is called, as it merges the
	// object and updates the managed fields.
	//  * `liveObj` is not mutated by this function
	//  * `newObj` may be mutated by this function
	// Returns the new object with managedFields removed, and the object's new
	// proposed managedFields separately.
	Apply(liveObj, appliedObj runtime.Object, managed Managed, fieldManager string, force bool) (runtime.Object, Managed, error)
}

Manager updates the managed fields and merges applied configurations.

func NewBuildManagerInfoManager

func NewBuildManagerInfoManager(f Manager, gv schema.GroupVersion, subresource string) Manager

NewBuildManagerInfoManager creates a new Manager that converts the manager name into a unique identifier combining operation and version for update requests, and just operation for apply requests.

func NewCRDStructuredMergeManager

func NewCRDStructuredMergeManager(typeConverter TypeConverter, objectConverter runtime.ObjectConvertor, objectDefaulter runtime.ObjectDefaulter, gv schema.GroupVersion, hub schema.GroupVersion, resetFields map[fieldpath.APIVersion]*fieldpath.Set) (_ Manager, err error)

NewCRDStructuredMergeManager creates a new Manager specifically for CRDs. This allows for the possibility of fields which are not defined in models, as well as having no models defined at all.

func NewCapManagersManager

func NewCapManagersManager(fieldManager Manager, maxUpdateManagers int) Manager

NewCapManagersManager creates a new wrapped FieldManager which ensures that the number of managers from updates does not exceed maxUpdateManagers, by merging some of the oldest entries on each update.

func NewLastAppliedManager

func NewLastAppliedManager(fieldManager Manager, typeConverter TypeConverter, objectConverter runtime.ObjectConvertor, groupVersion schema.GroupVersion) Manager

NewLastAppliedManager converts the client-side apply annotation to server-side apply managed fields

func NewLastAppliedUpdater

func NewLastAppliedUpdater(fieldManager Manager) Manager

NewLastAppliedUpdater sets the client-side apply annotation up to date with server-side apply managed fields

func NewManagedFieldsUpdater

func NewManagedFieldsUpdater(fieldManager Manager) Manager

NewManagedFieldsUpdater is responsible for updating the managedfields in the object, updating the time of the operation as necessary. For updates, it uses a hard-coded manager to detect if things have changed, and swaps back the correct manager after the operation is done.

func NewProbabilisticSkipNonAppliedManager

func NewProbabilisticSkipNonAppliedManager(fieldManager Manager, objectCreater runtime.ObjectCreater, p float32) Manager

NewProbabilisticSkipNonAppliedManager creates a new wrapped FieldManager that starts tracking managers after the first apply, or starts tracking on create with p probability.

func NewSkipNonAppliedManager

func NewSkipNonAppliedManager(fieldManager Manager, objectCreater runtime.ObjectCreater) Manager

NewSkipNonAppliedManager creates a new wrapped FieldManager that only starts tracking managers after the first apply.

func NewStripMetaManager

func NewStripMetaManager(fieldManager Manager) Manager

NewStripMetaManager creates a new Manager that strips metadata and typemeta fields from the manager's fieldset.

func NewStructuredMergeManager

func NewStructuredMergeManager(typeConverter TypeConverter, objectConverter runtime.ObjectConvertor, objectDefaulter runtime.ObjectDefaulter, gv schema.GroupVersion, hub schema.GroupVersion, resetFields map[fieldpath.APIVersion]*fieldpath.Set) (Manager, error)

NewStructuredMergeManager creates a new Manager that merges apply requests and update managed fields for other types of requests.

func NewVersionCheckManager added in v0.28.0

func NewVersionCheckManager(fieldManager Manager, gvk schema.GroupVersionKind) Manager

NewVersionCheckManager creates a manager that makes sure that the applied object is in the proper version.

type TypeConverter

type TypeConverter interface {
	ObjectToTyped(runtime.Object, ...typed.ValidationOptions) (*typed.TypedValue, error)
	TypedToObject(*typed.TypedValue) (runtime.Object, error)
}

TypeConverter allows you to convert from runtime.Object to typed.TypedValue and the other way around.

func NewDeducedTypeConverter

func NewDeducedTypeConverter() TypeConverter

DeducedTypeConverter is a TypeConverter for CRDs that don't have a schema. It does implement the same interface though (and create the same types of objects), so that everything can still work the same. CRDs are merged with all their fields being "atomic" (lists included).

func NewTypeConverter

func NewTypeConverter(openapiSpec map[string]*spec.Schema, preserveUnknownFields bool) (TypeConverter, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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