Skip to content

Commit

Permalink
fix: verify var type before returning default
Browse files Browse the repository at this point in the history
  • Loading branch information
alewitt2 committed Feb 24, 2021
1 parent ec39404 commit 2a253ef
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions lib/KubeResourceMeta.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,19 @@ module.exports = class KubeResourceMeta {
return this._resourceMeta;
}
get name() {
return this._resourceMeta.name || '';
return (typeof this._resourceMeta.name === 'string') ? this._resourceMeta.name : '';
}
get singularName() {
return this._resourceMeta.singularName || '';
return (typeof this._resourceMeta.singularName === 'string') ? this._resourceMeta.singularName : '';
}
get namespaced() {
return this._resourceMeta.namespaced || false;
return (typeof this._resourceMeta.namespaced === 'boolean') ? this._resourceMeta.namespaced : false;
}
get kind() {
return this._resourceMeta.kind || '';
return (typeof this._resourceMeta.kind === 'string') ? this._resourceMeta.kind : '';
}
get verbs() {
return this._resourceMeta.verbs || [];
return Array.isArray(this._resourceMeta.verbs) ? this._resourceMeta.verbs : [];
}
get kubeApiConfig() {
return this._kubeApiConfig;
Expand All @@ -75,11 +75,7 @@ module.exports = class KubeResourceMeta {
}

hasVerb(verb) {
let result=false;
if (Array.isArray(this.verbs)){
result=this.verbs.some(v => verb == v);
}
return result;
return this.verbs.some(v => verb == v);
}
addHeader(key, value) {
objectPath.set(this._extraHeaders, ['headers', key], value);
Expand Down

0 comments on commit 2a253ef

Please sign in to comment.