Skip to content

Commit

Permalink
fix: supply defaults if the resource meta doesnt have a field (#158)
Browse files Browse the repository at this point in the history
* fix: supply defaults if the resource meta doesnt have a field

* fix: verify var type before returning default
  • Loading branch information
alewitt2 authored Feb 24, 2021
1 parent aa29078 commit 00c46b7
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;
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 00c46b7

Please sign in to comment.