catch setup resource errors
parent
4384dbfb25
commit
08e76e950d
|
|
@ -1392,6 +1392,25 @@ exports.default = Kubernetes;
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||||
|
}) : (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
o[k2] = m[k];
|
||||||
|
}));
|
||||||
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||||
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||||
|
}) : function(o, v) {
|
||||||
|
o["default"] = v;
|
||||||
|
});
|
||||||
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
|
if (mod && mod.__esModule) return mod;
|
||||||
|
var result = {};
|
||||||
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
|
__setModuleDefault(result, mod);
|
||||||
|
return result;
|
||||||
|
};
|
||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
|
|
@ -1404,6 +1423,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
const client_node_1 = __webpack_require__(89679);
|
const client_node_1 = __webpack_require__(89679);
|
||||||
const cron_converter_1 = __webpack_require__(89926);
|
const cron_converter_1 = __webpack_require__(89926);
|
||||||
|
const core = __importStar(__webpack_require__(42186));
|
||||||
class KubernetesCleanupCronJob {
|
class KubernetesCleanupCronJob {
|
||||||
static cleanup(api, name, namespace) {
|
static cleanup(api, name, namespace) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
|
@ -1423,6 +1443,7 @@ class KubernetesCleanupCronJob {
|
||||||
};
|
};
|
||||||
const cronInstance = new cron_converter_1.Cron();
|
const cronInstance = new cron_converter_1.Cron();
|
||||||
const date = Date.now() + 1000 * 60 * 60;
|
const date = Date.now() + 1000 * 60 * 60;
|
||||||
|
const cronString = cronInstance.schedule(new Date(date)).toString();
|
||||||
const spec = {
|
const spec = {
|
||||||
containers: [
|
containers: [
|
||||||
{
|
{
|
||||||
|
|
@ -1442,14 +1463,16 @@ class KubernetesCleanupCronJob {
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
batchJob.spec = {
|
batchJob.spec = {
|
||||||
schedule: cronInstance.schedule(new Date(date)).toString(),
|
schedule: cronString,
|
||||||
jobTemplate: {
|
jobTemplate: {
|
||||||
spec: {
|
spec: {
|
||||||
template: { spec },
|
template: { spec },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
core.info('creating cron job');
|
||||||
yield kubeClientBatch.createNamespacedCronJob(namespace, batchJob);
|
yield kubeClientBatch.createNamespacedCronJob(namespace, batchJob);
|
||||||
|
core.info('created cron job');
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
throw error;
|
throw error;
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -1,5 +1,6 @@
|
||||||
import { BatchV1beta1Api, V1beta1CronJob } from '@kubernetes/client-node';
|
import { BatchV1beta1Api, V1beta1CronJob } from '@kubernetes/client-node';
|
||||||
import { Cron } from 'cron-converter';
|
import { Cron } from 'cron-converter';
|
||||||
|
import * as core from '@actions/core';
|
||||||
class KubernetesCleanupCronJob {
|
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);
|
||||||
|
|
@ -16,6 +17,7 @@ class KubernetesCleanupCronJob {
|
||||||
};
|
};
|
||||||
const cronInstance = new Cron();
|
const cronInstance = new Cron();
|
||||||
const date = Date.now() + 1000 * 60 * 60;
|
const date = Date.now() + 1000 * 60 * 60;
|
||||||
|
const cronString = cronInstance.schedule(new Date(date)).toString();
|
||||||
const spec = {
|
const spec = {
|
||||||
containers: [
|
containers: [
|
||||||
{
|
{
|
||||||
|
|
@ -35,7 +37,7 @@ class KubernetesCleanupCronJob {
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
batchJob.spec = {
|
batchJob.spec = {
|
||||||
schedule: cronInstance.schedule(new Date(date)).toString(),
|
schedule: cronString,
|
||||||
jobTemplate: {
|
jobTemplate: {
|
||||||
spec: {
|
spec: {
|
||||||
template: { spec },
|
template: { spec },
|
||||||
|
|
@ -43,7 +45,9 @@ class KubernetesCleanupCronJob {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
core.info('creating cron job');
|
||||||
await kubeClientBatch.createNamespacedCronJob(namespace, batchJob);
|
await kubeClientBatch.createNamespacedCronJob(namespace, batchJob);
|
||||||
|
core.info('created cron job');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue