{"modulePath":"github.com/AlaudaDevops/pkg","version":"v0.14.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package controllers\n\nPackage controllers implements the lazy loader logic for Katanomi.\n\nPackage controllers implements the lazy loader logic for Katanomi.\n\nPackage controllers implements the lazy loader logic for Katanomi.\n\n## Constants\n\n```go\nconst DefaultMaxConcurrentReconciles = 10\n```\nDefaultMaxConcurrentReconciles is the default number of max concurrent reconciles\n\n```go\nconst (\n\t// MessageShortenLength default message shorten length in event\n\tMessageShortenLength = 1000\n)\n```\n\n## Functions\n\n```go\nfunc ApplyControllerBuilderOptions(builder *builder.Builder, funcs ...ControllerBuilderOption) *builder.Builder\n```\nApplyControllerBuilderOptions applies the given options to the controller builder\n\n```go\nfunc BuilderOptions(opts ...BuilderOptionFunc) controller.Options\n```\nBuilderOptions returns a functional set of options with conservative defaults.\n\n```go\nfunc CreateOrGetWithRetry(ctx context.Context, clt client.Client, obj client.Object) error\n```\nCreateOrGetWithRetry will retry to create source multi times if encounter error however if error is alreadyExist then will get the resource and return it\n\n```go\nfunc DefaultOptions() controller.Options\n```\nDefaultOptions returns the default options for the controller\n\n```go\nfunc DefaultRateLimiter() workqueue.RateLimiter\n```\nDefaultRateLimiter returns a workqueue rate limiter with a starting value of 2 seconds opposed to controller-runtime's default one of 1 millisecond Deprecated: DefaultRateLimiter is deprecated, use DefaultTypedRateLimiter instead.\n\n```go\nfunc DefaultTypedRateLimiter[T comparable]() workqueue.TypedRateLimiter[T]\n```\nDefaultTypedRateLimiter returns a workqueue rate limiter with a starting value of 2 seconds opposed to controller-runtime's default one of 1 millisecond\n\n```go\nfunc GetNumRequeues(ctx context.Context) int\n```\nGetNumRequeues gets numRequeue from the context\n\n```go\nfunc HasControllerReferenceByObjectReference(obj metav1.Object, ref *corev1.ObjectReference, controller bool) bool\n```\nHasControllerReferenceByObjectReference has controller owner reference\n\n```go\nfunc NewReconcilerWrapper(r reconcile.Reconciler, opts ...WrapperOption) reconcile.Reconciler\n```\nNewReconcilerWrapper creates a new scheduleReconciler with the provided Reconciler and ScheduleOptions.\n\n```go\nfunc RateLimiterCtx(ctx context.Context) workqueue.RateLimiter\n```\nRateLimiterCtx retrieves a RateLimiter from context. Returns nil if none\n\n```go\nfunc ReconcileRequestCtx(ctx context.Context) ctrl.Request\n```\nReconcileRequestCtx retrieves a Request key from context returns an empty object if none\n\n```go\nfunc TypedRateLimiter[T comparable](baseDelay time.Duration, maxDelay time.Duration) workqueue.TypedRateLimiter[T]\n```\nTypedRateLimiter returns a workqueue rate limiter with value of baseDelay and maxDelay opposed to controller-runtime's default one of 1 millisecond\n\n```go\nfunc WithNumRequeues(ctx context.Context, num int) context.Context\n```\nWithNumRequeues adds the numRequeues to the context\n\n```go\nfunc WithRateLimiter(ctx context.Context, rl workqueue.RateLimiter) context.Context\n```\nWithRateLimiter stores a RateLimiter into context\n\n```go\nfunc WithReconcileRequest(ctx context.Context, key ctrl.Request) context.Context\n```\nWithReconcileRequest stores a Request key into context\n\n## Types\n\n```go\ntype AnnotationChangedPredicate struct {\n\t// Keys is a list of annotation keys to watch for changes.\n\t// If empty, all annotation changes will be considered.\n\tKeys []string\n\tpredicate.AnnotationChangedPredicate\n}\n```\nAnnotationChangedPredicate implements a predicate that checks for changes in specific annotations. It extends the default AnnotationChangedPredicate from controller-runtime and allows filtering on specific annotation keys.\n\n```go\nfunc (p AnnotationChangedPredicate) Create(e event.CreateEvent) bool\n```\nCreate implements Predicate interface for creation events. It checks if any of the specified annotation keys have changed from nil to a value.\n\n```go\nfunc (p AnnotationChangedPredicate) Delete(e event.DeleteEvent) bool\n```\nDelete implements Predicate interface for deletion events. It checks if any of the specified annotation keys have changed from a value to nil.\n\n```go\nfunc (p AnnotationChangedPredicate) Generic(e event.GenericEvent) bool\n```\nGeneric implements Predicate interface for generic events. It checks if any of the specified annotation keys have changed.\n\n```go\nfunc (p AnnotationChangedPredicate) Update(e event.UpdateEvent) bool\n```\nUpdate implements Predicate interface for update events. It checks if any of the specified annotation keys have different values between old and new objects.\n\n```go\ntype BuilderOptionFunc func(options controller.Options) controller.Options\n```\nBuilderOptionFunc is a function that can be used to configure the controller builder options\n\n```go\nfunc MaxConCurrentReconciles(num int) BuilderOptionFunc\n```\nMaxConCurrentReconciles sets the max concurrent reconciles\n\n```go\nfunc RateLimiter(rl workqueue.TypedRateLimiter[reconcile.Request]) BuilderOptionFunc\n```\nRateLimiter sets the rate limiter\n\n```go\ntype ControllerBuilderOption func(*builder.Builder) *builder.Builder\n```\nControllerBuilderOption is a function that can be used to configure the controller builder\n\n```go\nfunc WithBuilderOptions(opts controller.Options) ControllerBuilderOption\n```\nWithBuilderOptions returns a ControllerBuilderOption that applies the given options to the controller builder\n\n```go\ntype ControllerChecker interface {\n\tDependencyCheckerInterface\n\tSetupChecker\n}\n```\n\n```go\ntype ControllerManager struct {\n\tctrl.Manager\n}\n```\nControllerManager is just like sigs.k8s.io/controller-runtime.Manager and decorate GetEventRecorderFor function to shorten message length\n\n```go\nfunc (m ControllerManager) GetEventRecorderFor(name string) cliengorecord.EventRecorder\n```\nGetEventRecorderFor is just like sigs.k8s.io/controller-runtime.Manager.GetEventRecorderFor but will return EventRecorder that could shorten message length\n\n```go\ntype DependencyCheckerInterface interface {\n\tDependentCrdInstalled(ctx context.Context, logger *zap.SugaredLogger) (bool, error)\n}\n```\nDependencyCheckerInterface is the interface for checking dependencies\n\n```go\ntype EventRecorder struct {\n\tcliengorecord.EventRecorder\n\n\t// MessageShortenLen indicates max event message length, it will be shortened if length is more than MessageShortenLen\n\tMessageShortenLen int\n}\n```\nEventRecorder is just like k8s.io/client-go/tools/record.EventRecorder, but will shorten message length according to MessageShortenLen\n\n```go\nfunc (recorder *EventRecorder) AnnotatedEventf(object runtime.Object, annotations map[string]string, eventtype, reason, messageFmt string, args ...interface{})\n```\nAnnotatedEventf is same as k8s.io/client-go/tools/record.EventRecorder.Eventf, just shorten args filed if the field type is Stringer or Error\n\n```go\nfunc (recorder *EventRecorder) Event(object runtime.Object, eventtype, reason, message string)\n```\nEvent is same as k8s.io/client-go/tools/record.EventRecorder.Event, just shorten message filed\n\n```go\nfunc (recorder *EventRecorder) Eventf(object runtime.Object, eventtype, reason, messageFmt string, args ...interface{})\n```\nEventf is same as k8s.io/client-go/tools/record.EventRecorder.Eventf, just shorten args filed if the field type is Stringer or Error\n\n```go\ntype Interface interface {\n\tName() string\n\tSetup(context.Context, manager.Manager, *zap.SugaredLogger) error\n}\n```\nInterface is a basic interface that every reconciler should implement to create a new controller and startup in the controller manager\n\n```go\ntype LazyLoader interface {\n\tLazyLoad(context.Context, manager.Manager, *zap.SugaredLogger, SetupChecker) error\n\tStart(context.Context) error\n}\n```\nLazyLoader loads whenever dependencies are ready\n\n```go\nfunc NewLazyLoader(ctx context.Context, interval time.Duration) LazyLoader\n```\nNewLazyLoader constructs new LazyLoader for controllers\n\n```go\ntype RequestFunc func(ctx context.Context, request reconcile.Request) (context.Context, error)\n```\n\n```go\ntype ResultFunc func(ctx context.Context, request reconcile.Request, result *reconcile.Result) error\n```\n\n```go\nfunc SyncPeriodResultFunc(manager *config.Manager, configKey string) ResultFunc\n```\nSyncPeriodResultFunc contruct reconcile.Result to requeue automatically the RequeueAfter value is set by configKey in \\`FeatureFlag\\`\n\n```go\ntype SecretDataChangedPredicate struct {\n\tpredicate.Funcs\n}\n```\nSecretDataChangedPredicate implements a default update predicate function on secret data change.\n\n```go\nfunc (SecretDataChangedPredicate) Update(e event.UpdateEvent) bool\n```\nUpdate implements default UpdateEvent filter for validating generation change.\n\n```go\ntype SetupChecker interface {\n\tInterface\n\tCheckSetup(context.Context, manager.Manager, *zap.SugaredLogger) error\n}\n```\nSetupChecker controllers with dependencies on other resources will need to implement this interface to allow lazy loading\n\n```go\ntype WrapperOption func(*WrapperOptions)\n```\n\n```go\ntype WrapperOptions struct {\n\t// define the synchronization interval.\n\tRequestFuncs []RequestFunc\n\tResultFuncs  []ResultFunc\n\tObject       client.Object\n\tClient       client.Client\n}\n```\n\n","path":"github.com/AlaudaDevops/pkg/controllers","name":"controllers","synopsis":"Package controllers implements the lazy loader logic for Katanomi.","isRedistributable":true}
