common

package
v1.42.5 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, BSD-2-Clause, MIT, + 1 more Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultWatchdogInterval is the default interval between checks performed by watchdogs.
	DefaultWatchdogInterval = 30 * time.Second
	// DefaultWatchdogTimeout is the default timeout for checks performed by watchdogs.
	DefaultWatchdogTimeout = 2 * time.Minute
	// DefaultWatchdogTTL is the default watchdog TTL.
	DefaultWatchdogTTL = 10 * time.Minute
)

Variables

This section is empty.

Functions

func GetOwnerCheckResultAndContext added in v1.33.0

func GetOwnerCheckResultAndContext(ctx context.Context, c client.Client, namespace, shootName, key string) (bool, context.Context, func(), error)

GetOwnerCheckResultAndContext returns the result and context from the watchdog for the given namespace managed by the default owner check WatchdogManager.

Types

type ChartRendererContext

type ChartRendererContext struct {
	RESTConfigContext
	// contains filtered or unexported fields
}

ChartRendererContext extends the RESTConfigContext to additionally provide a chart renderer

func NewChartRendererContext

func NewChartRendererContext(factory chartrenderer.Factory) ChartRendererContext

NewChartRendererContext creates a new chart renderer context using a dedicated factory for the renderer,

func (*ChartRendererContext) ChartRenderer

func (cc *ChartRendererContext) ChartRenderer() chartrenderer.Interface

ChartRenderer returns the chart renderer of the context

func (*ChartRendererContext) InjectConfig

func (cc *ChartRendererContext) InjectConfig(config *rest.Config) error

InjectConfig injects the given REST config into the context and creates an appropriate chart renderer

type Checker added in v1.33.0

type Checker interface {
	// Check checks that a certain condition is true.
	Check(ctx context.Context) (bool, error)
}

Checker checks if a certain condition is true.

func NewOwnerChecker added in v1.33.0

func NewOwnerChecker(ownerName, ownerID string, resolver Resolver, logger logr.Logger) Checker

NewOwnerChecker returns a Checker that checks if the given owner domain name resolves to the given owner ID, using the given resolver and logger.

type CheckerFactory added in v1.33.0

type CheckerFactory interface {
	// NewChecker creates a new Checker using the given context, client, namespace, and shoot name.
	NewChecker(ctx context.Context, c client.Client, namespace, shootName string) (Checker, error)
}

CheckerFactory creates Checker instances.

func NewOwnerCheckerFactory added in v1.33.0

func NewOwnerCheckerFactory(resolver Resolver, logger logr.Logger) CheckerFactory

NewOwnerCheckerFactory creates a new CheckerFactory that uses NewOwnerChecker to create Checker instances.

type ClientContext

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

ClientContext bundles the feature of providing injected scheme and client for the controller runtime. Additionally it offers a decoder using the scheme.

func NewClientContext

func NewClientContext(client client.Client, scheme *runtime.Scheme, decoder runtime.Decoder) ClientContext

NewClientContext offers the possibility to create a ClientContext without injection.

func (*ClientContext) Client

func (cc *ClientContext) Client() client.Client

Client returns the rest client of the context

func (*ClientContext) Decoder

func (cc *ClientContext) Decoder() runtime.Decoder

Decoder returns a decoder for the scheme of the context

func (*ClientContext) InjectClient

func (cc *ClientContext) InjectClient(client client.Client) error

InjectClient injects the given client into the context.

func (*ClientContext) InjectScheme

func (cc *ClientContext) InjectScheme(scheme *runtime.Scheme) error

InjectScheme injects the given scheme into the valuesProvider.

func (*ClientContext) Scheme

func (cc *ClientContext) Scheme() *runtime.Scheme

Scheme returns the scheme of the context

type RESTConfigContext

type RESTConfigContext struct {
	ClientContext
	// contains filtered or unexported fields
}

RESTConfigContext extends the ClientContext with the REST config usable to create more specific clients.

func (*RESTConfigContext) InjectConfig

func (cc *RESTConfigContext) InjectConfig(config *rest.Config) error

InjectConfig injects the given REST config into the context.

func (*RESTConfigContext) RESTConfig

func (cc *RESTConfigContext) RESTConfig() *rest.Config

RESTConfig returns the rest config of the context

type Resolver added in v1.33.0

type Resolver interface {
	// LookupTXT returns the DNS TXT records for the given domain name.
	LookupTXT(ctx context.Context, name string) ([]string, error)
}

Resolver looks up domain names and returns the corresponding DNS records.

type Watchdog added in v1.33.0

type Watchdog interface {
	// Start starts a goroutine that regularly checks if a certain condition is true.
	// If the check fails or returns false, it cancels all contexts.
	Start(ctx context.Context)
	// Stop stops the goroutine started by Start.
	Stop()
	// AddContext adds the given context to this watchdog mapped to the given key,
	// and returns a new context that will be cancelled if the condition check fails or returns false.
	// It returns true if the first context has been added, false otherwise.
	AddContext(ctx context.Context, key string) (context.Context, bool)
	// RemoveContext removes the context mapped to the given key from this watchdog.
	// It returns true if the last context has been removed, false otherwise.
	RemoveContext(key string) bool
	// Result returns the result of the last condition check.
	Result() (bool, error)
}

Watchdog manages a goroutine that regularly checks if a certain condition is true, and if the check fails or returns false, cancels multiple previously added contexts.

func NewCheckerWatchdog added in v1.33.0

func NewCheckerWatchdog(checker Checker, interval, timeout time.Duration, clock clock.Clock, logger logr.Logger) Watchdog

NewCheckerWatchdog creates a new Watchdog that checks if the condition checked by the given checker is true every given interval, using the given clock and logger.

type WatchdogFactory added in v1.33.0

type WatchdogFactory interface {
	// NewWatchdog creates a new Watchdog using the given context, client, namespace, and shoot name.
	NewWatchdog(ctx context.Context, c client.Client, namespace, shootName string) (Watchdog, error)
}

WatchdogFactory creates Watchdog instances.

func NewCheckerWatchdogFactory added in v1.33.0

func NewCheckerWatchdogFactory(checkerFactory CheckerFactory, interval, timeout time.Duration, clock clock.Clock, logger logr.Logger) WatchdogFactory

NewCheckerWatchdogFactory creates a new WatchdogFactory that uses NewCheckerWatchdog to create Watchdog instances.

type WatchdogManager added in v1.33.0

type WatchdogManager interface {
	// GetResultAndContext returns the result and context from the watchdog for the given namespace.
	// If the watchdog does not exist yet, it is created using the given context, client, namespace, and shoot name.
	// If the watchdog result is true, the given context is added to the watchdog mapped to the given key,
	// and a cleanup function for properly removing it is also returned.
	GetResultAndContext(ctx context.Context, c client.Client, namespace, shootName, key string) (bool, context.Context, func(), error)
}

WatchdogManager manages Watchdog instances for multiple namespaces.

func GetDefaultOwnerCheckWatchdogManager added in v1.33.0

func GetDefaultOwnerCheckWatchdogManager() WatchdogManager

GetDefaultOwnerCheckWatchdogManager returns the default owner check WatchdogManager.

func NewWatchdogManager added in v1.33.0

func NewWatchdogManager(watchdogFactory WatchdogFactory, ttl time.Duration, clk clock.Clock, logger logr.Logger) WatchdogManager

NewWatchdogManager creates a new WatchdogManager using the given watchdog factory, ttl, and logger.

Directories

Path Synopsis
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.

Jump to

Keyboard shortcuts

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