UNPKG

@catladder/pipeline

Version:

Panter workflow for cloud CI/CD and DevOps

44 lines (43 loc) 1.88 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createKubernetesCloudsqlBaseValues = exports.hasKubernetesCloudSQL = void 0; var context_1 = require("../../../context"); var utils_1 = require("../../cloudSql/utils"); var types_1 = require("../../types"); var hasKubernetesCloudSQL = function (context) { var _a, _b, _c; var deployConfig = (_a = context.deploy) === null || _a === void 0 ? void 0 : _a.config; if ((0, types_1.isOfDeployType)(deployConfig, "kubernetes")) { return (_c = (_b = deployConfig.values) === null || _b === void 0 ? void 0 : _b.cloudsql) === null || _c === void 0 ? void 0 : _c.enabled; } return false; }; exports.hasKubernetesCloudSQL = hasKubernetesCloudSQL; var createKubernetesCloudsqlBaseValues = function (context) { var _a, _b, _c; var deployConfig = (_a = context.deploy) === null || _a === void 0 ? void 0 : _a.config; if (!(0, types_1.isOfDeployType)(deployConfig, "kubernetes")) { throw new Error("cannot get cloud sql config"); } var config = (_b = deployConfig.values) === null || _b === void 0 ? void 0 : _b.cloudsql; if (!config) { throw new Error("cannot get cloud sql config"); } var proxyCredentials = "$".concat((0, context_1.getSecretVarNameForContext)(context, "cloudsqlProxyCredentials")); if (config.type === "unmanaged") { return { cloudsql: { enabled: config.enabled, dbUser: (_c = config.dbUser) !== null && _c !== void 0 ? _c : "postgres", instanceConnectionName: config.instanceConnectionName, proxyCredentials: proxyCredentials, fullDbName: (0, utils_1.getFullDbName)(config, context.fullConfig, context.environment.slugPrefix, context.name) } }; } else { throw new Error("unknonw type"); } }; exports.createKubernetesCloudsqlBaseValues = createKubernetesCloudsqlBaseValues;