-
Notifications
You must be signed in to change notification settings - Fork 0
/
teardown.js
39 lines (32 loc) · 902 Bytes
/
teardown.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
const config = require(`./config-${process.env.NODE_ENV}`);
const { exec } = require("child_process");
const namespace = config.namespace;
const actions = {
async execCommand(command) {
console.log(`$ ${command}`);
const out = await await new Promise((resolve, reject) => {
exec(command, (err, stdout, stderr) => {
if(err) reject(err);
else if(stderr) reject(stderr);
else if(stdout) resolve(stdout);
});
});
console.log(`${out}\n`);
return out;
},
async deleteNamespace() {
await actions.execCommand(`kubectl delete namespace ${namespace}`);
},
async deletePersistentVolume() {
await actions.execCommand(`kubectl delete pv postgres-pv-${namespace}`);
}
};
async function init() {
await actions.deleteNamespace();
await actions.deletePersistentVolume();
}
init();
process.on("unhandledRejection", err => {
console.error(err.stack);
process.exit(1);
});