hierarchy

package
v0.22.9 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2022 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package hierarchy provides tools to discover a resource hierarchy. A resource hierarchy is made when a resource has a set of rules to discover other resources.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func List

func List(ctx context.Context, cli client.Client, list client.ObjectList, sel Selector) error

List will populate list with elements that match sel.

Types

type KeySelector

type KeySelector struct {
	Namespace, Name string
}

KeySelector is used for discovering a single object based on namespace and name.

func (*KeySelector) ApplyToList

func (ks *KeySelector) ApplyToList(lo *client.ListOptions)

ApplyToList implements Selector.

func (*KeySelector) Matches

func (ks *KeySelector) Matches(ctx context.Context, cli client.Client, o client.Object) (bool, error)

Matches implements Selector.

type LabelsSelector

type LabelsSelector struct {
	// NamespaceName is the default namespace to search for objects in when
	// NamespaceSelector is nil.
	NamespaceName string

	// NamespaceLabels causes all namespaces whose labels match NamespaceLabels
	// to be searched. When nil, only the namespace specified by NamespaceName
	// will be searched.
	NamespaceLabels labels.Selector

	// Labels discovers all objects whose labels match the selector. If nil,
	// no objects will be discovered.
	Labels labels.Selector
}

LabelsSelector is used for discovering a set of objects in a hierarchy based on labels.

func (*LabelsSelector) ApplyToList

func (ls *LabelsSelector) ApplyToList(lo *client.ListOptions)

ApplyToList implements Selector.

func (*LabelsSelector) Matches

func (ls *LabelsSelector) Matches(ctx context.Context, cli client.Client, o client.Object) (bool, error)

Matches implements Selector.

type Notifier

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

Notifier can be attached to a controller and generate reconciles when objects inside of a resource hierarchy change.

func NewNotifier

func NewNotifier(l log.Logger, cli client.Client) *Notifier

NewNotifier creates a new Notifier which uses the provided client for performing hierarchy lookups.

func (*Notifier) EventHandler

func (n *Notifier) EventHandler() handler.EventHandler

EventHandler returns an event handler that can be given to controller.Watches.

controller.Watches should be called once per type in the resource hierarchy. Each call to controller.Watches should use the same Notifier.

func (*Notifier) Notify

func (n *Notifier) Notify(watchers ...Watcher) error

Notify configures reconciles to be generated for a set of watchers when watched resources change.

Notify appends to the list of watchers. To remove out notifications for a specific owner, call StopNotify.

func (*Notifier) StopNotify

func (n *Notifier) StopNotify(owner client.ObjectKey)

StopNotify removes all watches for a specific owner.

type Selector

type Selector interface {
	// ListOption can be passed to List to perform initial filtering of returned
	// objects.
	client.ListOption

	// Matches returns true if the Selector matches the provided Object. The
	// provided Client may be used to perform extra searches.
	Matches(context.Context, client.Client, client.Object) (bool, error)
}

Selector finding objects within the resource hierarchy.

type Watcher

type Watcher struct {
	Object   client.Object    // Object to watch for events against.
	Owner    client.ObjectKey // Owner to receive a reconcile for.
	Selector Selector         // Selector to use to match changed objects.
}

Watcher is something watching for changes to a resource.

Jump to

Keyboard shortcuts

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