Skip to content

Commit 0b45abb

Browse files
mjudeikis-botmjudeikis
authored andcommitted
refactor: use ptr.Deref for SendInitialEvents nil check in unwrappingWatch
Simplify the SendInitialEvents nil-check using ptr.Deref from k8s.io/utils/ptr, which handles the nil pointer dereference idiom more readably. Suggested-by: ntnn Follows-up: kcp-dev#3875 Co-authored-by: Mangirdas Judeikis <mangirdas@judeikis.lt> Signed-off-by: mjudeikis-bot <mjudeikis-bot@faros.sh> Signed-off-by: Mangirdas Judeikis <mangirdas@judeikis.lt>
1 parent 32e8b9b commit 0b45abb

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

pkg/virtual/replication/builder/unwrap.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import (
3939
"k8s.io/apiserver/pkg/storage"
4040
storageerrors "k8s.io/apiserver/pkg/storage/errors"
4141
clientgocache "k8s.io/client-go/tools/cache"
42+
"k8s.io/utils/ptr"
4243

4344
"github.com/kcp-dev/logicalcluster/v3"
4445
apisv1alpha1 "github.com/kcp-dev/sdk/apis/apis/v1alpha1"
@@ -444,7 +445,7 @@ func newUnwrappingWatch(
444445
// existing items. Clients using WatchList (sendInitialEvents=true) expect a
445446
// BOOKMARK with the k8s.io/initial-events-end annotation to signal that the
446447
// initial state has been fully delivered.
447-
if innerListOpts != nil && innerListOpts.SendInitialEvents != nil && *innerListOpts.SendInitialEvents && innerListOpts.AllowWatchBookmarks {
448+
if innerListOpts != nil && ptr.Deref(innerListOpts.SendInitialEvents, false) && innerListOpts.AllowWatchBookmarks {
448449
go func() {
449450
if !clientgocache.WaitForCacheSync(ctx.Done(), handler.HasSynced) {
450451
return

0 commit comments

Comments
 (0)