UNPKG

@catladder/cli

Version:

Panter cli tool for cloud CI/CD and DevOps

52 lines (51 loc) 2.75 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getWorkerPoolDeleteScript = exports.getWorkerPoolDeployScript = void 0; const getLabels_1 = require("../../../context/getLabels"); const createArgsString_1 = require("../utils/createArgsString"); const getJobOrServiceArgs_1 = require("../utils/getJobOrServiceArgs"); const getServiceName_1 = require("../utils/getServiceName"); const common_1 = require("./common"); const constants_1 = require("./constants"); const volumes_1 = require("./volumes"); const getWorkerPoolDeployScript = (context, workerPool, nameSuffix) => { var _a, _b, _c, _d; const commonDeployArgs = (0, common_1.getCommonDeployArgs)(context); const serviceName = (0, getServiceName_1.getServiceName)(context); const command = workerPool.command; const commandArray = Array.isArray(command) ? command : command.split(" "); const fullWorkerPoolName = `${serviceName}-${nameSuffix}`; const argsString = (0, createArgsString_1.createArgsString)({ command: '"' + commandArray.join(",") + '"', args: (0, getJobOrServiceArgs_1.getCloudRunServiceOrJobArgsArg)(workerPool.args), ...commonDeployArgs, image: (_a = workerPool.image) !== null && _a !== void 0 ? _a : commonDeployArgs.image, labels: (0, common_1.makeLabelString)({ ...(0, getLabels_1.getLabels)(context), "cloud-run-worker-pool-name": fullWorkerPoolName }), "env-vars-file": constants_1.ENV_VARS_FILENAME, instances: (_b = workerPool.instances) !== null && _b !== void 0 ? _b : 1, cpu: (_c = workerPool.cpu) !== null && _c !== void 0 ? _c : 1, memory: (_d = workerPool.memory) !== null && _d !== void 0 ? _d : "512Mi", "vpc-connector": workerPool.vpcConnector, "vpc-egress": workerPool.vpcEgress, network: workerPool.network, subnet: workerPool.subnet, gpu: workerPool.gpu, "gpu-type": workerPool.gpuType }, ...(0, volumes_1.createVolumeConfig)(workerPool.volumes, "worker-pool")); // Worker pools are in beta and require the beta command return `${(0, common_1.gcloudRunCmd)("beta")} worker-pools deploy ${fullWorkerPoolName} ${argsString}`; }; exports.getWorkerPoolDeployScript = getWorkerPoolDeployScript; const getWorkerPoolDeleteScript = (context, workerPoolSuffix) => { const commonArgs = (0, common_1.getCommonCloudRunArgs)(context); const commonArgsString = (0, createArgsString_1.createArgsString)(commonArgs); const serviceName = (0, getServiceName_1.getServiceName)(context); const fullWorkerPoolName = `${serviceName}-${workerPoolSuffix}`; return [`${(0, common_1.gcloudRunCmd)("beta")} worker-pools delete ${fullWorkerPoolName} ${commonArgsString}`]; }; exports.getWorkerPoolDeleteScript = getWorkerPoolDeleteScript;