package recerr import corev1 "k8s.io/api/core/v1" // Option is a public error option that can be used to customize some of the // [Base] error's behavior. type Option func(*options) type options struct { notification bool eventType string } // WithoutNotification forces a reconciliation error to not result in a K8s // event notifiation. // // NOTE: All corev1.EventTypeWarning events will result in a notification func WithoutNotification() Option { return func(o *options) { o.notification = false } } // WithEvent sets the event type that should be used for the error. Some // specialized errors, like Stalled, set an appropriate Event type by default. // This [Option] can be used to configure generic reconcile errors or override // the behavior of specialized errors. func WithEvent(eventType string) Option { return func(o *options) { o.eventType = eventType } } func makeOptions(o *options, opts ...Option) *options { if o.eventType == "" { o.eventType = corev1.EventTypeWarning } for _, opt := range opts { opt(o) } return o }