UNPKG

@catladder/cli

Version:

Panter cli tool for cloud CI/CD and DevOps

43 lines 2 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createKubernetesCloudsqlBaseValues = exports.hasKubernetesCloudSQL = void 0; const context_1 = require("../../../context"); const utils_1 = require("../../cloudSql/utils"); const types_1 = require("../../types"); const hasKubernetesCloudSQL = (context) => { var _a, _b, _c; const 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; const createKubernetesCloudsqlBaseValues = (context) => { var _a, _b, _c; const 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"); } const config = (_b = deployConfig.values) === null || _b === void 0 ? void 0 : _b.cloudsql; if (!config) { throw new Error("cannot get cloud sql config"); } const proxyCredentials = `$${(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, fullDbName: (0, utils_1.getFullDbName)(config, context.fullConfig, context.environment.slugPrefix, context.name), }, }; } else { throw new Error("unknonw type"); } }; exports.createKubernetesCloudsqlBaseValues = createKubernetesCloudsqlBaseValues; //# sourceMappingURL=index.js.map