UNPKG

@catladder/pipeline

Version:

Panter workflow for cloud CI/CD and DevOps

82 lines (81 loc) 2.57 kB
"use strict"; var __read = this && this.__read || function (o, n) { var m = typeof Symbol === "function" && o[Symbol.iterator]; if (!m) return o; var i = m.call(o), r, ar = [], e; try { while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); } catch (error) { e = { error: error }; } finally { try { if (r && !r.done && (m = i["return"])) m.call(i); } finally { if (e) throw e.error; } } return ar; }; var __spreadArray = this && this.__spreadArray || function (to, from, pack) { if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { if (ar || !(i in from)) { if (!ar) ar = Array.prototype.slice.call(from, 0, i); ar[i] = from[i]; } } return to.concat(ar || Array.prototype.slice.call(from)); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.healthCheckCliArgs = void 0; var types_1 = require("../../types"); var PORT = 8080; function healthCheckCliArgs(healthCheck) { var shouldNotSetHealthCheck = healthCheck === undefined; if (shouldNotSetHealthCheck) { return undefined; } var shouldUseDefaultProbe = healthCheck === true; if (shouldUseDefaultProbe) { return { "startup-probe": toArgValue(probeToKeyValuePairs(types_1.defaultStartupProbe)), "liveness-probe": toArgValue(probeToKeyValuePairs(types_1.defaultLivenessProbe)) }; } return { "startup-probe": toArgValue(probeToKeyValuePairs(healthCheck.startupProbe)), "liveness-probe": healthCheck.livenessProbe ? toArgValue(probeToKeyValuePairs(healthCheck.livenessProbe)) : "" // NOTE: empty string ("") removes liveness probe }; } exports.healthCheckCliArgs = healthCheckCliArgs; function probeToKeyValuePairs(probe) { var sharedArgs = Object.entries({ initialDelaySeconds: probe.initialDelaySeconds, timeoutSeconds: probe.timeoutSeconds, periodSeconds: probe.periodSeconds, failureThreshold: probe.failureThreshold }); switch (probe.type) { case "tcp": return __spreadArray(__spreadArray([], __read(sharedArgs), false), [["tcpSocket.port", PORT]], false); case "http1": return __spreadArray(__spreadArray([], __read(sharedArgs), false), [["httpGet.port", PORT], ["httpGet.path", probe.path]], false); default: probe; return []; } } function toArgValue(keyValues) { return keyValues.map(function (_a) { var _b = __read(_a, 2), key = _b[0], value = _b[1]; return "".concat(key, "=").concat(value); }).join(","); }