sharedmain

package
v0.11.0 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: 57 Imported by: 1

Documentation

Overview

Package sharedmain contains useful functionality for main

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultTimeout = kclient.DefaultTimeout
	DefaultQPS     = kclient.DefaultQPS
	DefaultBurst   = kclient.DefaultBurst
	Timeout        time.Duration
	Burst          int
	QPS            float64
	ConfigFile     string

	WebServerPort      int
	InsecureSkipVerify bool

	ClusterProxyHost string
	ClusterProxyPath string
)

Functions

func GetClientManager

func GetClientManager(ctx context.Context) (context.Context, *kclient.Manager)

func GetConfigOrDie

func GetConfigOrDie(ctx context.Context) (context.Context, *rest.Config)

func GetLoggingConfig

func GetLoggingConfig(ctx context.Context) (*logging.Config, error)

func ParseFlag added in v0.2.0

func ParseFlag()

ParseFlag parse flag needed for App

func SetupLoggerOrDie

func SetupLoggerOrDie(ctx context.Context, component string) (*zap.SugaredLogger, zap.AtomicLevel)

SetupLoggerOrDie sets up the logger using the config from the given context and returns a logger and atomic level, or dies by calling log.Fatalf.

func WatchLoggingConfigOrDie

func WatchLoggingConfigOrDie(ctx context.Context, cmw configmap.Watcher, logger *zap.SugaredLogger, lvlMGR *klogging.LevelManager)

WatchLoggingConfigOrDie establishes a watch of the logging config or dies by calling log.Fatalw. Note, if the config does not exist, it will be defaulted and this method will not die.

func WithScheme

func WithScheme(scheme *runtime.Scheme) ctrlcluster.Option

WithScheme adds a scheme to cluster.Options

Types

type AddToRestContainer

type AddToRestContainer func(ws *restful.WebService)

type AppBuilder

type AppBuilder struct {
	// Basic options
	Name    string
	Context context.Context
	Config  *rest.Config
	sync.Once

	// Log related options
	Logger       *zap.SugaredLogger
	ZapConfig    *zap.Config
	LevelManager *klogging.LevelManager

	// Controllers
	Manager ctrl.Manager

	// ConfigWatch
	ConfigMapWatcher DefaultingWatcherWithOnChange

	// Profiling
	ProfilingServer *http.Server

	// client manager
	ClientManager *kclient.Manager
	// contains filtered or unexported fields
}

AppBuilder builds an app using multiple configuration options

func App

func App(name string) *AppBuilder

App main constructor entrypoint for AppBuilder

func (*AppBuilder) APIDocs

func (a *AppBuilder) APIDocs() *AppBuilder

APIDocs adds api docs to the server

func (*AppBuilder) ConfigManager added in v0.7.0

func (a *AppBuilder) ConfigManager() *AppBuilder

ConfigManager add katanomi manager to app context

func (*AppBuilder) Container

func (a *AppBuilder) Container(container *restful.Container) *AppBuilder

Container adds a containers

func (*AppBuilder) Controllers

func (a *AppBuilder) Controllers(ctors ...controllers.SetupChecker) *AppBuilder

Controllers adds controllers to the app, will start a manager under the hood

func (*AppBuilder) Filters

func (a *AppBuilder) Filters(filters ...restful.FilterFunction) *AppBuilder

Filters customize filters to this app

func (*AppBuilder) Log

func (a *AppBuilder) Log() *AppBuilder

Log adds logging and logger to the app

func (*AppBuilder) MultiClusterClient

func (a *AppBuilder) MultiClusterClient(client multicluster.Interface) *AppBuilder

MultiClusterClient injects a multi cluster client into the context

func (*AppBuilder) NewResourceLock added in v0.7.0

func (a *AppBuilder) NewResourceLock(newResourceLock kmanager.ResourceLockFunc) *AppBuilder

NewResourceLock set a new resource lock Used to change the default behavior in controller-runtime

func (*AppBuilder) PluginAttributes added in v0.3.0

func (a *AppBuilder) PluginAttributes(plugin client.PluginAttributes, file string) *AppBuilder

PluginAttributes set plugin attributes from yaml file

func (*AppBuilder) PluginDisplayColumns added in v0.11.0

func (a *AppBuilder) PluginDisplayColumns(plugin client.PluginDisplayColumns, file string) *AppBuilder

PluginDisplayColumns set plugin displayColumns from yaml file

func (*AppBuilder) PluginVersionAttributes added in v0.9.0

func (a *AppBuilder) PluginVersionAttributes(plugin client.PluginVersionAttributes, file string) *AppBuilder

PluginVersionAttributes set plugin attributes from yaml file

func (*AppBuilder) Plugins

func (a *AppBuilder) Plugins(plugins ...client.Interface) *AppBuilder

Plugins adds plugins to this app

func (*AppBuilder) Profiling

func (a *AppBuilder) Profiling() *AppBuilder

Profiling enables profiling http server

func (*AppBuilder) RESTClient

func (a *AppBuilder) RESTClient(client *resty.Client) *AppBuilder

RESTClient injects a RESTClient

func (*AppBuilder) Run

func (a *AppBuilder) Run(startFuncs ...func(context.Context) error) error

Run starts all

func (*AppBuilder) Scheme

func (a *AppBuilder) Scheme(scheme *runtime.Scheme) *AppBuilder

Scheme provides a scheme to the app

func (*AppBuilder) StoragePlugins added in v0.7.0

func (a *AppBuilder) StoragePlugins(plugins ...client.Interface) *AppBuilder

StoragePlugins adds storage plugins to this app

func (*AppBuilder) Tracing

func (a *AppBuilder) Tracing(ops ...tracing.TraceOption) *AppBuilder

Tracing adds tracing and tracer to the app

func (*AppBuilder) Webhooks

func (a *AppBuilder) Webhooks(objs ...runtime.Object) *AppBuilder

Webhooks adds webhook setup for objects in app

func (*AppBuilder) Webservices

func (a *AppBuilder) Webservices(webServices ...WebService) *AppBuilder

type Controller

type Controller interface {
	Name() string
	Setup(context.Context, manager.Manager, *zap.SugaredLogger) error
}

Controller is a basic interface that every reconciler should implement to create a new controller and startup in the controller manager

type DefaultingWatcherWithOnChange added in v0.7.0

type DefaultingWatcherWithOnChange watcher.DefaultingWatcherWithOnChange

DefaultingWatcherWithOnChange is a configmap.DefaultingWatcher that also has an OnChange callback. Deprecated: please use watcher.DefaultWatcherWithOnChange

type WebService

type WebService interface {
	Name() string
	Setup(ctx context.Context, add AddToRestContainer, logger *zap.SugaredLogger) error
}

type WebhookRegisterSetup

type WebhookRegisterSetup interface {
	GetLoggerName() string
	SetupRegisterWithManager(context.Context, ctrl.Manager)
}

WebhookRegisterSetup method to inject and setup webhook register using the object

type WebhookSetup

type WebhookSetup interface {
	SetupWebhookWithManager(mgr ctrl.Manager) error
}

WebhookSetup method to inject and setup webhooks using the object

Jump to

Keyboard shortcuts

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