diff --git a/lib/EventHandler.js b/lib/EventHandler.js index 69b3946..b037dd6 100644 --- a/lib/EventHandler.js +++ b/lib/EventHandler.js @@ -35,9 +35,9 @@ module.exports = class EventHandler { this._logger = params.logger || require('../bunyan-api').createLogger('EventHandler'); if (!(this._kubeResourceMeta && - this._kubeResourceMeta.constructor && - this._kubeResourceMeta.constructor.name === 'KubeResourceMeta' && - this._kubeResourceMeta.hasVerb('watch'))) { + this._kubeResourceMeta.constructor && + this._kubeResourceMeta.constructor.name === 'KubeResourceMeta' && + this._kubeResourceMeta.hasVerb('watch'))) { throw Error('Resource does not support verb "watch"'); } if (!this._kc) { @@ -68,7 +68,7 @@ module.exports = class EventHandler { // Event Handler async eventHandler(data) { let params = { - kubeResourceMeta: this._kubeResourceMeta, + kubeResourceMeta: this._kubeResourceMeta.clone(), eventData: data, kubeClass: this._kc, logger: this._logger, diff --git a/lib/KubeResourceMeta.js b/lib/KubeResourceMeta.js index 16a0c4a..63ebabf 100644 --- a/lib/KubeResourceMeta.js +++ b/lib/KubeResourceMeta.js @@ -27,6 +27,10 @@ module.exports = class KubeResourceMeta { this._logger = require('./bunyan-api').createLogger('KubeResourceMeta'); } + clone() { + return new KubeResourceMeta(this._path, this._resourceMeta, this._kubeApiConfig); + } + uri(options = {}) { let result = `${this._path}`; if (options.watch) { diff --git a/lib/kubeClass.js b/lib/kubeClass.js index 7ecebc7..fda8ca8 100644 --- a/lib/kubeClass.js +++ b/lib/kubeClass.js @@ -246,7 +246,7 @@ module.exports = class KubeClass { if (verb && krm && !krm.hasVerb(verb)) { krm = undefined; } - return krm; + return krm !== undefined ? krm.clone() : krm; } };