@k8ts/instruments
Version:
A collection of utilities and core components for k8ts.
37 lines • 1.16 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.parsePortInput = parsePortInput;
exports.portRecordInput = portRecordInput;
const immutable_1 = require("immutable");
const _ip_1 = require("../../_ip");
const set_1 = require("../set");
const parse_1 = require("./parse");
function portSetEntry(name, value) {
return {
name,
port: value.port,
protocol: value.protocol.toUpperCase(),
hostIp: value.hostIp ? new _ip_1.Ip4(value.hostIp) : undefined,
hostPort: value.hostPort
};
}
function parsePortInput(name, input) {
if (typeof input === "string") {
return portSetEntry(name, (0, parse_1.parsePortSpec)(name, input));
}
if (typeof input === "number") {
return portSetEntry(name, {
port: input,
protocol: "TCP"
});
}
return portSetEntry(name, input);
}
function portRecordInput(record) {
if (record instanceof set_1.PortSet) {
return record.values;
}
const inputMap = (0, immutable_1.Map)(record);
return inputMap.map((v, k) => parsePortInput(k, v));
}
//# sourceMappingURL=entry.js.map