package kpoll import ( "context" "sigs.k8s.io/controller-runtime/pkg/client" ) // CheckOption controls the behavior of a check against a cluster via an instance // of [KPoll]. type CheckOption = func(*checkOpts) type checkOpts struct { client client.Client fetch bool ctx context.Context } // WithClient sets the client that will be used while evaluating checks. func WithClient(c client.Client) CheckOption { return func(o *checkOpts) { o.client = c } } // WithoutFetch causes Checks to be evaluated without fetching latest live state // from API. // // This can be useful if your test logic needs to take full control over the // fetching process, or if you need to write a check based on the error value // returned from Get(): // // k.WaitOn(t, func(t poll.LogT) poll.Result { // // Fetch object with custom Get options, etc // return k.Compare(obj, myComparison, kpoll.WithoutFetch()) // }) func WithoutFetch() CheckOption { return func(o *checkOpts) { o.fetch = false } } // WithContext overrides the [context.Context] for the check. By default, the // context used to instantiate the poller is used. func WithContext(ctx context.Context) CheckOption { return func(o *checkOpts) { o.ctx = ctx } }