clusterclientstore

package
v0.10.9 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2021 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package clusterclientstore provides a thread-safe storage for Kubernetes API clients connected to target clusters. The internal storage is updated automatically by watching for Cluster and Secret resources. New Cluster objects trigger a client/informer creation, updates to Secret objects trigger re-creation of a client/informer, and Cluster deletions cause the removal of a client and its associated informer.

Index

Constants

View Source
const AgentName = "clusterclientstore"

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientBuilderFunc

type ClientBuilderFunc func(string, string, *rest.Config) (kubernetes.Interface, error)

This enables tests to inject an appropriate fake client, which allows us to use the real cluster client store in unit tests.

type EventHandlerRegisterFunc

type EventHandlerRegisterFunc func(kubeinformers.SharedInformerFactory, string)

EventHandlerRegisterFunc is called after the caches for the clusters have been built, and provides a hook for a controller to register its event handlers. These will be event handlers for changes to the resources that the controller has subscribed to in the `SubscriptionRegisterFunc` callback.

type Interface

type Interface interface {
	AddEventHandlerCallback(EventHandlerRegisterFunc)
	AddSubscriptionCallback(SubscriptionRegisterFunc)
	GetClient(clusterName string, ua string) (kubernetes.Interface, error)
	GetConfig(clusterName string) (*rest.Config, error)
	GetInformerFactory(string) (kubeinformers.SharedInformerFactory, error)
}

type Store

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

func NewStore

func NewStore(
	buildClient ClientBuilderFunc,
	secretInformer corev1informer.SecretInformer,
	clusterInformer shipperinformer.ClusterInformer,
	ns string,
	restTimeout *time.Duration,
) *Store

NewStore creates a new client store that will use the specified informers to maintain a cache of clientsets, rest.Configs, and informers for target clusters.

func (*Store) AddEventHandlerCallback

func (s *Store) AddEventHandlerCallback(eventHandler EventHandlerRegisterFunc)

func (*Store) AddSubscriptionCallback

func (s *Store) AddSubscriptionCallback(subscription SubscriptionRegisterFunc)

func (*Store) GetClient

func (s *Store) GetClient(clusterName string, ua string) (kubernetes.Interface, error)

GetClient returns a client for the specified cluster name and user agent pair.

func (*Store) GetConfig

func (s *Store) GetConfig(clusterName string) (*rest.Config, error)

GetConfig returns a rest.Config for the specified cluster name.

func (*Store) GetInformerFactory

func (s *Store) GetInformerFactory(clusterName string) (kubeinformers.SharedInformerFactory, error)

GetInformerFactory returns an informer factory for the specified cluster name.

func (*Store) Run

func (s *Store) Run(stopCh <-chan struct{})

type SubscriptionRegisterFunc

type SubscriptionRegisterFunc func(kubeinformers.SharedInformerFactory)

SubscriptionRegisterFunc should call the relevant functions on a shared informer factory to set up watches.

Note that there should be no event handlers being assigned to any informers in this function.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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