Skip to content

Commit

Permalink
Merge pull request #3609 from twz123/inttest-fix-watcher
Browse files Browse the repository at this point in the history
Add label selector also when watching
  • Loading branch information
twz123 authored Oct 20, 2023
2 parents f7f6811 + 0c54d39 commit b4b02b0
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pkg/kubernetes/watch/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func (w *Watcher[T]) WithObjectName(name string) *Watcher[T] {
// [Kubernetes codebase].
//
// [concept]: https://kubernetes.io/docs/concepts/overview/working-with-objects/field-selectors/
// [Kubernetes codebase]: https://sourcegraph.com/search?q=lang:go+AddFieldLabelConversionFunc(...)+repo:^github\.com/kubernetes/kubernetes%24+-file:_test\.go%24+select:content&patternType=structural
// [Kubernetes codebase]: https://sourcegraph.com/search?q=lang:go+AddFieldLabelConversionFunc%28...%29+repo:%5Egithub%5C.com/kubernetes/kubernetes%24+-file:_test%5C.go%24+select:content&patternType=structural
func (w *Watcher[T]) WithFieldSelector(selector fields.Selector) *Watcher[T] {
w.fieldSelector = selector.String()
return w
Expand Down Expand Up @@ -288,6 +288,7 @@ func (w *Watcher[T]) watch(ctx context.Context, resourceVersion string, conditio
ResourceVersion: resourceVersion,
AllowWatchBookmarks: true,
FieldSelector: w.fieldSelector,
LabelSelector: w.labelSelector,
TimeoutSeconds: pointer.Int64(maxWatchDurationSecs),
})
if err != nil {
Expand Down

0 comments on commit b4b02b0

Please sign in to comment.