binding

package
v0.21.2 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: Apache-2.0 Imports: 38 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KSFinalizer = "bindingpolicy.kubestellar.io/kscontroller"
)

Variables

This section is empty.

Functions

func ALabelSelectorIsEmpty added in v0.21.0

func ALabelSelectorIsEmpty(selectors ...metav1.LabelSelector) bool

func SliceContains

func SliceContains[Elt comparable](slice []Elt, seek Elt) bool

Types

type APIResource

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

type BindingPolicyResolver

type BindingPolicyResolver interface {
	// GenerateBinding returns the binding for the given
	// bindingpolicy key.
	//
	// If no resolution is associated with the given key, nil is returned.
	GenerateBinding(bindingPolicyKey string) *v1alpha1.BindingSpec
	// GetOwnerReference returns the owner reference for the given
	// bindingpolicy key. If no resolution is associated with the given key, an
	// error is returned.
	GetOwnerReference(bindingPolicyKey string) (metav1.OwnerReference, error)
	// CompareBinding compares the given binding spec
	// with the maintained binding for the given bindingpolicy key.
	// The returned value is true only if:
	//
	// - The destinations in the BindingSpec are an exact match
	//of those in the resolution.
	//
	// - The same is true for every selected object.
	//
	// It is possible to output a false negative due to a temporary state of
	// internal caches being out of sync.
	CompareBinding(bindingPolicyKey string,
		bindingSpec *v1alpha1.BindingSpec) bool

	// NoteBindingPolicy associates a new resolution with the given
	// bindingpolicy, if none is associated. This method maintains the
	// singleton status reporting requirement in the resolution.
	NoteBindingPolicy(bindingpolicy *v1alpha1.BindingPolicy)

	// EnsureObjectIdentifierWithVersion ensures that an object's identifier is
	// in the resolution for the given bindingpolicy key, and is associated
	// with the given resourceVersion.
	//
	// The returned bool indicates whether the bindingpolicy resolution was
	// changed. If no resolution is associated with the given key, an error is
	// returned.
	EnsureObjectIdentifierWithVersion(bindingPolicyKey string, objIdentifier util.ObjectIdentifier,
		resourceVersion string) (bool, error)
	// RemoveObjectIdentifier ensures the absence of the given object
	// identifier from the resolution for the given bindingpolicy key.
	//
	// The returned bool indicates whether the bindingpolicy resolution was
	// changed. If no resolution is associated with the given key, false is
	// returned.
	RemoveObjectIdentifier(bindingPolicyKey string, objIdentifier util.ObjectIdentifier) bool
	// GetObjectIdentifiers returns the object identifiers associated with the
	// given bindingpolicy key.
	// If no resolution is associated with the given key, an error is returned.
	GetObjectIdentifiers(bindingPolicyKey string) (sets.Set[util.ObjectIdentifier], error)

	// SetDestinations updates the maintained bindingpolicy's
	// destinations resolution for the given bindingpolicy key.
	// The given destinations set is expected not to be mutated during and
	// after this call by the caller.
	// If no resolution is associated with the given key, an error is returned.
	SetDestinations(bindingPolicyKey string, destinations sets.Set[string]) error

	// ResolutionExists returns true if a resolution is associated with the
	// given bindingpolicy key.
	ResolutionExists(bindingPolicyKey string) bool
	// ResolutionRequiresSingletonReportedState returns true if the
	// bindingpolicy associated with the given key requires a singleton
	// reported state, and it satisfies the conditions on this requirement.
	//
	// This means that if true is returned, then the singleton status reporting
	// requirement is effective.
	ResolutionRequiresSingletonReportedState(bindingPolicyKey string) bool
	// DeleteResolution deletes the resolution associated with the given key,
	// if it exists.
	DeleteResolution(bindingPolicyKey string)
}

A BindingPolicyResolver holds a collection of bindingpolicy resolutions. The collection is indexed by bindingPolicyKey strings, which are the names of the bindingpolicy objects. The resolution for a given key can be updated, exported and compared to the binding representation. All functions in this interface are thread-safe, and nothing mutates any method-parameter during a call to one of them.

func NewBindingPolicyResolver

func NewBindingPolicyResolver() BindingPolicyResolver

type Controller

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

Controller watches all objects, finds associated bindingpolicies, when matched a bindingpolicy wraps and places objects into mailboxes

func NewController

func NewController(parentLogger logr.Logger, wdsRestConfig *rest.Config, imbsRestConfig *rest.Config,
	wdsName string, allowedGroupsSet sets.Set[string]) (*Controller, error)

Create a new binding controller

func (*Controller) AppendKSResources added in v0.21.2

func (c *Controller) AppendKSResources(ctx context.Context) error

AppendKSResources lets the controller know about the KS resources. Call this after EnsureCRDs and before Start.

func (*Controller) EnsureCRDs

func (c *Controller) EnsureCRDs(ctx context.Context) error

EnsureCRDs will ensure that the CRDs are installed. Call this before Start.

func (*Controller) Start

func (c *Controller) Start(parentCtx context.Context, workers int, cListers chan interface{}) error

Start the controller

Jump to

Keyboard shortcuts

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