UNPKG

@catladder/cli

Version:

Panter cli tool for cloud CI/CD and DevOps

51 lines 1.87 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.healthCheckCliArgs = void 0; const types_1 = require("../../types"); const PORT = 8080; function healthCheckCliArgs(healthCheck) { const shouldNotSetHealthCheck = healthCheck === undefined; if (shouldNotSetHealthCheck) { return undefined; } const 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) { const sharedArgs = Object.entries({ initialDelaySeconds: probe.initialDelaySeconds, timeoutSeconds: probe.timeoutSeconds, periodSeconds: probe.periodSeconds, failureThreshold: probe.failureThreshold, }); switch (probe.type) { case "tcp": return [...sharedArgs, ["tcpSocket.port", PORT]]; case "http1": return [ ...sharedArgs, ["httpGet.port", PORT], ["httpGet.path", probe.path], // NOTE: headers are not supported by "gcloud beta" at the moment ]; default: probe; return []; } } function toArgValue(keyValues) { return keyValues.map(([key, value]) => `${key}=${value}`).join(","); } //# sourceMappingURL=healthCheck.js.map