package merge
import "sigs.k8s.io/structured-merge-diff/v4/merge"
Index ¶
- type Conflict
- type Conflicts
- func ConflictsFromManagers(sets fieldpath.ManagedFields) Conflicts
- func (c Conflicts) Equals(c2 Conflicts) bool
- func (conflicts Conflicts) Error() string
- func (c Conflicts) ToSet() *fieldpath.Set
- type Converter
- type Updater
- func (s *Updater) Apply(liveObject, configObject *typed.TypedValue, version fieldpath.APIVersion, managers fieldpath.ManagedFields, manager string, force bool) (*typed.TypedValue, fieldpath.ManagedFields, error)
- func (s *Updater) Update(liveObject, newObject *typed.TypedValue, version fieldpath.APIVersion, managers fieldpath.ManagedFields, manager string) (*typed.TypedValue, fieldpath.ManagedFields, error)
- type UpdaterBuilder
Types ¶
type Conflict ¶
Conflict is a conflict on a specific field with the current manager of that field. It does implement the error interface so that it can be used as an error.
func (Conflict) Equals ¶
Equals returns true if c == c2
func (Conflict) Error ¶
Error formats the conflict as an error.
type Conflicts ¶
type Conflicts []Conflict
Conflicts accumulates multiple conflicts and aggregates them by managers.
func ConflictsFromManagers ¶
func ConflictsFromManagers(sets fieldpath.ManagedFields) Conflicts
ConflictsFromManagers creates a list of conflicts given Managers sets.
func (Conflicts) Equals ¶
Equals returns true if the lists of conflicts are the same.
func (Conflicts) Error ¶
Error prints the list of conflicts, grouped by sorted managers.
func (Conflicts) ToSet ¶
ToSet aggregates conflicts for all managers into a single Set.
type Converter ¶
type Converter interface { Convert(object *typed.TypedValue, version fieldpath.APIVersion) (*typed.TypedValue, error) IsMissingVersionError(error) bool }
Converter is an interface to the conversion logic. The converter needs to be able to convert objects from one version to another.
type Updater ¶
type Updater struct { // Deprecated: This will eventually become private. Converter Converter // Deprecated: This will eventually become private. IgnoredFields map[fieldpath.APIVersion]*fieldpath.Set // Deprecated: This will eventually become private. IgnoreFilter map[fieldpath.APIVersion]fieldpath.Filter // contains filtered or unexported fields }
Updater is the object used to compute updated FieldSets and also merge the object on Apply.
func (*Updater) Apply ¶
func (s *Updater) Apply(liveObject, configObject *typed.TypedValue, version fieldpath.APIVersion, managers fieldpath.ManagedFields, manager string, force bool) (*typed.TypedValue, fieldpath.ManagedFields, error)
Apply should be called when Apply is run, given the current object as well as the configuration that is applied. This will merge the object and return it.
func (*Updater) Update ¶
func (s *Updater) Update(liveObject, newObject *typed.TypedValue, version fieldpath.APIVersion, managers fieldpath.ManagedFields, manager string) (*typed.TypedValue, fieldpath.ManagedFields, error)
Update is the method you should call once you've merged your final object on CREATE/UPDATE/PATCH verbs. newObject must be the object that you intend to persist (after applying the patch if this is for a PATCH call), and liveObject must be the original object (empty if this is a CREATE call).
type UpdaterBuilder ¶
type UpdaterBuilder struct { Converter Converter IgnoreFilter map[fieldpath.APIVersion]fieldpath.Filter // IgnoredFields provides a set of fields to ignore for each IgnoredFields map[fieldpath.APIVersion]*fieldpath.Set // Stop comparing the new object with old object after applying. // This was initially used to avoid spurious etcd update, but // since that's vastly inefficient, we've come-up with a better // way of doing that. Create this flag to stop it. // Comparing has become more expensive too now that we're not using // `Compare` but `value.Equals` so this gives an option to avoid it. ReturnInputOnNoop bool }
UpdateBuilder allows you to create a new Updater by exposing all of the options and setting them once.
func (*UpdaterBuilder) BuildUpdater ¶
func (u *UpdaterBuilder) BuildUpdater() *Updater
Source Files ¶
conflict.go update.go
- Version
- v4.5.0 (latest)
- Published
- Dec 11, 2024
- Platform
- linux/amd64
- Imports
- 6 packages
- Last checked
- 2 months ago –
Tools for package owners.