@controlplane/cli
Version:
Control Plane Corporation CLI
41 lines • 1.38 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.K8sConfigMapHandler = void 0;
const helper_1 = require("../../util/helper");
class K8sConfigMapHandler {
constructor(filePath, k8sConfigMap) {
this.filePath = filePath;
this.k8sConfigMap = k8sConfigMap;
this.secret = {
kind: 'secret',
type: 'dictionary',
tags: k8sConfigMap.metadata.labels,
name: k8sConfigMap.metadata.name,
};
}
/*** Public Methods ***/
handle() {
// Validate ConfigMap
this.validate();
// At least one should be defined because of the previous validation
this.secret.data = {
...(this.k8sConfigMap.data || {}),
...(this.k8sConfigMap.binaryData || {}),
};
return this.secret;
}
/*** Private Methods ***/
// Validators //
validate() {
// At least one of the properties below must be defined
if (!this.k8sConfigMap.data && !this.k8sConfigMap.binaryData) {
this.ensurePropertyPresence('data');
}
}
// Validation Helpers //
ensurePropertyPresence(property) {
(0, helper_1.ensurePropertyPresence)(property, this.filePath, this.k8sConfigMap);
}
}
exports.K8sConfigMapHandler = K8sConfigMapHandler;
//# sourceMappingURL=configmap.js.map