generator

package
v0.0.0-...-f54f72f Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2024 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanupProjects

func CleanupProjects(ctx context.Context, c client.Client, labels map[string]string) error

CleanupProjects deletes all namespaces with the given labels.

func CreateClusterScopedOwnerObject

func CreateClusterScopedOwnerObject(ctx context.Context, c client.Client, opts ...GenerateOption) (client.Object, *metav1.OwnerReference, error)

CreateClusterScopedOwnerObject creates a new cluster-scoped object that has a single purpose: being used as an owner for multiple objects that should be cleaned up at once. This is useful for cleaning up a lot of objects (of different kinds) at once with a single DELETE call.

func CreateProject

func CreateProject(ctx context.Context, c client.Client, opts ...GenerateOption) error

CreateProject creates a random project namespace.

func CreateProjects

func CreateProjects(ctx context.Context, c client.Client, n int, opts ...GenerateOption) error

CreateProjects creates n random project namespaces.

func CreateTheme

func CreateTheme(ctx context.Context, c client.Client, opts ...GenerateOption) error

CreateTheme creates a random theme.

func CreateThemes

func CreateThemes(ctx context.Context, c client.Client, n int, opts ...GenerateOption) error

CreateThemes creates n random themes.

func CreateWebsite

func CreateWebsite(ctx context.Context, c client.Client, opts ...GenerateOption) error

CreateWebsite creates a random website.

func CreateWebsites

func CreateWebsites(ctx context.Context, c client.Client, n int, opts ...GenerateOption) error

CreateWebsites creates n random websites.

func DeleteWebsite

func DeleteWebsite(ctx context.Context, c client.Client, labels map[string]string) error

DeleteWebsite deletes a random existing website using the given client and labels.

func EmitN

func EmitN(n int) source.Source

EmitN returns a source that emits exactly n events (reconcile.Request). The source ignores predicates. Use it with the controller builder:

WatchesRawSource(EmitN(n), &handler.EnqueueRequestForObject{})

Or a plain controller:

Watch(EmitN(n), &handler.EnqueueRequestForObject{})

func MutateRandomTheme

func MutateRandomTheme(ctx context.Context, c client.Client, labels map[string]string) error

MutateRandomTheme mutates a random existing theme using the given client and labels.

func MutateTheme

func MutateTheme(ctx context.Context, c client.Client, theme *webhostingv1alpha1.Theme) error

MutateTheme mutates the given theme using the given client and labels.

func MutateWebsite

func MutateWebsite(ctx context.Context, c client.Client, website *webhostingv1alpha1.Website, labels map[string]string) error

MutateWebsite mutates the given website using the given client and labels.

func NTimesConcurrently

func NTimesConcurrently(n, workers int, do func() error) error

NTimesConcurrently runs the given action n times. It distributes the work across the given number of concurrent workers.

func ReconcileWebsite

func ReconcileWebsite(ctx context.Context, c client.Client, website *webhostingv1alpha1.Website) error

ReconcileWebsite triggers reconciliation of the given website by updating an annotation.

func RetryOnError

func RetryOnError(ctx context.Context, retries int, do func(context.Context) error, retriable func(error) bool) error

RetryOnError runs the given action with a short timeout and retries it up to `retries` times if it retruns a retriable error. This is useful when creating a lot of objects in parallel with generateName which can lead to AlreadyExists errors.

func SetWebsiteTracker

func SetWebsiteTracker(tracker WebsiteTracker)

SetWebsiteTracker sets up this package to track website creations and spec updates with the given tracker.

func StopOnContextCanceled

func StopOnContextCanceled(r reconcile.Reconciler) reconcile.Reconciler

StopOnContextCanceled wraps the given reconciler so that "context canceled" errors are ignored. This is helpful when a reconciler is expected to be canceled (e.g., when the scenario finishes). We neither need to retry nor log on such errors. We can just stop silently.

Types

type Every

type Every struct {
	client.Client

	Name    string
	Do      func(ctx context.Context, c client.Client) error
	Rate    rate.Limit
	Stop    time.Time
	Workers int
}

Every runs the given Func with the specified frequency.

func (*Every) AddToManager

func (r *Every) AddToManager(mgr manager.Manager) error

func (*Every) Reconcile

func (r *Every) Reconcile(ctx context.Context, _ reconcile.Request) (reconcile.Result, error)

type ForEach

type ForEach[T client.Object] struct {
	client.Client

	Name    string
	Do      func(ctx context.Context, c client.Client, obj T) error
	Every   time.Duration
	Stop    time.Time
	Workers int
	// contains filtered or unexported fields
}

ForEach runs the given Func for each object of the given kind with the specified frequency. The first execution runs Every after object creation.

func (*ForEach[T]) AddToManager

func (r *ForEach[T]) AddToManager(mgr manager.Manager) error

func (*ForEach[T]) Reconcile

func (r *ForEach[T]) Reconcile(ctx context.Context, request reconcile.Request) (reconcile.Result, error)

type GenerateOption

type GenerateOption interface {
	ApplyToOptions(options *GenerateOptions)
}

func WithLabels

func WithLabels(labels map[string]string) GenerateOption

func WithOwnerReference

func WithOwnerReference(ownerRef *metav1.OwnerReference) GenerateOption

type GenerateOptionFunc

type GenerateOptionFunc func(options *GenerateOptions)

func (GenerateOptionFunc) ApplyToOptions

func (f GenerateOptionFunc) ApplyToOptions(options *GenerateOptions)

type GenerateOptions

type GenerateOptions struct {
	Labels         map[string]string
	OwnerReference *metav1.OwnerReference
}

func (*GenerateOptions) ApplyOptions

func (o *GenerateOptions) ApplyOptions(opts ...GenerateOption) *GenerateOptions

func (*GenerateOptions) ApplyToObject

func (o *GenerateOptions) ApplyToObject(obj *metav1.ObjectMeta)

func (*GenerateOptions) ApplyToOptions

func (o *GenerateOptions) ApplyToOptions(options *GenerateOptions)

type WebsiteTracker

type WebsiteTracker interface {
	RecordSpecChange(website *webhostingv1alpha1.Website)
}

Jump to

Keyboard shortcuts

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