function getExternalSecretEvents ({
  kubeClient,
  watchedNamespaces,
  customResourceManifest,
  logger,
  watchTimeout
}) {
  return (async function * () {
    const eventQueue = createEventQueue()

    // If the watchedNamespaces is set create a watcher for each namespace, otherwise create a watcher for all namespaces.
    if (watchedNamespaces.length) {
      // Create watcher for each namespace
      watchedNamespaces.forEach((namespace) => {
        startWatcher({
          namespace,
          kubeClient,
          customResourceManifest,
          logger,
          eventQueue,
          watchTimeout
        })
      })
    } else {
      startWatcher({
        kubeClient,
        customResourceManifest,
        logger,
        eventQueue,
        watchTimeout
      })
    }

    while (true) {
      yield await eventQueue.take()
    }
  }())
}
Get a stream of external secret events. This implementation uses
watch and yields as a stream of events.
@param {Object} kubeClient - Client for interacting with kubernetes cluster.
@param {Array} watchedNamespaces - List of scoped namespaces.
@param {Object} customResourceManifest - Custom resource manifest.
@returns {Object} An async generator that yields externalsecret events.