Documentation ¶
Index ¶
- func CleanupProjects(ctx context.Context, c client.Client, labels map[string]string) error
- func CreateClusterScopedOwnerObject(ctx context.Context, c client.Client, opts ...GenerateOption) (client.Object, *metav1.OwnerReference, error)
- func CreateProject(ctx context.Context, c client.Client, opts ...GenerateOption) error
- func CreateProjects(ctx context.Context, c client.Client, n int, opts ...GenerateOption) error
- func CreateTheme(ctx context.Context, c client.Client, opts ...GenerateOption) error
- func CreateThemes(ctx context.Context, c client.Client, n int, opts ...GenerateOption) error
- func CreateWebsite(ctx context.Context, c client.Client, opts ...GenerateOption) error
- func CreateWebsites(ctx context.Context, c client.Client, n int, opts ...GenerateOption) error
- func DeleteWebsite(ctx context.Context, c client.Client, labels map[string]string) error
- func EmitN(n int) source.Source
- func MutateRandomTheme(ctx context.Context, c client.Client, labels map[string]string) error
- func MutateTheme(ctx context.Context, c client.Client, theme *webhostingv1alpha1.Theme) error
- func MutateWebsite(ctx context.Context, c client.Client, website *webhostingv1alpha1.Website, ...) error
- func NTimesConcurrently(n, workers int, do func() error) error
- func ReconcileWebsite(ctx context.Context, c client.Client, website *webhostingv1alpha1.Website) error
- func RetryOnError(ctx context.Context, retries int, do func(context.Context) error, ...) error
- func SetWebsiteTracker(tracker WebsiteTracker)
- func StopOnContextCanceled(r reconcile.Reconciler) reconcile.Reconciler
- type Every
- type ForEach
- type GenerateOption
- type GenerateOptionFunc
- type GenerateOptions
- type WebsiteTracker
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CleanupProjects ¶
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 ¶
CreateProject creates a random project namespace.
func CreateProjects ¶
CreateProjects creates n random project namespaces.
func CreateTheme ¶
CreateTheme creates a random theme.
func CreateThemes ¶
CreateThemes creates n random themes.
func CreateWebsite ¶
CreateWebsite creates a random website.
func CreateWebsites ¶
CreateWebsites creates n random websites.
func DeleteWebsite ¶
DeleteWebsite deletes a random existing website using the given client and labels.
func EmitN ¶
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 ¶
MutateRandomTheme mutates a random existing theme using the given client and labels.
func MutateTheme ¶
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 ¶
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.
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.
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)
}