k8ts
Version:
Powerful framework for building Kubernetes manifests in TypeScript.
82 lines • 2.43 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Pod_Volume_Secret = exports.Pod_Volume_ConfigMap = exports.Pod_Volume_Pvc = exports.Pod_Volume = void 0;
const instruments_1 = require("@k8ts/instruments");
const default_1 = require("../../../kinds/default");
const mounts_1 = require("../container/mounts");
const allowedVolumeResourceKinds = [default_1.v1.ConfigMap._, default_1.v1.Secret._];
class Pod_Volume extends instruments_1.Resource_Child {
get kind() {
return default_1.v1.Pod.Volume._;
}
get sourceNamespace() {
const backend = this.props.$backend;
return backend.namespace;
}
__needs__() {
return {
backend: this.props.$backend
};
}
Mount(options) {
return new mounts_1.Container_Mount_Volume({
volume: this,
...options
});
}
}
exports.Pod_Volume = Pod_Volume;
class Pod_Volume_Pvc extends Pod_Volume {
__submanifest__() {
return {
name: this.name,
persistentVolumeClaim: {
claimName: this.props.$backend.name,
readOnly: this.props.readOnly
}
};
}
}
exports.Pod_Volume_Pvc = Pod_Volume_Pvc;
function mappingsToKeyPaths(input) {
const mappings = input;
const arr = Object.entries(mappings).map(([key, value]) => {
return {
key: key,
path: value
};
});
if (arr.length === 0) {
return undefined;
}
return arr;
}
class Pod_Volume_ConfigMap extends Pod_Volume {
__submanifest__() {
const mappings = mappingsToKeyPaths(this.props.mappings ?? {});
return {
name: this.name,
configMap: {
name: this.props.$backend.name,
optional: this.props.optional,
items: mappings
}
};
}
}
exports.Pod_Volume_ConfigMap = Pod_Volume_ConfigMap;
class Pod_Volume_Secret extends Pod_Volume {
__submanifest__() {
const mappings = mappingsToKeyPaths(this.props.mappings ?? {});
return {
name: this.name,
secret: {
secretName: this.props.$backend.name,
optional: this.props.optional,
items: mappings
}
};
}
}
exports.Pod_Volume_Secret = Pod_Volume_Secret;
//# sourceMappingURL=volumes.js.map