UNPKG

@catladder/pipeline

Version:

Panter workflow for cloud CI/CD and DevOps

76 lines (75 loc) 2.26 kB
"use strict"; var __assign = this && this.__assign || function () { __assign = Object.assign || function (t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; 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; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.createKubeEnv = void 0; var types_1 = require("../types"); var shouldGoIntoSecrets = function (key, value) { var _a; if (!value) return false; if ((_a = String(value)) === null || _a === void 0 ? void 0 : _a.includes("$CL_")) { return true; } return false; }; /** * separate by secrets and public. * we evalulate the actual values later, but want to store the secrets in kubernetes secrets */ var createKubeEnv = function (context) { var _a; if (!(0, types_1.isOfDeployType)((_a = context.deploy) === null || _a === void 0 ? void 0 : _a.config, "kubernetes")) { // should not happen throw new Error("deploy config is not kubernetes"); } var allEnvVars = context.environment.envVars; var env = Object.entries(allEnvVars).reduce(function (acc, _a) { var _b, _c; var _d = __read(_a, 2), key = _d[0], value = _d[1]; if (shouldGoIntoSecrets(key, value === null || value === void 0 ? void 0 : value.toString())) { acc.secret = __assign(__assign({}, acc.secret), (_b = {}, _b[key] = value !== null && value !== void 0 ? value : "", _b)); return acc; } acc.public = __assign(__assign({}, acc.public), (_c = {}, _c[key] = value !== null && value !== void 0 ? value : "", _c)); return acc; }, { secret: {}, public: {} }); return env; }; exports.createKubeEnv = createKubeEnv;