Documentation ¶
Overview ¶
Package structuredmerge implements server side apply support for managed topology controllers.
Index ¶
Constants ¶
const TopologyManagerName = "capi-topology"
TopologyManagerName is the manager name in managed fields for the topology controller.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HelperOption ¶
type HelperOption interface { // ApplyToHelper applies this configuration to the given helper options. ApplyToHelper(*HelperOptions) }
HelperOption is some configuration that modifies options for Helper.
type HelperOptions ¶
type HelperOptions struct {
ssa.FilterObjectInput
}
HelperOptions contains options for Helper.
func (*HelperOptions) ApplyOptions ¶
func (o *HelperOptions) ApplyOptions(opts []HelperOption) *HelperOptions
ApplyOptions applies the given patch options on these options, and then returns itself (for convenient chaining).
type IgnorePaths ¶
IgnorePaths instruct the Helper to ignore given paths when computing a patch. NOTE: ignorePaths are used to filter out fields nested inside allowedPaths, e.g. spec.ControlPlaneEndpoint.
func (IgnorePaths) ApplyToHelper ¶
func (i IgnorePaths) ApplyToHelper(opts *HelperOptions)
ApplyToHelper applies this configuration to the given helper options.
type PatchHelper ¶
type PatchHelper interface { // HasChanges return true if the modified object is generating changes vs the original object. HasChanges() bool // HasSpecChanges return true if the modified object is generating spec changes vs the original object. HasSpecChanges() bool // Changes returns the changes vs the original object. Changes() []byte // Patch patches the given obj in the Kubernetes cluster. Patch(ctx context.Context) error }
PatchHelper define the behavior for component responsible for managing patches for Kubernetes objects owned by the topology controller. NOTE: this interface is required to allow to plug in different PatchHelper implementations, because the default one is based on server side apply, and it cannot be used for topology dry run, so we have a minimal viable replacement based on two-ways merge.
func NewServerSidePatchHelper ¶
func NewServerSidePatchHelper(ctx context.Context, original, modified client.Object, c client.Client, ssaCache ssa.Cache, opts ...HelperOption) (PatchHelper, error)
NewServerSidePatchHelper returns a new PatchHelper using server side apply.
type PatchHelperFactoryFunc ¶
type PatchHelperFactoryFunc func(ctx context.Context, original, modified client.Object, opts ...HelperOption) (PatchHelper, error)
PatchHelperFactoryFunc defines a func that returns a new PatchHelper.
type TwoWaysPatchHelper ¶
type TwoWaysPatchHelper struct {
// contains filtered or unexported fields
}
TwoWaysPatchHelper helps with a patch that yields the modified document when applied to the original document.
func NewTwoWaysPatchHelper ¶
func NewTwoWaysPatchHelper(original, modified client.Object, c client.Client, opts ...HelperOption) (*TwoWaysPatchHelper, error)
NewTwoWaysPatchHelper will return a patch that yields the modified document when applied to the original document using the two-ways merge algorithm. NOTE: In the case of ClusterTopologyReconciler, original is the current object, modified is the desired object, and the patch returns all the changes required to align current to what is defined in desired; fields not managed by the topology controller are going to be preserved without changes. NOTE: TwoWaysPatch is considered a minimal viable replacement for server side apply during topology dry run, with the following limitations:
- TwoWaysPatch doesn't consider OpenAPI schema extension like +ListMap this can lead to false positive when topology dry run is simulating a change to an existing slice (TwoWaysPatch always revert external changes, like server side apply when +ListMap=atomic).
- TwoWaysPatch doesn't consider existing metadata.managedFields, and this can lead to false negative when topology dry run is simulating a change to an existing object where the topology controller is dropping an opinion for a field (TwoWaysPatch always preserve dropped fields, like server side apply when the field has more than one manager).
- TwoWaysPatch doesn't generate metadata.managedFields as server side apply does.
NOTE: NewTwoWaysPatchHelper consider changes only in metadata.labels, metadata.annotation and spec; it also respects the ignorePath option (same as the server side apply helper).
func (*TwoWaysPatchHelper) Changes ¶ added in v1.8.0
func (h *TwoWaysPatchHelper) Changes() []byte
Changes return the changes.
func (*TwoWaysPatchHelper) HasChanges ¶
func (h *TwoWaysPatchHelper) HasChanges() bool
HasChanges return true if the patch has changes.
func (*TwoWaysPatchHelper) HasSpecChanges ¶
func (h *TwoWaysPatchHelper) HasSpecChanges() bool
HasSpecChanges return true if the patch has changes to the spec field.