wrangler

package
v0.0.0-...-e1267bf Latest Latest
Warning

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

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

Documentation

Overview

Package wrangler contains functions for creating a management context with wrangler controllers.

Index

Constants

View Source
const (
	Management controllerContextType = "mgmt"
)

Variables

View Source
var (
	AddToScheme = localSchemeBuilder.AddToScheme
	Scheme      = runtime.NewScheme()
)

Functions

func GetOptsFromEnv

func GetOptsFromEnv(contextType controllerContextType) *controller.SharedControllerFactoryOptions

GetOptsFromEnv configures a SharedControllersFactoryOptions using env var and return a pointer to it.

Types

type Context

type Context struct {
	RESTConfig *rest.Config

	Apply               apply.Apply
	Dynamic             *dynamic.Controller
	Mgmt                managementv3.Interface
	Apps                appsv1.Interface
	ControllerFactory   controller.SharedControllerFactory
	MultiClusterManager MultiClusterManager
	Core                corev1.Interface

	CachedDiscovery         discovery.CachedDiscoveryInterface
	RESTMapper              meta.RESTMapper
	SharedControllerFactory controller.SharedControllerFactory

	RESTClientGetter genericclioptions.RESTClientGetter
	// contains filtered or unexported fields
}

func NewContext

func NewContext(ctx context.Context, restConfig *rest.Config, ts *session.Session) (*Context, error)

NewContext creates a new Context with the given parameters. It initializes the required controller factories and other components needed for the context.

func (*Context) DownStreamClusterWranglerContext

func (w *Context) DownStreamClusterWranglerContext(clusterID string) (*Context, error)

DownStreamClusterWranglerContext creates a wrangler context to interact with a specific cluster.

func (*Context) OnLeader

func (w *Context) OnLeader(f func(ctx context.Context) error)

OnLeader registers a callback function to be executed when the current context becomes the leader. It calls the OnLeader method of the leadership field in the Context struct and passes the provided function as an argument.

func (*Context) Start

func (w *Context) Start(ctx context.Context) error

Start registers the current context as started and performs necessary initialization steps. It acquires a lock using the controllerLock mutex to ensure thread safety. If the context is not already started, it calls the Register method of the Dynamic field in the Context struct, passing the provided context and SharedControllerFactory as arguments. It sets the started field to true. It then calls the Start method of the ControllerFactory field, passing the provided context and 50 as arguments. It returns an error if there is any. It finally calls the Start method of the leadership field in the Context struct, passing the provided context.

func (*Context) StartWithTransaction

func (w *Context) StartWithTransaction(ctx context.Context, f func(context.Context) error) (err error)

StartWithTransaction is a method of the Context struct that starts a transaction and executes a provided callback function within the transaction. It returns an error if the callback fails

type MultiClusterManager

type MultiClusterManager interface {
	NormanSchemas() *types.Schemas
	ClusterDialer(clusterID string) func(ctx context.Context, network, address string) (net.Conn, error)
	Start(ctx context.Context) error
	Wait(ctx context.Context)
	Middleware(next http.Handler) http.Handler
	K8sClient(clusterName string) (kubernetes.Interface, error)
}

type SimpleRESTClientGetter

type SimpleRESTClientGetter struct {
	RESTConfig      *rest.Config
	CachedDiscovery discovery.CachedDiscoveryInterface
	RESTMapper      meta.RESTMapper
}

func (*SimpleRESTClientGetter) ToDiscoveryClient

ToDiscoveryClient returns the cached discovery client It returns the CachedDiscovery field of the SimpleRESTClientGetter struct as a CachedDiscoveryInterface and nil error.

func (*SimpleRESTClientGetter) ToRESTConfig

func (s *SimpleRESTClientGetter) ToRESTConfig() (*rest.Config, error)

ToRESTConfig returns the RESTConfig stored in the SimpleRESTClientGetter. It is a getter method that allows access to the REST configuration. The RESTConfig field is a pointer to rest.Config defined in the SimpleRESTClientGetter struct. It returns the RESTConfig and a nil error.

func (*SimpleRESTClientGetter) ToRESTMapper

func (s *SimpleRESTClientGetter) ToRESTMapper() (meta.RESTMapper, error)

ToRESTMapper returns the REST mapper associated with the SimpleRESTClientGetter. It retrieves the REST mapper from the RESTMapper field of the SimpleRESTClientGetter struct and returns it as the first return value. The second return value is always nil since no error is encountered during the retrieval process.

Directories

Path Synopsis
pkg
generic
Package generic provides generic types and implementations for Controllers, Clients, and Caches.
Package generic provides generic types and implementations for Controllers, Clients, and Caches.

Jump to

Keyboard shortcuts

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