clustersmngr

package
v0.7.0-rc9 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2022 License: MPL-2.0 Imports: 8 Imported by: 14

Documentation

Index

Constants

View Source
const (
	// Clusters Client context key
	ClustersClientCtxKey key = iota
)
View Source
const DefaultCluster = "Default"

Variables

This section is empty.

Functions

func WithClustersClient

func WithClustersClient(clustersFetcher ClusterFetcher, next http.Handler) http.Handler

WithClustersClient creates clusters client for provided user in the context

Types

type Client

type Client interface {
	// Get retrieves an obj for the given object key.
	Get(ctx context.Context, cluster string, key client.ObjectKey, obj client.Object) error
	// List retrieves list of objects for a given namespace and list options.
	List(ctx context.Context, cluster string, list client.ObjectList, opts ...client.ListOption) error

	// Create saves the object obj.
	Create(ctx context.Context, cluster string, obj client.Object, opts ...client.CreateOption) error
	// Delete deletes the given obj
	Delete(ctx context.Context, cluster string, obj client.Object, opts ...client.DeleteOption) error
	// Update updates the given obj.
	Update(ctx context.Context, cluster string, obj client.Object, opts ...client.UpdateOption) error
	// Patch patches the given obj
	Patch(ctx context.Context, cluster string, obj client.Object, patch client.Patch, opts ...client.PatchOption) error

	// ClusteredList retrieves list of objects for all clusters.
	ClusteredList(ctx context.Context, clist ClusteredObjectList, opts ...client.ListOption) error

	// ClientsPool returns the clients pool.
	ClientsPool() ClientsPool
}

Client thin wrapper to controller-runtime/client adding multi clusters context.

func ClientFromCtx

func ClientFromCtx(ctx context.Context) Client

ClientFromCtx returns the ClusterClient stored in the context

func NewClient

func NewClient(clientsPool ClientsPool) Client

type ClientsPool

type ClientsPool interface {
	Add(user *auth.UserPrincipal, cluster Cluster) error
	Clients() map[string]client.Client
	Client(cluster string) (client.Client, error)
}

ClientsPool stores all clients to the leaf clusters

func NewClustersClientsPool

func NewClustersClientsPool() ClientsPool

NewClustersClientsPool initializes a new ClientsPool

type Cluster

type Cluster struct {
	// Name defines the cluster name
	Name string `yaml:"name"`
	// Server defines cluster api address
	Server string `yaml:"server"`

	// SecretRef defines secret name that holds the cluster Bearer Token
	SecretRef string `yaml:"secretRef"`
	// BearerToken cluster access token read from SecretRef
	BearerToken string

	// TLSConfig holds configuration for TLS connection with the cluster values read from SecretRef
	TLSConfig rest.TLSClientConfig
}

Cluster defines a leaf cluster

type ClusterFetcher

type ClusterFetcher interface {
	Fetch(ctx context.Context) ([]Cluster, error)
}

ClusterFetcher fetches all leaf clusters

func NewSingleClusterFetcher

func NewSingleClusterFetcher(config *rest.Config) (ClusterFetcher, error)

type ClusterNotFoundError

type ClusterNotFoundError struct {
	Cluster string
}

ClusterNotFoundError cluster client can be found in the pool

func (ClusterNotFoundError) Error

func (e ClusterNotFoundError) Error() string

type ClusteredList

type ClusteredList struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func (*ClusteredList) Lists

func (cl *ClusteredList) Lists() map[string]client.ObjectList

func (*ClusteredList) ObjectList

func (cl *ClusteredList) ObjectList(cluster string) client.ObjectList

type ClusteredObjectList

type ClusteredObjectList interface {
	ObjectList(cluster string) client.ObjectList
	Lists() map[string]client.ObjectList
}

func NewClusteredList

func NewClusteredList(listFactory func() client.ObjectList) ClusteredObjectList

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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