catch setup resource errors

pull/273/head
Frostebite 2021-06-26 03:00:49 +01:00
parent aa15eda155
commit 4384dbfb25
3 changed files with 43 additions and 41 deletions

78
dist/index.js vendored
View File

@ -1411,48 +1411,50 @@ class KubernetesCleanupCronJob {
}); });
} }
static createCleanupCronJob(kubeClientBatch, name, namespace) { static createCleanupCronJob(kubeClientBatch, name, namespace) {
try { return __awaiter(this, void 0, void 0, function* () {
const batchJob = new client_node_1.V1beta1CronJob(); try {
batchJob.kind = 'CronJob'; const batchJob = new client_node_1.V1beta1CronJob();
batchJob.metadata = { batchJob.kind = 'CronJob';
name, batchJob.metadata = {
labels: { name,
app: 'unity-builder', labels: {
}, app: 'unity-builder',
}; },
const cronInstance = new cron_converter_1.Cron(); };
const date = Date.now() + 1000 * 60 * 60; const cronInstance = new cron_converter_1.Cron();
const spec = { const date = Date.now() + 1000 * 60 * 60;
containers: [ const spec = {
{ containers: [
name: 'main', {
image: 'bitnami/kubectl', name: 'main',
imagePullPolicy: '', image: 'bitnami/kubectl',
command: ['/bin/sh'], imagePullPolicy: '',
args: [ command: ['/bin/sh'],
'-c', args: [
` '-c',
`
echo "delete the kubernetes resources" echo "delete the kubernetes resources"
kubectl get pods kubectl get pods
`, `,
], ],
restartPolicy: '', restartPolicy: '',
},
],
};
batchJob.spec = {
schedule: cronInstance.schedule(new Date(date)).toString(),
jobTemplate: {
spec: {
template: { spec },
},
}, },
], };
}; yield kubeClientBatch.createNamespacedCronJob(namespace, batchJob);
batchJob.spec = { }
schedule: cronInstance.schedule(new Date(date)).toString(), catch (error) {
jobTemplate: { throw error;
spec: { }
template: { spec }, });
},
},
};
kubeClientBatch.createNamespacedCronJob(namespace, batchJob);
}
catch (error) {
throw error;
}
} }
} }
exports.default = KubernetesCleanupCronJob; exports.default = KubernetesCleanupCronJob;

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,7 @@ class KubernetesCleanupCronJob {
static async cleanup(api: BatchV1beta1Api, name: string, namespace: string) { static async cleanup(api: BatchV1beta1Api, name: string, namespace: string) {
await api.deleteNamespacedCronJob('name', namespace); await api.deleteNamespacedCronJob('name', namespace);
} }
static createCleanupCronJob(kubeClientBatch: BatchV1beta1Api, name: string, namespace: string) { static async createCleanupCronJob(kubeClientBatch: BatchV1beta1Api, name: string, namespace: string) {
try { try {
const batchJob = new V1beta1CronJob(); const batchJob = new V1beta1CronJob();
batchJob.kind = 'CronJob'; batchJob.kind = 'CronJob';
@ -43,7 +43,7 @@ class KubernetesCleanupCronJob {
}, },
}; };
kubeClientBatch.createNamespacedCronJob(namespace, batchJob); await kubeClientBatch.createNamespacedCronJob(namespace, batchJob);
} catch (error) { } catch (error) {
throw error; throw error;
} }