// Finds all managed fields owners of the given operation type which owns all of // the fields in the given set // // If there is an error decoding one of the fieldsets for any reason, it is ignored // and assumed not to match the query. func FindFieldsOwners( managedFields []metav1.ManagedFieldsEntry, operation metav1.ManagedFieldsOperationType, fields *fieldpath.Set, ) []metav1.ManagedFieldsEntry { … } // Upgrades the Manager information for fields managed with client-side-apply (CSA) // Prepares fields owned by `csaManager` for 'Update' operations for use now // with the given `ssaManager` for `Apply` operations. // // This transformation should be performed on an object if it has been previously // managed using client-side-apply to prepare it for future use with // server-side-apply. // // Caveats: // 1. This operation is not reversible. Information about which fields the client // owned will be lost in this operation. // 2. Supports being performed either before or after initial server-side apply. // 3. Client-side apply tends to own more fields (including fields that are defaulted), // this will possibly remove this defaults, they will be re-defaulted, that's fine. // 4. Care must be taken to not overwrite the managed fields on the server if they // have changed before sending a patch. // // obj - Target of the operation which has been managed with CSA in the past // csaManagerNames - Names of FieldManagers to merge into ssaManagerName // ssaManagerName - Name of FieldManager to be used for `Apply` operations func UpgradeManagedFields( obj runtime.Object, csaManagerNames sets.Set[string], ssaManagerName string, opts ...Option, ) error { … } // Calculates a minimal JSON Patch to send to upgrade managed fields // See `UpgradeManagedFields` for more information. // // obj - Target of the operation which has been managed with CSA in the past // csaManagerNames - Names of FieldManagers to merge into ssaManagerName // ssaManagerName - Name of FieldManager to be used for `Apply` operations // // Returns non-nil error if there was an error, a JSON patch, or nil bytes if // there is no work to be done. func UpgradeManagedFieldsPatch( obj runtime.Object, csaManagerNames sets.Set[string], ssaManagerName string, opts ...Option, ) ([]byte, error) { … } // Returns a copy of the provided managed fields that has been migrated from // client-side-apply to server-side-apply, or an error if there was an issue func upgradedManagedFields( managedFields []metav1.ManagedFieldsEntry, csaManagerName string, ssaManagerName string, opts options, ) ([]metav1.ManagedFieldsEntry, error) { … } // Locates an Update manager entry named `csaManagerName` with the same APIVersion // as the manager at the targetIndex. Unions both manager's fields together // into the manager specified by `targetIndex`. No other managers are modified. func unionManagerIntoIndex( entries []metav1.ManagedFieldsEntry, targetIndex int, csaManagerName string, opts options, ) error { … } func findFirstIndex[T any]( collection []T, predicate func(T) bool, ) (int, bool) { … } func filter[T any]( collection []T, predicate func(T) bool, ) []T { … } // Included from fieldmanager.internal to avoid dependency cycle // FieldsToSet creates a set paths from an input trie of fields func decodeManagedFieldsEntrySet(f metav1.ManagedFieldsEntry) (s fieldpath.Set, err error) { … } // SetToFields creates a trie of fields from an input set of paths func encodeManagedFieldsEntrySet(f *metav1.ManagedFieldsEntry, s fieldpath.Set) (err error) { … }