structuredmerge

package
v1.11.2 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package structuredmerge implements server side apply support for managed topology controllers.

Index

Constants

View Source
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 DropEmptyStructAndNil added in v1.11.0

type DropEmptyStructAndNil bool

DropEmptyStructAndNil instructs the Helper to drop all fields with values equal to empty struct or nil. NOTE: This is required when using typed objects, because the DefaultUnstructuredConverter does not handle omitzero (yet).

func (DropEmptyStructAndNil) ApplyToHelper added in v1.11.0

func (i DropEmptyStructAndNil) ApplyToHelper(opts *HelperOptions)

ApplyToHelper applies this configuration to the given helper options.

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

type IgnorePaths []contract.Path

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.

Jump to

Keyboard shortcuts

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