Skip to content

Commit

Permalink
Allow to pass watcher strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
ash2k committed Mar 16, 2023
1 parent 7a6572a commit 73518bb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion pkg/apply/applier.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,8 @@ func (a *Applier) Run(ctx context.Context, invInfo inventory.Info, objects objec
runner := taskrunner.NewTaskStatusRunner(allIds, statusWatcher)
klog.V(4).Infoln("applier running TaskStatusRunner...")
err = runner.Run(ctx, taskContext, taskQueue.ToChannel(), taskrunner.Options{
EmitStatusEvents: options.EmitStatusEvents,
EmitStatusEvents: options.EmitStatusEvents,
WatcherRESTScopeStrategy: options.WatcherRESTScopeStrategy,
})
if err != nil {
handleError(eventChannel, err)
Expand Down Expand Up @@ -288,6 +289,10 @@ type ApplierOptions struct {

// ValidationPolicy defines how to handle invalid objects.
ValidationPolicy validation.Policy

// RESTScopeStrategy specifies which strategy to use when listing and
// watching resources. By default, the strategy is selected automatically.
WatcherRESTScopeStrategy watcher.RESTScopeStrategy
}

// setDefaults set the options to the default values if they
Expand Down
7 changes: 6 additions & 1 deletion pkg/apply/taskrunner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ type TaskStatusRunner struct {
// the statusPoller.
type Options struct {
EmitStatusEvents bool
// RESTScopeStrategy specifies which strategy to use when listing and
// watching resources. By default, the strategy is selected automatically.
WatcherRESTScopeStrategy watcher.RESTScopeStrategy
}

// Run executes the tasks in the taskqueue, with the statusPoller running in the
Expand All @@ -57,7 +60,9 @@ func (tsr *TaskStatusRunner) Run(
// If taskStatusRunner.Run is cancelled, baseRunner.run will exit early,
// causing the poller to be cancelled.
statusCtx, cancelFunc := context.WithCancel(context.Background())
statusChannel := tsr.StatusWatcher.Watch(statusCtx, tsr.Identifiers, watcher.Options{})
statusChannel := tsr.StatusWatcher.Watch(statusCtx, tsr.Identifiers, watcher.Options{
RESTScopeStrategy: opts.WatcherRESTScopeStrategy,
})

// complete stops the statusPoller, drains the statusChannel, and returns
// the provided error.
Expand Down

0 comments on commit 73518bb

Please sign in to comment.