sync

package
v0.4.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OwnedBy added in v0.2.0

func OwnedBy(obj ctrlruntimeclient.Object, agentName string) bool

func RemoteNameForLocalObject

func RemoteNameForLocalObject(localObj ctrlruntimeclient.Object) *mcreconcile.Request

func WithClusterName added in v0.4.0

func WithClusterName(ctx context.Context, cluster logicalcluster.Name) context.Context

func WithEventRecorder added in v0.4.0

func WithEventRecorder(ctx context.Context, recorder record.EventRecorder) context.Context

WithEventRecorder adds a event recorder to the context. The recorder must be configured for the kcp side of the synchronization as the agent never issues events on the local cluster.

func WithWorkspacePath added in v0.4.0

func WithWorkspacePath(ctx context.Context, path logicalcluster.Path) context.Context

Types

type MutatorCreatorFunc added in v0.3.0

type MutatorCreatorFunc func(*syncagentv1alpha1.ResourceMutationSpec) (mutation.Mutator, error)

type ObjectStateStore

type ObjectStateStore interface {
	Get(ctx context.Context, source syncSide) (*unstructured.Unstructured, error)
	Put(ctx context.Context, obj *unstructured.Unstructured, clusterName logicalcluster.Name, subresources []string) error
}

type ResourceSyncer

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

func NewResourceSyncer

func NewResourceSyncer(
	log *zap.SugaredLogger,
	localClient ctrlruntimeclient.Client,
	remoteClient ctrlruntimeclient.Client,
	pubRes *syncagentv1alpha1.PublishedResource,
	localCRD *apiextensionsv1.CustomResourceDefinition,
	mutatorCreator MutatorCreatorFunc,
	stateNamespace string,
	agentName string,
) (*ResourceSyncer, error)

func (*ResourceSyncer) Process

func (s *ResourceSyncer) Process(ctx context.Context, remoteObj *unstructured.Unstructured) (requeue bool, err error)

Process is the primary entrypoint for object synchronization. This function will create/update the local primary object (i.e. the copy of the remote object), sync any local status back to the remote object and then also synchronize all related resources. It also handles object deletion and will clean up the local objects when a remote object is gone. Each of these steps can potentially end the current processing and return (true, nil). In this case, the caller should re-fetch the remote object and call Process() again (most likely in the next reconciliation). Only when (false, nil) is returned is the entire process finished. The context must contain a cluster name and event recorder, optionally a workspace path.

Directories

Path Synopsis
apis
dummy/v1alpha1
+groupName=dummy.example.com +versionName=v1alpha1 +kubebuilder:object:generate=true
+groupName=dummy.example.com +versionName=v1alpha1 +kubebuilder:object:generate=true

Jump to

Keyboard shortcuts

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