output

package
v0.36.7 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2024 License: Apache-2.0 Imports: 16 Imported by: 17

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ClusterLabelKey = fmt.Sprintf("cluster.%s", v1alpha1.SchemeGroupVersion.Group)

the key used to differentiate discovery resources by the cluster in which they were discovered

Functions

func AddClusterLabels added in v0.7.17

func AddClusterLabels(clusterName string, objLabels map[string]string) map[string]string

adds cluster labels to the given set of labels and returns them

func ClusterLabel added in v0.7.17

func ClusterLabel(cluster string) (string, string)

func ClusterLabels added in v0.7.17

func ClusterLabels(cluster string) map[string]string

Create a label that identifies the cluster used to discover a resource.

Types

type ErrorHandler added in v0.7.17

type ErrorHandler interface {
	// handle an error that happens when we try to write a resource
	HandleWriteError(resource ezkube.Object, err error)

	// handle an error that happens when we try to delete a resource
	HandleDeleteError(resource ezkube.Object, err error)

	// handle an error that happens when we try list resources in a cluster
	HandleListError(err error)
}

User-defined error-handling functions. Used to invoke custom error-handling code when a resource write fails.

type ErrorHandlerFuncs added in v0.7.17

type ErrorHandlerFuncs struct {
	// handle an error that happens when we try to write a resource
	HandleWriteErrorFunc func(resource ezkube.Object, err error)

	// handle an error that happens when we try to delete a resource
	HandleDeleteErrorFunc func(resource ezkube.Object, err error)

	// handle an error that happens when we try list resources in a cluster
	HandleListErrorFunc func(err error)
}

straightforward implementation of an Error Handler

func (ErrorHandlerFuncs) HandleDeleteError added in v0.7.17

func (e ErrorHandlerFuncs) HandleDeleteError(resource ezkube.Object, err error)

func (ErrorHandlerFuncs) HandleListError added in v0.7.17

func (e ErrorHandlerFuncs) HandleListError(err error)

func (ErrorHandlerFuncs) HandleWriteError added in v0.7.17

func (e ErrorHandlerFuncs) HandleWriteError(resource ezkube.Object, err error)

type OutputOpts added in v0.19.4

type OutputOpts struct {
	// error handler
	ErrHandler ErrorHandler

	// If provided, ensure the resource has been verified before adding it to snapshots
	Verifier verifier.OutputResourceVerifier
}

Options for writing resources of a given type

type ResourceList

type ResourceList struct {
	// the desired resources should share the given labels
	Resources []ezkube.Object

	// list function that will be used to compare the given resources to the currently existing state.
	// if the resources in the list do not match those returned by the list func,
	// the differences will be reconciled by applying the snapshot.
	// if this function is nil, no garbage collection will be done.
	ListFunc func(ctx context.Context, cli client.Client) ([]ezkube.Object, error)

	// indicates whether the resources in the list should have their status updated to the cluster.
	// if true, resources will not be upserted or garbage collected.
	StatusUpdate bool

	// GVK of the resources in the list
	GVK schema.GroupVersionKind
}

a ResourceList define a list of resources we wish to write to kubernetes. A ListFunc can be provided to compare the resources with what is currently written to storage and trim stale resources. A transition function can also be provided for updating existing resources.

func (ResourceList) SplitByClusterName

func (l ResourceList) SplitByClusterName() map[string][]ezkube.Object

partition the resource list by the ClusterName of each object.

type Snapshot

type Snapshot struct {
	// name of the snapshot, used for metrics
	Name string

	// the clusters across which the snapshot should be synced.
	// only relevant for multicluster syncing.
	Clusters []string

	// the lists of resources to sync, partitioned by resource type
	// and ListFunc (typically a set of labels)
	ListsToSync []ResourceList
}

an Output Snapshot defines a list of desired resources to apply to Kubernetes. Stale resources (resources with no parents) will be garbage collected.

A resources is determined to be stale when it currently exists in the cluster, but does not exist in the snapshot.

func (Snapshot) SyncLocalCluster added in v0.7.17

func (s Snapshot) SyncLocalCluster(ctx context.Context, cli client.Client, opts OutputOpts)

sync the output snapshot to local cluster storage. only writes resources intended for the local cluster (with ClusterName == "") Note that Syncing snapshots in this way adds the label

func (Snapshot) SyncMultiCluster

func (s Snapshot) SyncMultiCluster(ctx context.Context, mcClient multicluster.Client, opts OutputOpts)

sync the output snapshot to storage across multiple clusters. uses the object's ClusterName to determine the correct destination cluster.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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