@catladder/cli 3.38.0 → 3.39.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundles/cli/index.js +1 -1
- package/dist/cli/src/apps/cli/commands/project/cloudSql/commandProjectRestoreDb.js +17 -6
- package/dist/cli/src/apps/cli/commands/project/cloudSql/commandProjectRestoreDb.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/apps/cli/commands/project/cloudSql/commandProjectRestoreDb.ts +20 -9
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(()=>{var __webpack_modules__={73318:function(e,t,r){"use strict";var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:true});t.evaluateDocument=t.makeTemplate=void 0;const n=i(r(76435));const a=n.default;const s="✅";const o="❌";const l=`${s}/${o}`;const c="@...";const u=[["Responsible",l,"Description","Note","More Information"]].concat(a.map((e=>[Array(e.responsibles).fill(c).join(", "),l,e.description,"",e.more])));function makeTable(e){const t=calculateColumnWidths(e);return`\n${makeRow(e[0],t," ")}\n${makeRow(e[0].map((()=>"")),t,"-")}\n${e.slice(1).map((e=>makeRow(e,t," "))).join("\n")}\n`}function calculateColumnWidths(e){const t=e[0].length;return Array.from({length:t},((e,t)=>t)).map((t=>Math.max(...e.map((e=>e[t].length)))))}function makeRow(e,t,r){return`| ${e.map(((e,i)=>e.padEnd(t[i],r))).join(" | ")} |`}function makeTemplate(){return`\n# Security Audit Report\n\nA security audit report document is a comprehensive assessment of an application's security posture, containing security topics that auditors can mark to indicate the state of various security aspects.\n\nIt serves as a structured guide for security team to evaluate different security factors such as authentication, authorization, data encryption, input validation, and more.\n\n## General Information\n\n- Project Owner is @...\n- Dev team:\n - @...\n - @...\n - @...\n\n## Project Security\n\n${makeTable(u)}\n\n`}t.makeTemplate=makeTemplate;function evaluateDocument(e){var t,r;const i=(r=(t=e.match(/^\s*\|.*?\|\s*$/gm))===null||t===void 0?void 0:t.map((e=>e.trim())))!==null&&r!==void 0?r:[];const n=i.map((e=>e.split("|").map((e=>e.trim())))).slice(2);const o=new Set(a.map((e=>e.description)));const u=n.map((e=>{const t=e[1].split(", ");const r=e[2];const i=e[3];const n=e[4];const a=!o.has(i);const u=!a&&!r.includes(l)&&!t.some((e=>e.includes(c)));const p=!a&&u&&r.includes(s);return{responsibles:t,answer:r,description:i,note:n,isUnknown:a,isAnswered:u,isSecured:p}}));const p=a.length;const d=u.filter((e=>e.isAnswered)).length;const h=u.filter((e=>e.isSecured)).length;const m=u.filter((e=>e.isUnknown)).length;const b=Math.round(h/p*100);return{topics:u,score:{rating:b,totalTopics:p,answeredTopics:d,securedTopics:h,unknownTopics:m}}}t.evaluateDocument=evaluateDocument},24523:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});t.createSecurityAuditMergeRequest=t.SECURITY_AUDIT_FILE_NAME=void 0;const i=r(85572);const n=r(73318);function makeDatedBranchName(e){const t=(new Date).toISOString().slice(0,-5).replaceAll(/[:.T]/g,"-");return`${e}-${t}`}const a="Draft: chore(security): add security audit document";t.SECURITY_AUDIT_FILE_NAME="SECURITY.md";async function createSecurityAuditMergeRequest({projectId:e,mainBranch:r,userId:s,api:o}){const l=(await i.Result.wrapAsync((()=>o.MergeRequests.all({state:"opened",wip:"yes",labels:"security-audit"})))).mapErr((()=>`could not search for existing merge requests`));if(l.isErr())return l;const c=l.value[0];if(c)return(0,i.Err)(`open merge request with security audit already exists: ${c.web_url}`);const u=i.Result.wrap((()=>(0,n.makeTemplate)())).mapErr((()=>"could not make security audit template document"));if(u.isErr())return u;const p=(await i.Result.wrapAsync((()=>o.Branches.create(e,makeDatedBranchName("chore/security-audit"),r)))).mapErr((e=>{console.log(e);return"could not create branch"}));if(p.isErr())return p;const d=(await i.Result.wrapAsync((()=>o.Commits.create(e,p.value.name,"chore(security): add empty security audit document template",[{action:"create",filePath:t.SECURITY_AUDIT_FILE_NAME,content:u.value,encoding:"text"}])))).mapErr((()=>"could not create commit"));if(d.isErr())return d;const h=(await i.Result.wrapAsync((()=>o.MergeRequests.create(e,p.value.name,r,a,{description:`Please follow and update security audit document in \`${t.SECURITY_AUDIT_FILE_NAME}\`.`,assigneeId:s,squash:true,labels:"security-audit",removeSourceBranch:true})))).mapErr((()=>"could not create merge request"));return h}t.createSecurityAuditMergeRequest=createSecurityAuditMergeRequest},90371:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});t.makeSecurityAuditOverview=t.evaluateSecurityAudit=void 0;const i=r(85572);const n=r(16928);const a=r(91943);const s=r(24523);const o=r(73318);async function evaluateSecurityAudit({path:e}){return(await i.Result.wrapAsync((async()=>{const t=(0,n.join)(e,s.SECURITY_AUDIT_FILE_NAME);const r=await(0,a.readFile)(t);const i=r.toString("utf-8");return(0,o.evaluateDocument)(i)}))).mapErr((e=>`could not evaluate ${s.SECURITY_AUDIT_FILE_NAME}: ${e}`))}t.evaluateSecurityAudit=evaluateSecurityAudit;function makeSecurityAuditOverview(e){const ratingToEmo=e=>e<33?"🟥":e<66?"🟨":"🟩";return`Project security posture overview:\n 🧐 Total topics: ${e.score.totalTopics}\n 🔒 Secured topics: ${e.score.securedTopics}\n 📢 Answered topics: ${e.score.answeredTopics}\n ❔ Unknown topics: ${e.score.unknownTopics}\n 📊 Rating: ${ratingToEmo(e.score.rating)} ${e.score.rating}/100`}t.makeSecurityAuditOverview=makeSecurityAuditOverview},80149:function(e,t,r){"use strict";var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:true});const n=i(r(72999));const a=i(r(53568));const s=r(77090);const o=i(r(65193));const l=i(r(75603));const c=i(r(41156));const u=i(r(87824));const p=i(r(52248));const d=r(18709);const h=r(85490);const m=r(71055);t["default"]=async()=>{const e=new n.default;const t=(0,m.boxWithAsci)(`catladder 😻 v${a.default.version} ✨`);e.delimiter("catladder $").history("catladder").show().log("").log(t).log("");await(0,h.showProjectBanner)(e);(0,d.verify)(e);(0,o.default)(e);(0,u.default)(e);(0,c.default)(e);(0,l.default)(e);(0,p.default)(e);process.on("exit",(()=>{(0,s.stopAllPortForwards)()}))}},38105:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});const i=r(57151);const n=r(95540);t["default"]=async e=>e.command("cloud-sql-restore-db","restore a db from one source to another target").action((async function restoreDb(){const{sourceInstance:e}=await this.prompt({type:"input",name:"sourceInstance",message:"Source instance (connection string or 'local')? 🤔 "});let t;let r;let a;let s;if(e==="local"){const{sourceLocalPort:e}=await this.prompt({type:"number",name:"sourceLocalPort",default:5432,message:"Local Port for source? 🤔 "});a=e}else{a=54399;t=await(0,n.startCloudSqlProxyInBackground)({instanceName:e,localPort:a})}const{sourceUsername:o}=await this.prompt({type:"input",name:"sourceUsername",default:"postgres",message:"Source Username? 🤔 "});const{sourcePassword:l}=await this.prompt({type:"input",name:"sourcePassword",message:"Source Password? 🤔 "});const{sourceDbName:c}=await this.prompt({type:"input",name:"sourceDbName",message:"Source DB name? 🤔 "});const{targetInstance:u}=await this.prompt({type:"input",name:"targetInstance",message:"Target INSTANCE (connection string or 'local')? 🤔 "});if(u==="local"){const{targetLocalPort:e}=await this.prompt({type:"number",name:"targetLocalPort",default:5432,message:"Local Port for target? 🤔 "});s=e}else{s=54499;r=await(0,n.startCloudSqlProxyInBackground)({instanceName:u,localPort:s})}const{targetUsername:p}=await this.prompt({type:"input",name:"targetUsername",default:"postgres",message:"Target Username? 🤔 "});const{targetPassword:d}=await this.prompt({type:"input",name:"targetPassword",message:"Target Password? 🤔 "});const{targetDbName:h}=await this.prompt({type:"input",name:"targetDbName",message:"Target DB name? 🤔 "});const{shouldContinue:m}=await this.prompt({type:"confirm",name:"shouldContinue",message:`This will drop ${u}/${h} and replace it with ${e}/${c}. Continue? 🤔 `});if(!m){return}try{await(0,i.spawnCopyDb)({targetPassword:d,targetPort:s,targetUsername:p,sourceUsername:o,sourcePassword:l,sourcePort:a,sourceDbName:c,targetDbName:h})}finally{t===null||t===void 0?void 0:t.stop();r===null||r===void 0?void 0:r.stop()}}))},41156:function(e,t,r){"use strict";var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:true});const n=i(r(38105));t["default"]=async e=>{(0,n.default)(e)}},65193:function(e,t,r){"use strict";var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:true});t.getAllNamespacesNames=void 0;const n=i(r(57009));const a=r(90390);const s=r(5581);const o=r(67253);const l=r(77090);const c=r(45381);const u=r(79383);const p=i(r(12005));const d=(0,n.default)((async()=>{const e=(0,a.getk8sApi)();const t=await e.listNamespace();return t.body.items}),{maxAge:3e4,promise:true});const getAllNamespacesNames=async()=>{const e=await d();return e.map((e=>e.metadata.name))};t.getAllNamespacesNames=getAllNamespacesNames;t["default"]=async e=>{e.command("kube-current-context").action((async function(){this.log(await(0,s.getCurrentContext)())}));e.command("kube-list-namespaces","list all namespaces").action((async function(){const e=await(0,t.getAllNamespacesNames)();this.log(e.join("\n"))}));e.command("kube-list-secrets <namespace>","show secrets").autocomplete(u.namespaceAutoCompletion).action((async function({namespace:e}){const t=(0,a.getk8sApi)();const r=await t.listNamespacedSecret(e);this.log(r.body.items.map((e=>e.metadata.name)).join("\n"))}));e.command("kube-list-pods <namespace>","list all pods of namespace").autocomplete(u.namespaceAutoCompletion).action((async function({namespace:e}){const t=(0,a.getk8sApi)();const r=await t.listNamespacedPod(e);this.log(r.body.items.map((e=>e.metadata.name)).join("\n"))}));e.command("kube-stop-portforward <name>","stop a running port forward").autocomplete({data:async()=>(0,l.getAllRunningPortForwards)()}).action((async function({name:e}){(0,l.stopPortForward)(e.trim())}));e.command("kube-get-shell <namespace>","get a shell to a pod in the environment").autocomplete(u.namespaceAutoCompletion).action((async function({namespace:e}){const t=(0,a.getk8sApi)();const r=await t.listNamespacedPod(e);if(r.body.items.length===0){(0,o.logError)(this,"sorry, no pods found");return}const i=r.body.items.map((e=>e.metadata.name));const{podName:n}=await this.prompt({type:"list",name:"podName",choices:i,message:"Which pod? 🤔"});await(0,c.getShell)(e,n)}));(0,p.default)(e)}},79383:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});t.namespaceAutoCompletion=void 0;const i=r(65193);t.namespaceAutoCompletion={async data(){const e=await(0,i.getAllNamespacesNames)();return e}}},12005:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});const i=r(67253);const n=r(86070);const a=r(90390);const s=r(79383);t["default"]=async e=>e.command("kube-port-forward <namespace>","start port-forwarding").autocomplete(s.namespaceAutoCompletion).action((async function({namespace:e}){const t=(0,a.getk8sApi)();const r=await t.listNamespacedPod(e);if(r.body.items.length===0){(0,i.logError)(this,"sorry, no pods found");return}const s=r.body.items.map((e=>e.metadata.name));if(s.length===0){(0,i.logError)(this,"sorry, no pods found");return}const{podName:o}=await this.prompt({type:"list",name:"podName",choices:s,message:"Which pod? 🤔"});const{localPort:l}=await this.prompt({type:"number",name:"localPort",message:"Local port: "});const{remotePort:c}=await this.prompt({type:"number",name:"remotePort",message:"Remote port: "});return(0,n.startKubePortForward)(o,l,c,e)}))},75603:function(e,t,r){"use strict";var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:true});const n=i(r(38990));const a=i(r(75422));const s=i(r(40438));t["default"]=async e=>{(0,a.default)(e);(0,s.default)(e);(0,n.default)(e)}},38990:function(e,t,r){"use strict";var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:true});const n=r(51748);const a=r(45198);const s=r(67253);const o=r(57414);const l=r(52468);const c=i(r(2490));const u=r(38365);const removeFinalizer=async(e,t,r)=>(0,n.exec)(`kubectl patch --namespace ${e} ${t} ${r} -p '{"metadata":{"finalizers":null}}'`);const deleteResource=async(e,t,r)=>(0,n.exec)(`kubectl delete --namespace ${e} ${t} ${r}`);const removeFinalizerAndDelete=async(e,t,r)=>Promise.all([removeFinalizer(e,t,r),await deleteResource(e,t,r)]);t["default"]=async e=>e.command("project-mongo-destroy-member <envComponent>","DESTROY a member of a replicaset in order to reinitialize it").autocomplete(await(0,l.envAndComponents)()).action((async function({envComponent:e}){await c.default.call(this,e);this.log("this command tries to delete a (secondary) member of the replicaset, it's persistent volume claim (pvc) and the volume");this.log("");this.log("this is useful, if you update the stateful set with new volume configuration (different size or storage class)");this.log("");this.log("Kubernetes will usually recreate the missing member with the updated config and mongodb will start synchronizing the new member.");this.log("");this.log("This works without downtime, but should be done when load on the db is low. Also it has not been tested with large dbs (> 10gi)");this.log("");this.log("Deleting the volume and claim often stuck, just wait or cancel and restart.");this.log("");const{understood:t}=await this.prompt({default:true,message:"DO YOU UNDERSTAND?",name:"understood",type:"confirm"});if(!t){throw new Error("abort")}const r=await(0,o.getProjectNamespace)(e);const i=await(0,u.getMongoDbPodsWithReplInfo)(e);const n=await(0,a.getProjectPvcs)(e);const l=i.filter((e=>!e.isMaster));if(l.length===0){(0,s.logError)(this,"sorry, no pods found");return}const p=(await this.prompt({type:"list",name:"podName",choices:l.map((e=>({name:`[ secondary ] ${e.podName}`,value:e.podName}))),message:"Which pod? 🤔"})).podName;const d=n.find((e=>e.metadata.name===`datadir-${p}`));if(!d){(0,s.logError)(this,`sorry, no pvc found for ${p}`);return}const{shouldContinue:h}=await this.prompt({default:true,message:"THIS WILL DESTROY THE POD, ITS VOLUME AND ALL ITS DATA 🙀🙀🙀!!! continue? 🤔",name:"shouldContinue",type:"confirm"});if(!h){throw new Error("abort")}this.log("destroying volume...");try{await removeFinalizerAndDelete(r,"pv",d.spec.volumeName)}catch(e){this.log(e.message)}this.log("destroying volume claim...");try{await removeFinalizerAndDelete(r,"pvc",d.metadata.name)}catch(e){this.log(e.message)}this.log("destroying pod...");await removeFinalizerAndDelete(r,"pod",p)}))},75422:function(e,t,r){"use strict";var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:true});const n=r(67253);const a=r(57414);const s=r(52468);const o=i(r(2490));const l=r(38365);t["default"]=async e=>e.command("project-mongo-get-shell <envComponent>","get a shell to a mongodb in the environment").autocomplete(await(0,s.envAndComponents)()).action((async function({envComponent:e}){await o.default.call(this,e);const t=await(0,a.getProjectNamespace)(e);const r=await(0,l.getProjectMongodbAllPodsSortedWithLabel)(e);if(r.length===0){(0,n.logError)(this,"sorry, no pods found");return}let i;if(r.length===1){i=r[0]}else{i=(await this.prompt({type:"list",name:"podName",choices:r,message:"Which pod? 🤔"})).podName}return(0,l.getMongodbShell)(t,i)}))},40438:function(e,t,r){"use strict";var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:true});const n=r(50001);const a=r(67253);const s=r(86070);const o=r(57414);const l=r(52468);const c=i(r(2490));const u=r(38365);const p=i(r(77983));t["default"]=async e=>e.command("project-mongo-port-forward <envComponent>","port foward to a mongodb").autocomplete(await(0,l.envAndComponents)()).action((async function({envComponent:e}){await c.default.call(this,e);const t=await(0,o.getProjectNamespace)(e);const r=await(0,u.getProjectMongodbAllPodsSortedWithLabel)(e);if(r.length===0){(0,a.logError)(this,"sorry, no pods found");return}let i;if(r.length===1){i=r[0].value}else{i=(await this.prompt({type:"list",name:"podName",choices:r,message:"Which pod? 🤔"})).podName}const{localPort:l}=await this.prompt({type:"number",name:"localPort",default:"30000",message:"Local port: "});const{env:d,componentName:h}=(0,n.parseChoice)(e);const m=await(0,n.getEnvVarsResolved)(this,d,h);const b=m===null||m===void 0?void 0:m.MONGODB_ROOT_PASSWORD;const y=`mongodb://root:${b}@localhost:${l}`;p.default.writeSync(y);this.log("");this.log("username: root");this.log(`password: ${b}`);this.log(`connection string: ${y}`);this.log("");this.log("👆 connection string has been copied to your clipboard!");this.log("");return(0,s.startKubePortForward)(i,l,27017,t)}))},38365:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});t.getProjectMongodbAllPodsSortedWithLabel=t.getMongoDbPodsWithReplInfo=t.podIsMaster=t.executeMongodbCommand=t.getMongodbShell=t.getProjectMongodbAllPods=void 0;const i=r(51748);const n=r(45198);const a=r(57414);const filterMongoDbs=e=>e.filter((e=>e.includes("mongodb")&&!e.includes("mongodb-backup")&&!e.includes("arbiter")));const getProjectMongodbAllPods=async e=>filterMongoDbs(await(0,n.getProjectPodNames)(e));t.getProjectMongodbAllPods=getProjectMongodbAllPods;const getMongodbShell=async(e,t)=>{const r=`kubectl exec -it ${t} --namespace ${e} mongo`;try{await(0,i.spawn)(r,{shell:true,stdio:"inherit",env:{...process.env,DEBUG:""}})}catch(e){}};t.getMongodbShell=getMongodbShell;const executeMongodbCommand=async(e,t,r)=>{const n=`kubectl exec -it ${t} --namespace ${e} -- mongo --quiet --eval "JSON.stringify(${r})"`;const{stdout:a}=await(0,i.exec)(n,{env:{...process.env,DEBUG:""}});return JSON.parse(a)};t.executeMongodbCommand=executeMongodbCommand;const podIsMaster=async(e,r)=>{try{const i=await(0,t.executeMongodbCommand)(e,r,"db.isMaster()");return i.ismaster}catch(e){return null}};t.podIsMaster=podIsMaster;const spaces=e=>" ".repeat(e);const getMongoDbPodsWithReplInfo=async e=>{const r=await(0,a.getProjectNamespace)(e);return(await Promise.all((await(0,t.getProjectMongodbAllPods)(e)).map((async e=>({podName:e,componentName:e.replace(/-mongodb-replicaset-[0-9]+/,""),isMaster:await(0,t.podIsMaster)(r,e)}))))).sort(((e,t)=>e.isMaster?t.isMaster?0:-1:1))};t.getMongoDbPodsWithReplInfo=getMongoDbPodsWithReplInfo;const getProjectMongodbAllPodsSortedWithLabel=async e=>{const r=await(0,t.getMongoDbPodsWithReplInfo)(e);const i=Math.max(...r.map((e=>e.componentName.length)));return r.map((({podName:e,isMaster:t,componentName:r})=>({value:e,name:`[ ${r}${spaces(i-r.length)} ${t?" PRIMARY ":" secondary "}] ${e}`})))};t.getProjectMongodbAllPodsSortedWithLabel=getProjectMongodbAllPodsSortedWithLabel},76512:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});const i=r(50001);const n=r(95540);const a=r(77992);const s=r(57151);const o=r(60241);const hasCloudSql=e=>{var t,r,i;const n=(t=e.deploy)===null||t===void 0?void 0:t.config;if((0,o.isOfDeployType)(n,"google-cloudrun")){return!!n.cloudSql}if((0,o.isOfDeployType)(n,"kubernetes")){return!!((i=(r=n.values)===null||r===void 0?void 0:r.cloudsql)===null||i===void 0?void 0:i.enabled)}return false};t["default"]=async e=>e.command("project-cloud-sql-restore-db","restores a project db from one source to another target").action((async function restoreDb(){var e,t,r,o,l;const c=await(0,i.getAllPipelineContexts)(undefined,{includeLocal:true});const u=c.filter(hasCloudSql).map((e=>`${e.env}:${e.name}`)).sort(((e,t)=>{const r=e.startsWith("local:");const i=t.startsWith("local:");if(r!==i)return r?1:-1;return e.localeCompare(t)}));const{sourceEnvAndComponent:p}=await this.prompt({type:"list",name:"sourceEnvAndComponent",choices:u,message:"Source instance (connection string or 'local')? 🤔 "});const[d,h]=p.split(":");const m=await(0,i.getPipelineContextByChoice)(d,h);const b=await(0,i.getEnvVarsResolved)(this,m.env,m.name);let y;let g;let v;let w;let j;let O;let _;let k;let C;let P;const closeAll=()=>{y===null||y===void 0?void 0:y.stop();_===null||_===void 0?void 0:_.stop()};if(d==="local"){const r=(0,a.parseConnectionString)(b.DATABASE_URL.toString());k=(t=(e=r.hosts)===null||e===void 0?void 0:e[0])===null||t===void 0?void 0:t.port;v=r.username;w=r.password;g=r.endpoint}else{k=54399;y=await(0,n.startCloudSqlProxyInBackground)({instanceName:b.CLOUD_SQL_INSTANCE_CONNECTION_NAME.toString(),localPort:k});v=b.DB_USER.toString();w=b.DB_PASSWORD.toString();g=(r=b.DB_NAME)===null||r===void 0?void 0:r.toString()}const{targetEnvAndComponent:z}=await this.prompt({type:"list",name:"targetEnvAndComponent",choices:u,message:"target env? 🤔 "});const[R,x]=z.split(":");const V=await(0,i.getPipelineContextByChoice)(R,x);const N=await(0,i.getEnvVarsResolved)(this,V.env,V.name);if(R==="local"){const e=(0,a.parseConnectionString)(N.DATABASE_URL.toString());C=(l=(o=e.hosts)===null||o===void 0?void 0:o[0])===null||l===void 0?void 0:l.port;j=e.username;O=e.password;P=e.endpoint}else{C=54499;_=await(0,n.startCloudSqlProxyInBackground)({instanceName:N.CLOUD_SQL_INSTANCE_CONNECTION_NAME.toString(),localPort:C});j=N.DB_USER.toString();O=N.DB_PASSWORD.toString();P=N.DB_NAME.toString()}const{shouldContinue:D}=await this.prompt({type:"confirm",name:"shouldContinue",message:`This will drop ${R}/${P} and replace it with ${d}/${g}. Continue? 🤔 `});if(!D){this.log("abort");closeAll();return}if(V.environment.envType==="prod"){this.log(`\n🚨 You are overriding a production environment. Please type in ${N.CLOUD_SQL_INSTANCE_CONNECTION_NAME} to continue\n\n`);const{confirmInstance:e}=await this.prompt({type:"input",name:"confirmInstance",message:"confirm: "});if(e!==N.CLOUD_SQL_INSTANCE_CONNECTION_NAME){this.log("abort");closeAll();return}}try{await(0,s.spawnCopyDb)({targetPassword:O,targetPort:C,targetUsername:j,sourceUsername:v,sourcePassword:w,sourcePort:k,sourceDbName:g,targetDbName:P})}finally{closeAll()}}))},29020:function(e,t,r){"use strict";var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:true});const n=r(60241);const a=i(r(77983));const s=r(50001);const o=r(52468);const l=r(95540);const c=r(67253);const getProxyInfo=e=>{var t,r,i,a;if((0,n.isOfDeployType)((t=e.deploy)===null||t===void 0?void 0:t.config,"kubernetes")){return getProxyInfoForKubernetes(this,e)}else if((0,n.isOfDeployType)((r=e.deploy)===null||r===void 0?void 0:r.config,"google-cloudrun")){return getProxyInfoForCloudRun(this,e)}throw new Error(`unsupported environment: ${(a=(i=e.deploy)===null||i===void 0?void 0:i.config)===null||a===void 0?void 0:a.type}`)};const getProxyInfoForKubernetes=async(e,t)=>{var r,i;if(!(0,n.isOfDeployType)((r=t.deploy)===null||r===void 0?void 0:r.config,"kubernetes")){throw new Error("unsupported")}const a=await(0,s.getEnvVarsResolved)(e,t.env,t.name);const o=(0,n.createKubernetesCloudsqlBaseValues)(t);const l=(i=(a===null||a===void 0?void 0:a.DB_PASSWORD)||(a===null||a===void 0?void 0:a.POSTGRESQL_PASSWORD))===null||i===void 0?void 0:i.toString();const c=o.cloudsql.fullDbName.toString();const u=o.cloudsql.instanceConnectionName;return{instanceName:u,DB_PASSWORD:l,DB_NAME:c,DB_USER:"postgres"}};const getProxyInfoForCloudRun=async(e,t)=>{var r,i,a,o,l,u;if(!(0,n.isOfDeployType)((r=t.deploy)===null||r===void 0?void 0:r.config,"google-cloudrun")||!((i=t.deploy)===null||i===void 0?void 0:i.config.cloudSql)){const r=(0,n.getDeployConfigType)((a=t.deploy)===null||a===void 0?void 0:a.config);const i=r==="google-cloudrun"?`DeployConfig is missing the cloudSql property`:`Unsupported DeployConfig type: ${r}`;(0,c.logError)(e,i);throw new Error(i)}const p=await(0,s.getEnvVarsResolved)(e,t.env,t.name);return{instanceName:(o=t.deploy)===null||o===void 0?void 0:o.config.cloudSql.instanceConnectionName,DB_PASSWORD:(l=p===null||p===void 0?void 0:p.DB_PASSWORD)===null||l===void 0?void 0:l.toString(),DB_NAME:t.environment.envVars.DB_NAME.toString(),DB_USER:(u=p===null||p===void 0?void 0:p.DB_USER)===null||u===void 0?void 0:u.toString()}};const getDbUrl=({DB_PASSWORD:e,DB_NAME:t,DB_USER:r},i,n="")=>`DATABASE_URL="postgresql://${r}:${e}@localhost:${i}/${t}${n}"`;const getJdbcUrl=({DB_PASSWORD:e,DB_NAME:t,DB_USER:r},i)=>`DATABASE_JDBC_URL="jdbc:postgresql://localhost:${i}/${t}?schema=public&user=${r}&password=${e}"`;t["default"]=async e=>e.command("project-cloud-sql-proxy <envComponent>","proxy to cloud sql db").autocomplete(await(0,o.envAndComponents)()).action((async function({envComponent:e}){const{env:t,componentName:r}=(0,s.parseChoice)(e);if(!r){(0,c.logWarning)(this,"need componentName");return}const i=await(0,s.getPipelineContextByChoice)(t,r);if(t==="review"){(0,c.logWarning)(this,"connection string does not include mr information on review environments")}const{localPort:n}=await this.prompt({type:"number",name:"localPort",default:"54320",message:"Local port: "});const o=await getProxyInfo(i);const u={PGPASSWORD:o.DB_PASSWORD,PGUSER:o.DB_USER,PGDATABASE:o.DB_NAME,PGHOST:"localhost",PGPORT:n};const p=Object.entries(u).map((([e,t])=>`${e}="${t}"`));const d=getDbUrl(o,n);const h=getJdbcUrl(o,n);a.default.writeSync(["","## CloudSQL proxy connection .env variables",d,h,"## DATABASE_URL with schema=public parameter (e. g. Prisma requires this):",`# ${getDbUrl(o,n,`?schema=public`)}`,"## Env variables for libpq (e.g. psql client https://www.postgresql.org/docs/current/libpq-envars.html#LIBPQ-ENVARS)",...p,""].join("\n"));(0,c.logLines)(this,null,"Connection strings env variables DATABASE_URL and those for the 'psql' client (copied to your clipboard for .env file):",d,h,...p,null,"DATABASE_URL with schema=public parameter (e. g. Prisma requires this):",getDbUrl(o,n,`?schema=public`),null);try{await(0,l.startCloudSqlProxyInCurrentShell)({instanceName:o.instanceName,localPort:n})}catch(e){if(!(e instanceof Error))throw e;if(e.message!==l.ERROR_NOT_INSTALLED)throw e;(0,c.logError)(this,e.message,null,"Please install the Cloud SQL Auth Proxy from:",`https://cloud.google.com/sql/docs/postgres/connect-auth-proxy#install`,null)}}))},58002:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});t.projectConfigSecrets=void 0;const i=r(60241);const n=r(63779);const a=r(49250);const s=r(50001);const o=r(82805);const l=r(4508);const c=r(51762);const u=r(52468);const resolveJson=e=>Object.fromEntries(Object.entries(e).map((([e,t])=>[e,Object.fromEntries(Object.entries(t).map((([e,t])=>[e,Object.fromEntries(Object.entries(t).map((([e,t])=>{try{return[e,JSON.parse(t)]}catch(r){return[e,t]}})))])))])));const getSecretEnvVarKeysToConfigure=async(e,t)=>{const{secretEnvVarKeys:r,jobOnlyVars:i}=await(0,s.getEnvironment)(e,t);return[...i.build.secretEnvVarKeys,...i.deploy.secretEnvVarKeys,...r].filter((e=>!e.hidden)).map((e=>e.key))};const getEnvVarsToEdit=async(e,t,r)=>{const n=await getSecretEnvVarKeysToConfigure(t,r);const a=await(0,s.getEnvVarsResolved)(e,t,r);const o=await(0,s.getJobOnlyEnvVarsResolved)(e,t,r);const l={...a,...o};return Object.fromEntries(n.map((e=>{const n=l[e];const a=n==="$"+(0,i.getSecretVarName)(t,r,e);return[e,a?"🚨 FILL ME":n]})))};const doItFor=async(e,t)=>{let r=Object.fromEntries(await Promise.all(Object.entries(t).map((async([t,r])=>[t,Object.fromEntries(await Promise.all(r.map((async r=>[r,await getEnvVarsToEdit(e,r,t)]))))]))));let i=true;while(i){r=await(0,o.editAsFile)(resolveJson(r),(0,n.stripIndents)`
|
|
1
|
+
(()=>{var __webpack_modules__={73318:function(e,t,r){"use strict";var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:true});t.evaluateDocument=t.makeTemplate=void 0;const n=i(r(76435));const a=n.default;const s="✅";const o="❌";const l=`${s}/${o}`;const c="@...";const u=[["Responsible",l,"Description","Note","More Information"]].concat(a.map((e=>[Array(e.responsibles).fill(c).join(", "),l,e.description,"",e.more])));function makeTable(e){const t=calculateColumnWidths(e);return`\n${makeRow(e[0],t," ")}\n${makeRow(e[0].map((()=>"")),t,"-")}\n${e.slice(1).map((e=>makeRow(e,t," "))).join("\n")}\n`}function calculateColumnWidths(e){const t=e[0].length;return Array.from({length:t},((e,t)=>t)).map((t=>Math.max(...e.map((e=>e[t].length)))))}function makeRow(e,t,r){return`| ${e.map(((e,i)=>e.padEnd(t[i],r))).join(" | ")} |`}function makeTemplate(){return`\n# Security Audit Report\n\nA security audit report document is a comprehensive assessment of an application's security posture, containing security topics that auditors can mark to indicate the state of various security aspects.\n\nIt serves as a structured guide for security team to evaluate different security factors such as authentication, authorization, data encryption, input validation, and more.\n\n## General Information\n\n- Project Owner is @...\n- Dev team:\n - @...\n - @...\n - @...\n\n## Project Security\n\n${makeTable(u)}\n\n`}t.makeTemplate=makeTemplate;function evaluateDocument(e){var t,r;const i=(r=(t=e.match(/^\s*\|.*?\|\s*$/gm))===null||t===void 0?void 0:t.map((e=>e.trim())))!==null&&r!==void 0?r:[];const n=i.map((e=>e.split("|").map((e=>e.trim())))).slice(2);const o=new Set(a.map((e=>e.description)));const u=n.map((e=>{const t=e[1].split(", ");const r=e[2];const i=e[3];const n=e[4];const a=!o.has(i);const u=!a&&!r.includes(l)&&!t.some((e=>e.includes(c)));const p=!a&&u&&r.includes(s);return{responsibles:t,answer:r,description:i,note:n,isUnknown:a,isAnswered:u,isSecured:p}}));const p=a.length;const d=u.filter((e=>e.isAnswered)).length;const h=u.filter((e=>e.isSecured)).length;const m=u.filter((e=>e.isUnknown)).length;const b=Math.round(h/p*100);return{topics:u,score:{rating:b,totalTopics:p,answeredTopics:d,securedTopics:h,unknownTopics:m}}}t.evaluateDocument=evaluateDocument},24523:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});t.createSecurityAuditMergeRequest=t.SECURITY_AUDIT_FILE_NAME=void 0;const i=r(85572);const n=r(73318);function makeDatedBranchName(e){const t=(new Date).toISOString().slice(0,-5).replaceAll(/[:.T]/g,"-");return`${e}-${t}`}const a="Draft: chore(security): add security audit document";t.SECURITY_AUDIT_FILE_NAME="SECURITY.md";async function createSecurityAuditMergeRequest({projectId:e,mainBranch:r,userId:s,api:o}){const l=(await i.Result.wrapAsync((()=>o.MergeRequests.all({state:"opened",wip:"yes",labels:"security-audit"})))).mapErr((()=>`could not search for existing merge requests`));if(l.isErr())return l;const c=l.value[0];if(c)return(0,i.Err)(`open merge request with security audit already exists: ${c.web_url}`);const u=i.Result.wrap((()=>(0,n.makeTemplate)())).mapErr((()=>"could not make security audit template document"));if(u.isErr())return u;const p=(await i.Result.wrapAsync((()=>o.Branches.create(e,makeDatedBranchName("chore/security-audit"),r)))).mapErr((e=>{console.log(e);return"could not create branch"}));if(p.isErr())return p;const d=(await i.Result.wrapAsync((()=>o.Commits.create(e,p.value.name,"chore(security): add empty security audit document template",[{action:"create",filePath:t.SECURITY_AUDIT_FILE_NAME,content:u.value,encoding:"text"}])))).mapErr((()=>"could not create commit"));if(d.isErr())return d;const h=(await i.Result.wrapAsync((()=>o.MergeRequests.create(e,p.value.name,r,a,{description:`Please follow and update security audit document in \`${t.SECURITY_AUDIT_FILE_NAME}\`.`,assigneeId:s,squash:true,labels:"security-audit",removeSourceBranch:true})))).mapErr((()=>"could not create merge request"));return h}t.createSecurityAuditMergeRequest=createSecurityAuditMergeRequest},90371:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});t.makeSecurityAuditOverview=t.evaluateSecurityAudit=void 0;const i=r(85572);const n=r(16928);const a=r(91943);const s=r(24523);const o=r(73318);async function evaluateSecurityAudit({path:e}){return(await i.Result.wrapAsync((async()=>{const t=(0,n.join)(e,s.SECURITY_AUDIT_FILE_NAME);const r=await(0,a.readFile)(t);const i=r.toString("utf-8");return(0,o.evaluateDocument)(i)}))).mapErr((e=>`could not evaluate ${s.SECURITY_AUDIT_FILE_NAME}: ${e}`))}t.evaluateSecurityAudit=evaluateSecurityAudit;function makeSecurityAuditOverview(e){const ratingToEmo=e=>e<33?"🟥":e<66?"🟨":"🟩";return`Project security posture overview:\n 🧐 Total topics: ${e.score.totalTopics}\n 🔒 Secured topics: ${e.score.securedTopics}\n 📢 Answered topics: ${e.score.answeredTopics}\n ❔ Unknown topics: ${e.score.unknownTopics}\n 📊 Rating: ${ratingToEmo(e.score.rating)} ${e.score.rating}/100`}t.makeSecurityAuditOverview=makeSecurityAuditOverview},80149:function(e,t,r){"use strict";var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:true});const n=i(r(72999));const a=i(r(53568));const s=r(77090);const o=i(r(65193));const l=i(r(75603));const c=i(r(41156));const u=i(r(87824));const p=i(r(52248));const d=r(18709);const h=r(85490);const m=r(71055);t["default"]=async()=>{const e=new n.default;const t=(0,m.boxWithAsci)(`catladder 😻 v${a.default.version} ✨`);e.delimiter("catladder $").history("catladder").show().log("").log(t).log("");await(0,h.showProjectBanner)(e);(0,d.verify)(e);(0,o.default)(e);(0,u.default)(e);(0,c.default)(e);(0,l.default)(e);(0,p.default)(e);process.on("exit",(()=>{(0,s.stopAllPortForwards)()}))}},38105:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});const i=r(57151);const n=r(95540);t["default"]=async e=>e.command("cloud-sql-restore-db","restore a db from one source to another target").action((async function restoreDb(){const{sourceInstance:e}=await this.prompt({type:"input",name:"sourceInstance",message:"Source instance (connection string or 'local')? 🤔 "});let t;let r;let a;let s;if(e==="local"){const{sourceLocalPort:e}=await this.prompt({type:"number",name:"sourceLocalPort",default:5432,message:"Local Port for source? 🤔 "});a=e}else{a=54399;t=await(0,n.startCloudSqlProxyInBackground)({instanceName:e,localPort:a})}const{sourceUsername:o}=await this.prompt({type:"input",name:"sourceUsername",default:"postgres",message:"Source Username? 🤔 "});const{sourcePassword:l}=await this.prompt({type:"input",name:"sourcePassword",message:"Source Password? 🤔 "});const{sourceDbName:c}=await this.prompt({type:"input",name:"sourceDbName",message:"Source DB name? 🤔 "});const{targetInstance:u}=await this.prompt({type:"input",name:"targetInstance",message:"Target INSTANCE (connection string or 'local')? 🤔 "});if(u==="local"){const{targetLocalPort:e}=await this.prompt({type:"number",name:"targetLocalPort",default:5432,message:"Local Port for target? 🤔 "});s=e}else{s=54499;r=await(0,n.startCloudSqlProxyInBackground)({instanceName:u,localPort:s})}const{targetUsername:p}=await this.prompt({type:"input",name:"targetUsername",default:"postgres",message:"Target Username? 🤔 "});const{targetPassword:d}=await this.prompt({type:"input",name:"targetPassword",message:"Target Password? 🤔 "});const{targetDbName:h}=await this.prompt({type:"input",name:"targetDbName",message:"Target DB name? 🤔 "});const{shouldContinue:m}=await this.prompt({type:"confirm",name:"shouldContinue",message:`This will drop ${u}/${h} and replace it with ${e}/${c}. Continue? 🤔 `});if(!m){return}try{await(0,i.spawnCopyDb)({targetPassword:d,targetPort:s,targetUsername:p,sourceUsername:o,sourcePassword:l,sourcePort:a,sourceDbName:c,targetDbName:h})}finally{t===null||t===void 0?void 0:t.stop();r===null||r===void 0?void 0:r.stop()}}))},41156:function(e,t,r){"use strict";var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:true});const n=i(r(38105));t["default"]=async e=>{(0,n.default)(e)}},65193:function(e,t,r){"use strict";var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:true});t.getAllNamespacesNames=void 0;const n=i(r(57009));const a=r(90390);const s=r(5581);const o=r(67253);const l=r(77090);const c=r(45381);const u=r(79383);const p=i(r(12005));const d=(0,n.default)((async()=>{const e=(0,a.getk8sApi)();const t=await e.listNamespace();return t.body.items}),{maxAge:3e4,promise:true});const getAllNamespacesNames=async()=>{const e=await d();return e.map((e=>e.metadata.name))};t.getAllNamespacesNames=getAllNamespacesNames;t["default"]=async e=>{e.command("kube-current-context").action((async function(){this.log(await(0,s.getCurrentContext)())}));e.command("kube-list-namespaces","list all namespaces").action((async function(){const e=await(0,t.getAllNamespacesNames)();this.log(e.join("\n"))}));e.command("kube-list-secrets <namespace>","show secrets").autocomplete(u.namespaceAutoCompletion).action((async function({namespace:e}){const t=(0,a.getk8sApi)();const r=await t.listNamespacedSecret(e);this.log(r.body.items.map((e=>e.metadata.name)).join("\n"))}));e.command("kube-list-pods <namespace>","list all pods of namespace").autocomplete(u.namespaceAutoCompletion).action((async function({namespace:e}){const t=(0,a.getk8sApi)();const r=await t.listNamespacedPod(e);this.log(r.body.items.map((e=>e.metadata.name)).join("\n"))}));e.command("kube-stop-portforward <name>","stop a running port forward").autocomplete({data:async()=>(0,l.getAllRunningPortForwards)()}).action((async function({name:e}){(0,l.stopPortForward)(e.trim())}));e.command("kube-get-shell <namespace>","get a shell to a pod in the environment").autocomplete(u.namespaceAutoCompletion).action((async function({namespace:e}){const t=(0,a.getk8sApi)();const r=await t.listNamespacedPod(e);if(r.body.items.length===0){(0,o.logError)(this,"sorry, no pods found");return}const i=r.body.items.map((e=>e.metadata.name));const{podName:n}=await this.prompt({type:"list",name:"podName",choices:i,message:"Which pod? 🤔"});await(0,c.getShell)(e,n)}));(0,p.default)(e)}},79383:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});t.namespaceAutoCompletion=void 0;const i=r(65193);t.namespaceAutoCompletion={async data(){const e=await(0,i.getAllNamespacesNames)();return e}}},12005:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});const i=r(67253);const n=r(86070);const a=r(90390);const s=r(79383);t["default"]=async e=>e.command("kube-port-forward <namespace>","start port-forwarding").autocomplete(s.namespaceAutoCompletion).action((async function({namespace:e}){const t=(0,a.getk8sApi)();const r=await t.listNamespacedPod(e);if(r.body.items.length===0){(0,i.logError)(this,"sorry, no pods found");return}const s=r.body.items.map((e=>e.metadata.name));if(s.length===0){(0,i.logError)(this,"sorry, no pods found");return}const{podName:o}=await this.prompt({type:"list",name:"podName",choices:s,message:"Which pod? 🤔"});const{localPort:l}=await this.prompt({type:"number",name:"localPort",message:"Local port: "});const{remotePort:c}=await this.prompt({type:"number",name:"remotePort",message:"Remote port: "});return(0,n.startKubePortForward)(o,l,c,e)}))},75603:function(e,t,r){"use strict";var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:true});const n=i(r(38990));const a=i(r(75422));const s=i(r(40438));t["default"]=async e=>{(0,a.default)(e);(0,s.default)(e);(0,n.default)(e)}},38990:function(e,t,r){"use strict";var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:true});const n=r(51748);const a=r(45198);const s=r(67253);const o=r(57414);const l=r(52468);const c=i(r(2490));const u=r(38365);const removeFinalizer=async(e,t,r)=>(0,n.exec)(`kubectl patch --namespace ${e} ${t} ${r} -p '{"metadata":{"finalizers":null}}'`);const deleteResource=async(e,t,r)=>(0,n.exec)(`kubectl delete --namespace ${e} ${t} ${r}`);const removeFinalizerAndDelete=async(e,t,r)=>Promise.all([removeFinalizer(e,t,r),await deleteResource(e,t,r)]);t["default"]=async e=>e.command("project-mongo-destroy-member <envComponent>","DESTROY a member of a replicaset in order to reinitialize it").autocomplete(await(0,l.envAndComponents)()).action((async function({envComponent:e}){await c.default.call(this,e);this.log("this command tries to delete a (secondary) member of the replicaset, it's persistent volume claim (pvc) and the volume");this.log("");this.log("this is useful, if you update the stateful set with new volume configuration (different size or storage class)");this.log("");this.log("Kubernetes will usually recreate the missing member with the updated config and mongodb will start synchronizing the new member.");this.log("");this.log("This works without downtime, but should be done when load on the db is low. Also it has not been tested with large dbs (> 10gi)");this.log("");this.log("Deleting the volume and claim often stuck, just wait or cancel and restart.");this.log("");const{understood:t}=await this.prompt({default:true,message:"DO YOU UNDERSTAND?",name:"understood",type:"confirm"});if(!t){throw new Error("abort")}const r=await(0,o.getProjectNamespace)(e);const i=await(0,u.getMongoDbPodsWithReplInfo)(e);const n=await(0,a.getProjectPvcs)(e);const l=i.filter((e=>!e.isMaster));if(l.length===0){(0,s.logError)(this,"sorry, no pods found");return}const p=(await this.prompt({type:"list",name:"podName",choices:l.map((e=>({name:`[ secondary ] ${e.podName}`,value:e.podName}))),message:"Which pod? 🤔"})).podName;const d=n.find((e=>e.metadata.name===`datadir-${p}`));if(!d){(0,s.logError)(this,`sorry, no pvc found for ${p}`);return}const{shouldContinue:h}=await this.prompt({default:true,message:"THIS WILL DESTROY THE POD, ITS VOLUME AND ALL ITS DATA 🙀🙀🙀!!! continue? 🤔",name:"shouldContinue",type:"confirm"});if(!h){throw new Error("abort")}this.log("destroying volume...");try{await removeFinalizerAndDelete(r,"pv",d.spec.volumeName)}catch(e){this.log(e.message)}this.log("destroying volume claim...");try{await removeFinalizerAndDelete(r,"pvc",d.metadata.name)}catch(e){this.log(e.message)}this.log("destroying pod...");await removeFinalizerAndDelete(r,"pod",p)}))},75422:function(e,t,r){"use strict";var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:true});const n=r(67253);const a=r(57414);const s=r(52468);const o=i(r(2490));const l=r(38365);t["default"]=async e=>e.command("project-mongo-get-shell <envComponent>","get a shell to a mongodb in the environment").autocomplete(await(0,s.envAndComponents)()).action((async function({envComponent:e}){await o.default.call(this,e);const t=await(0,a.getProjectNamespace)(e);const r=await(0,l.getProjectMongodbAllPodsSortedWithLabel)(e);if(r.length===0){(0,n.logError)(this,"sorry, no pods found");return}let i;if(r.length===1){i=r[0]}else{i=(await this.prompt({type:"list",name:"podName",choices:r,message:"Which pod? 🤔"})).podName}return(0,l.getMongodbShell)(t,i)}))},40438:function(e,t,r){"use strict";var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:true});const n=r(50001);const a=r(67253);const s=r(86070);const o=r(57414);const l=r(52468);const c=i(r(2490));const u=r(38365);const p=i(r(77983));t["default"]=async e=>e.command("project-mongo-port-forward <envComponent>","port foward to a mongodb").autocomplete(await(0,l.envAndComponents)()).action((async function({envComponent:e}){await c.default.call(this,e);const t=await(0,o.getProjectNamespace)(e);const r=await(0,u.getProjectMongodbAllPodsSortedWithLabel)(e);if(r.length===0){(0,a.logError)(this,"sorry, no pods found");return}let i;if(r.length===1){i=r[0].value}else{i=(await this.prompt({type:"list",name:"podName",choices:r,message:"Which pod? 🤔"})).podName}const{localPort:l}=await this.prompt({type:"number",name:"localPort",default:"30000",message:"Local port: "});const{env:d,componentName:h}=(0,n.parseChoice)(e);const m=await(0,n.getEnvVarsResolved)(this,d,h);const b=m===null||m===void 0?void 0:m.MONGODB_ROOT_PASSWORD;const y=`mongodb://root:${b}@localhost:${l}`;p.default.writeSync(y);this.log("");this.log("username: root");this.log(`password: ${b}`);this.log(`connection string: ${y}`);this.log("");this.log("👆 connection string has been copied to your clipboard!");this.log("");return(0,s.startKubePortForward)(i,l,27017,t)}))},38365:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});t.getProjectMongodbAllPodsSortedWithLabel=t.getMongoDbPodsWithReplInfo=t.podIsMaster=t.executeMongodbCommand=t.getMongodbShell=t.getProjectMongodbAllPods=void 0;const i=r(51748);const n=r(45198);const a=r(57414);const filterMongoDbs=e=>e.filter((e=>e.includes("mongodb")&&!e.includes("mongodb-backup")&&!e.includes("arbiter")));const getProjectMongodbAllPods=async e=>filterMongoDbs(await(0,n.getProjectPodNames)(e));t.getProjectMongodbAllPods=getProjectMongodbAllPods;const getMongodbShell=async(e,t)=>{const r=`kubectl exec -it ${t} --namespace ${e} mongo`;try{await(0,i.spawn)(r,{shell:true,stdio:"inherit",env:{...process.env,DEBUG:""}})}catch(e){}};t.getMongodbShell=getMongodbShell;const executeMongodbCommand=async(e,t,r)=>{const n=`kubectl exec -it ${t} --namespace ${e} -- mongo --quiet --eval "JSON.stringify(${r})"`;const{stdout:a}=await(0,i.exec)(n,{env:{...process.env,DEBUG:""}});return JSON.parse(a)};t.executeMongodbCommand=executeMongodbCommand;const podIsMaster=async(e,r)=>{try{const i=await(0,t.executeMongodbCommand)(e,r,"db.isMaster()");return i.ismaster}catch(e){return null}};t.podIsMaster=podIsMaster;const spaces=e=>" ".repeat(e);const getMongoDbPodsWithReplInfo=async e=>{const r=await(0,a.getProjectNamespace)(e);return(await Promise.all((await(0,t.getProjectMongodbAllPods)(e)).map((async e=>({podName:e,componentName:e.replace(/-mongodb-replicaset-[0-9]+/,""),isMaster:await(0,t.podIsMaster)(r,e)}))))).sort(((e,t)=>e.isMaster?t.isMaster?0:-1:1))};t.getMongoDbPodsWithReplInfo=getMongoDbPodsWithReplInfo;const getProjectMongodbAllPodsSortedWithLabel=async e=>{const r=await(0,t.getMongoDbPodsWithReplInfo)(e);const i=Math.max(...r.map((e=>e.componentName.length)));return r.map((({podName:e,isMaster:t,componentName:r})=>({value:e,name:`[ ${r}${spaces(i-r.length)} ${t?" PRIMARY ":" secondary "}] ${e}`})))};t.getProjectMongodbAllPodsSortedWithLabel=getProjectMongodbAllPodsSortedWithLabel},76512:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});const i=r(50001);const n=r(95540);const a=r(77992);const s=r(57151);const o=r(60241);const hasCloudSql=e=>{var t,r,i;const n=(t=e.deploy)===null||t===void 0?void 0:t.config;if((0,o.isOfDeployType)(n,"google-cloudrun")){return!!n.cloudSql}if((0,o.isOfDeployType)(n,"kubernetes")){return!!((i=(r=n.values)===null||r===void 0?void 0:r.cloudsql)===null||i===void 0?void 0:i.enabled)}return false};t["default"]=async e=>e.command("project-cloud-sql-restore-db","restores a project db from one source to another target").action((async function restoreDb(){var e,t,r,o,l;const c=await(0,i.getAllPipelineContexts)(undefined,{includeLocal:true});const u=c.filter(hasCloudSql);const sortByEnv=(e,t)=>{const r=e.startsWith("local:");const i=t.startsWith("local:");if(r!==i)return r?1:-1;return e.localeCompare(t)};const p=u.map((e=>`${e.env}:${e.name}`)).sort(sortByEnv);const d=u.map((e=>{const t=`${e.env}:${e.name}`;const r=e.environment.envType==="prod";return{name:r?`⚠️ ${t}`:t,value:t}})).sort(((e,t)=>sortByEnv(e.value,t.value)));const{sourceEnvAndComponent:h}=await this.prompt({type:"list",name:"sourceEnvAndComponent",choices:p,message:"Source instance (connection string or 'local')? 🤔 "});const[m,b]=h.split(":");const y=await(0,i.getPipelineContextByChoice)(m,b);const g=await(0,i.getEnvVarsResolved)(this,y.env,y.name);let v;let w;let j;let O;let _;let k;let C;let P;let z;let R;const closeAll=()=>{v===null||v===void 0?void 0:v.stop();C===null||C===void 0?void 0:C.stop()};if(m==="local"){const r=(0,a.parseConnectionString)(g.DATABASE_URL.toString());P=(t=(e=r.hosts)===null||e===void 0?void 0:e[0])===null||t===void 0?void 0:t.port;j=r.username;O=r.password;w=r.endpoint}else{P=54399;v=await(0,n.startCloudSqlProxyInBackground)({instanceName:g.CLOUD_SQL_INSTANCE_CONNECTION_NAME.toString(),localPort:P});j=g.DB_USER.toString();O=g.DB_PASSWORD.toString();w=(r=g.DB_NAME)===null||r===void 0?void 0:r.toString()}const{targetEnvAndComponent:x}=await this.prompt({type:"list",name:"targetEnvAndComponent",choices:d,message:"target env? 🤔 "});const[V,N]=x.split(":");const D=await(0,i.getPipelineContextByChoice)(V,N);const I=await(0,i.getEnvVarsResolved)(this,D.env,D.name);if(V==="local"){const e=(0,a.parseConnectionString)(I.DATABASE_URL.toString());z=(l=(o=e.hosts)===null||o===void 0?void 0:o[0])===null||l===void 0?void 0:l.port;_=e.username;k=e.password;R=e.endpoint}else{z=54499;C=await(0,n.startCloudSqlProxyInBackground)({instanceName:I.CLOUD_SQL_INSTANCE_CONNECTION_NAME.toString(),localPort:z});_=I.DB_USER.toString();k=I.DB_PASSWORD.toString();R=I.DB_NAME.toString()}const{shouldContinue:q}=await this.prompt({type:"confirm",name:"shouldContinue",message:`This will drop ${V}/${R} and replace it with ${m}/${w}. Continue? 🤔 `});if(!q){this.log("abort");closeAll();return}if(D.environment.envType==="prod"){this.log(`\n🚨 You are overriding a production environment. Please type in ${I.CLOUD_SQL_INSTANCE_CONNECTION_NAME} to continue\n\n`);const{confirmInstance:e}=await this.prompt({type:"input",name:"confirmInstance",message:"confirm: "});if(e!==I.CLOUD_SQL_INSTANCE_CONNECTION_NAME){this.log("abort");closeAll();return}}try{await(0,s.spawnCopyDb)({targetPassword:k,targetPort:z,targetUsername:_,sourceUsername:j,sourcePassword:O,sourcePort:P,sourceDbName:w,targetDbName:R})}finally{closeAll()}}))},29020:function(e,t,r){"use strict";var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:true});const n=r(60241);const a=i(r(77983));const s=r(50001);const o=r(52468);const l=r(95540);const c=r(67253);const getProxyInfo=e=>{var t,r,i,a;if((0,n.isOfDeployType)((t=e.deploy)===null||t===void 0?void 0:t.config,"kubernetes")){return getProxyInfoForKubernetes(this,e)}else if((0,n.isOfDeployType)((r=e.deploy)===null||r===void 0?void 0:r.config,"google-cloudrun")){return getProxyInfoForCloudRun(this,e)}throw new Error(`unsupported environment: ${(a=(i=e.deploy)===null||i===void 0?void 0:i.config)===null||a===void 0?void 0:a.type}`)};const getProxyInfoForKubernetes=async(e,t)=>{var r,i;if(!(0,n.isOfDeployType)((r=t.deploy)===null||r===void 0?void 0:r.config,"kubernetes")){throw new Error("unsupported")}const a=await(0,s.getEnvVarsResolved)(e,t.env,t.name);const o=(0,n.createKubernetesCloudsqlBaseValues)(t);const l=(i=(a===null||a===void 0?void 0:a.DB_PASSWORD)||(a===null||a===void 0?void 0:a.POSTGRESQL_PASSWORD))===null||i===void 0?void 0:i.toString();const c=o.cloudsql.fullDbName.toString();const u=o.cloudsql.instanceConnectionName;return{instanceName:u,DB_PASSWORD:l,DB_NAME:c,DB_USER:"postgres"}};const getProxyInfoForCloudRun=async(e,t)=>{var r,i,a,o,l,u;if(!(0,n.isOfDeployType)((r=t.deploy)===null||r===void 0?void 0:r.config,"google-cloudrun")||!((i=t.deploy)===null||i===void 0?void 0:i.config.cloudSql)){const r=(0,n.getDeployConfigType)((a=t.deploy)===null||a===void 0?void 0:a.config);const i=r==="google-cloudrun"?`DeployConfig is missing the cloudSql property`:`Unsupported DeployConfig type: ${r}`;(0,c.logError)(e,i);throw new Error(i)}const p=await(0,s.getEnvVarsResolved)(e,t.env,t.name);return{instanceName:(o=t.deploy)===null||o===void 0?void 0:o.config.cloudSql.instanceConnectionName,DB_PASSWORD:(l=p===null||p===void 0?void 0:p.DB_PASSWORD)===null||l===void 0?void 0:l.toString(),DB_NAME:t.environment.envVars.DB_NAME.toString(),DB_USER:(u=p===null||p===void 0?void 0:p.DB_USER)===null||u===void 0?void 0:u.toString()}};const getDbUrl=({DB_PASSWORD:e,DB_NAME:t,DB_USER:r},i,n="")=>`DATABASE_URL="postgresql://${r}:${e}@localhost:${i}/${t}${n}"`;const getJdbcUrl=({DB_PASSWORD:e,DB_NAME:t,DB_USER:r},i)=>`DATABASE_JDBC_URL="jdbc:postgresql://localhost:${i}/${t}?schema=public&user=${r}&password=${e}"`;t["default"]=async e=>e.command("project-cloud-sql-proxy <envComponent>","proxy to cloud sql db").autocomplete(await(0,o.envAndComponents)()).action((async function({envComponent:e}){const{env:t,componentName:r}=(0,s.parseChoice)(e);if(!r){(0,c.logWarning)(this,"need componentName");return}const i=await(0,s.getPipelineContextByChoice)(t,r);if(t==="review"){(0,c.logWarning)(this,"connection string does not include mr information on review environments")}const{localPort:n}=await this.prompt({type:"number",name:"localPort",default:"54320",message:"Local port: "});const o=await getProxyInfo(i);const u={PGPASSWORD:o.DB_PASSWORD,PGUSER:o.DB_USER,PGDATABASE:o.DB_NAME,PGHOST:"localhost",PGPORT:n};const p=Object.entries(u).map((([e,t])=>`${e}="${t}"`));const d=getDbUrl(o,n);const h=getJdbcUrl(o,n);a.default.writeSync(["","## CloudSQL proxy connection .env variables",d,h,"## DATABASE_URL with schema=public parameter (e. g. Prisma requires this):",`# ${getDbUrl(o,n,`?schema=public`)}`,"## Env variables for libpq (e.g. psql client https://www.postgresql.org/docs/current/libpq-envars.html#LIBPQ-ENVARS)",...p,""].join("\n"));(0,c.logLines)(this,null,"Connection strings env variables DATABASE_URL and those for the 'psql' client (copied to your clipboard for .env file):",d,h,...p,null,"DATABASE_URL with schema=public parameter (e. g. Prisma requires this):",getDbUrl(o,n,`?schema=public`),null);try{await(0,l.startCloudSqlProxyInCurrentShell)({instanceName:o.instanceName,localPort:n})}catch(e){if(!(e instanceof Error))throw e;if(e.message!==l.ERROR_NOT_INSTALLED)throw e;(0,c.logError)(this,e.message,null,"Please install the Cloud SQL Auth Proxy from:",`https://cloud.google.com/sql/docs/postgres/connect-auth-proxy#install`,null)}}))},58002:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});t.projectConfigSecrets=void 0;const i=r(60241);const n=r(63779);const a=r(49250);const s=r(50001);const o=r(82805);const l=r(4508);const c=r(51762);const u=r(52468);const resolveJson=e=>Object.fromEntries(Object.entries(e).map((([e,t])=>[e,Object.fromEntries(Object.entries(t).map((([e,t])=>[e,Object.fromEntries(Object.entries(t).map((([e,t])=>{try{return[e,JSON.parse(t)]}catch(r){return[e,t]}})))])))])));const getSecretEnvVarKeysToConfigure=async(e,t)=>{const{secretEnvVarKeys:r,jobOnlyVars:i}=await(0,s.getEnvironment)(e,t);return[...i.build.secretEnvVarKeys,...i.deploy.secretEnvVarKeys,...r].filter((e=>!e.hidden)).map((e=>e.key))};const getEnvVarsToEdit=async(e,t,r)=>{const n=await getSecretEnvVarKeysToConfigure(t,r);const a=await(0,s.getEnvVarsResolved)(e,t,r);const o=await(0,s.getJobOnlyEnvVarsResolved)(e,t,r);const l={...a,...o};return Object.fromEntries(n.map((e=>{const n=l[e];const a=n==="$"+(0,i.getSecretVarName)(t,r,e);return[e,a?"🚨 FILL ME":n]})))};const doItFor=async(e,t)=>{let r=Object.fromEntries(await Promise.all(Object.entries(t).map((async([t,r])=>[t,Object.fromEntries(await Promise.all(r.map((async r=>[r,await getEnvVarsToEdit(e,r,t)]))))]))));let i=true;while(i){r=await(0,o.editAsFile)(resolveJson(r),(0,n.stripIndents)`
|
|
2
2
|
Please fill in all secrets for:
|
|
3
3
|
|
|
4
4
|
${Object.entries(t).map((([e,t])=>`- ${e}: ${t.join(", ")}`)).join("\n")}
|
|
@@ -23,16 +23,27 @@ exports.default = async (vorpal) => vorpal
|
|
|
23
23
|
const allContexts = await (0, getProjectConfig_1.getAllPipelineContexts)(undefined, {
|
|
24
24
|
includeLocal: true,
|
|
25
25
|
});
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
.map((c) => `${c.env}:${c.name}`)
|
|
29
|
-
.sort((a, b) => {
|
|
26
|
+
const filteredContexts = allContexts.filter(hasCloudSql);
|
|
27
|
+
const sortByEnv = (a, b) => {
|
|
30
28
|
const aLocal = a.startsWith("local:");
|
|
31
29
|
const bLocal = b.startsWith("local:");
|
|
32
30
|
if (aLocal !== bLocal)
|
|
33
31
|
return aLocal ? 1 : -1;
|
|
34
32
|
return a.localeCompare(b);
|
|
35
|
-
}
|
|
33
|
+
};
|
|
34
|
+
const envs = filteredContexts
|
|
35
|
+
.map((c) => `${c.env}:${c.name}`)
|
|
36
|
+
.sort(sortByEnv);
|
|
37
|
+
const targetEnvChoices = filteredContexts
|
|
38
|
+
.map((c) => {
|
|
39
|
+
const value = `${c.env}:${c.name}`;
|
|
40
|
+
const isProd = c.environment.envType === "prod";
|
|
41
|
+
return {
|
|
42
|
+
name: isProd ? `⚠️ ${value}` : value,
|
|
43
|
+
value,
|
|
44
|
+
};
|
|
45
|
+
})
|
|
46
|
+
.sort((a, b) => sortByEnv(a.value, b.value));
|
|
36
47
|
const { sourceEnvAndComponent } = await this.prompt({
|
|
37
48
|
type: "list",
|
|
38
49
|
name: "sourceEnvAndComponent",
|
|
@@ -76,7 +87,7 @@ exports.default = async (vorpal) => vorpal
|
|
|
76
87
|
const { targetEnvAndComponent } = await this.prompt({
|
|
77
88
|
type: "list",
|
|
78
89
|
name: "targetEnvAndComponent",
|
|
79
|
-
choices:
|
|
90
|
+
choices: targetEnvChoices,
|
|
80
91
|
message: "target env? 🤔 ",
|
|
81
92
|
});
|
|
82
93
|
const [targetEnv, targetComponent] = targetEnvAndComponent.split(":");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commandProjectRestoreDb.js","sourceRoot":"","sources":["../../../../../../../../src/apps/cli/commands/project/cloudSql/commandProjectRestoreDb.ts"],"names":[],"mappings":";;AACA,6EAIgD;AAEhD,0EAA2F;AAE3F,gGAA6F;AAC7F,kEAAoE;AAEpE,kDAAqD;AAErD,MAAM,WAAW,GAAG,CAAC,OAAyB,EAAE,EAAE;;IAChD,MAAM,YAAY,GAAG,MAAA,OAAO,CAAC,MAAM,0CAAE,MAAM,CAAC;IAC5C,IAAI,IAAA,yBAAc,EAAC,YAAY,EAAE,iBAAiB,CAAC,EAAE,CAAC;QACpD,OAAO,CAAC,CAAC,YAAY,CAAC,QAAQ,CAAC;IACjC,CAAC;IACD,IAAI,IAAA,yBAAc,EAAC,YAAY,EAAE,YAAY,CAAC,EAAE,CAAC;QAC/C,OAAO,CAAC,CAAC,CAAA,MAAA,MAAA,YAAY,CAAC,MAAM,0CAAE,QAAQ,0CAAE,OAAO,CAAA,CAAC;IAClD,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF,kBAAe,KAAK,EAAE,MAAc,EAAE,EAAE,CACtC,MAAM;KACH,OAAO,CACN,8BAA8B,EAC9B,yDAAyD,CAC1D;KACA,MAAM,CAAC,KAAK,UAAU,SAAS;;IAC9B,MAAM,WAAW,GAAG,MAAM,IAAA,yCAAsB,EAAC,SAAS,EAAE;QAC1D,YAAY,EAAE,IAAI;KACnB,CAAC,CAAC;IACH,MAAM,
|
|
1
|
+
{"version":3,"file":"commandProjectRestoreDb.js","sourceRoot":"","sources":["../../../../../../../../src/apps/cli/commands/project/cloudSql/commandProjectRestoreDb.ts"],"names":[],"mappings":";;AACA,6EAIgD;AAEhD,0EAA2F;AAE3F,gGAA6F;AAC7F,kEAAoE;AAEpE,kDAAqD;AAErD,MAAM,WAAW,GAAG,CAAC,OAAyB,EAAE,EAAE;;IAChD,MAAM,YAAY,GAAG,MAAA,OAAO,CAAC,MAAM,0CAAE,MAAM,CAAC;IAC5C,IAAI,IAAA,yBAAc,EAAC,YAAY,EAAE,iBAAiB,CAAC,EAAE,CAAC;QACpD,OAAO,CAAC,CAAC,YAAY,CAAC,QAAQ,CAAC;IACjC,CAAC;IACD,IAAI,IAAA,yBAAc,EAAC,YAAY,EAAE,YAAY,CAAC,EAAE,CAAC;QAC/C,OAAO,CAAC,CAAC,CAAA,MAAA,MAAA,YAAY,CAAC,MAAM,0CAAE,QAAQ,0CAAE,O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