Skip to content

Commit 71cb77f

Browse files
committed
Alias functional options
1 parent 1247a4d commit 71cb77f

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

pkg/cache/cache.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,15 @@ var (
4444
defaultSyncPeriod = 10 * time.Hour
4545
)
4646

47+
type InformerGetOptions internal.GetOptions
48+
4749
// InformerGetOption defines an option that alters the behavior of how informers are retrieved.
48-
type InformerGetOption func(*internal.GetOptions)
50+
type InformerGetOption func(*InformerGetOptions)
4951

5052
// BlockUntilSynced determines whether a get request for an informer should block
5153
// until the informer's cache has synced.
5254
func BlockUntilSynced(shouldBlock bool) InformerGetOption {
53-
return func(opts *internal.GetOptions) {
55+
return func(opts *InformerGetOptions) {
5456
opts.BlockUntilSynced = &shouldBlock
5557
}
5658
}

pkg/cache/informer_cache.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,11 @@ func (ic *informerCache) objectTypeForListObject(list client.ObjectList) (*schem
142142
}
143143

144144
func applyGetOptions(opts ...InformerGetOption) *internal.GetOptions {
145-
cfg := &internal.GetOptions{}
145+
cfg := &InformerGetOptions{}
146146
for _, opt := range opts {
147147
opt(cfg)
148148
}
149-
return cfg
149+
return (*internal.GetOptions)(cfg)
150150
}
151151

152152
// GetInformerForKind returns the informer for the GroupVersionKind. If no informer exists, one will be started.

pkg/cache/internal/informers.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,8 @@ func (ip *Informers) Get(ctx context.Context, gvk schema.GroupVersionKind, obj r
267267
}
268268

269269
shouldBlock := true
270-
if cfg.BlockUntilSynced != nil {
271-
shouldBlock = *cfg.BlockUntilSynced
270+
if opts.BlockUntilSynced != nil {
271+
shouldBlock = *opts.BlockUntilSynced
272272
}
273273

274274
if shouldBlock && started && !i.Informer.HasSynced() {

0 commit comments

Comments
 (0)