applyset

package
v0.0.0-...-c7d747a Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ApplyResults

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

ApplyResults contains the results of an Apply operation.

func (*ApplyResults) AllApplied

func (r *ApplyResults) AllApplied() bool

AllApplied is true if the desired state has been successfully applied for all objects. Note: you likely also want to check AllHealthy, if you want to be sure the objects are "ready".

func (*ApplyResults) AllHealthy

func (r *ApplyResults) AllHealthy() bool

AllHealthy is true if all the objects have been applied and have converged to a "ready" state. Note that this is only meaningful if AllApplied is true.

type ApplySet

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

ApplySet is a set of objects that we want to apply to the cluster.

An ApplySet has a few cases which it tries to optimize for: * We can change the objects we're applying * We want to watch the objects we're applying / be notified of changes * We want to know when the objects we apply are "healthy" * We expose a "try once" method to better support running from a controller.

TODO: Pluggable health functions. TODO: Pruning

func New

func New(options Options) (*ApplySet, error)

New constructs a new ApplySet

func (*ApplySet) ApplyOnce

func (a *ApplySet) ApplyOnce(ctx context.Context) (*ApplyResults, error)

ApplyOnce will make one attempt to apply all objects and observe their health. It does not wait for the objects to become healthy, but will report their health.

TODO: Limit the amount of time this takes, particularly if we have thousands of objects.

We don't _have_ to try to apply all objects if it is taking too long.

TODO: We re-apply every object every iteration; we should be able to do better.

func (*ApplySet) ReplaceAllObjects

func (a *ApplySet) ReplaceAllObjects(objects []ApplyableObject) error

ReplaceAllObjects is used to replace the desired state of all the objects. Any objects not specified are removed from the "desired" set.

type ApplyableObject

type ApplyableObject interface {
	GroupVersionKind() schema.GroupVersionKind
	GetNamespace() string
	GetName() string

	GetOwnerReferences() []metav1.OwnerReference
	SetOwnerReferences([]metav1.OwnerReference)
}

type Options

type Options struct {
	// Client is the dynamic kubernetes client used to apply objects to the k8s cluster.
	Client dynamic.Interface
	// RESTMapper is used to map object kind to resources, and to know if objects are cluster-scoped.
	RESTMapper meta.RESTMapper
	// PatchOptions holds the options used when applying, in particular the fieldManager
	PatchOptions metav1.PatchOptions
}

Options holds the parameters for building an ApplySet.

Jump to

Keyboard shortcuts

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