@apigeeks/fbl-k8s-plugin
Version:
fbl wrapper plugin for helm and kubectl cli utilities
75 lines • 2.51 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const Joi = require("joi");
const typedi_1 = require("typedi");
const fbl_1 = require("fbl");
const services_1 = require("../services");
class K8sCleanupActionHandler extends fbl_1.ActionHandler {
constructor() {
super(...arguments);
/**
* {@inheritDoc}
*/
this.metadata = {
id: 'a6s.k8s.cleanup',
aliases: ['k8s.cleanup'],
};
/**
* {@inheritDoc}
*/
this.schema = Joi.object()
.keys({
dryRun: Joi.boolean(),
namespace: Joi.string()
.min(1)
.required(),
kinds: Joi.array()
.min(1)
.items(Joi.string().required()),
ignored: Joi.object().keys({
objects: Joi.object().pattern(/\w+/, Joi.array()
.min(1)
.items(Joi.string().required())),
helms: Joi.array()
.min(1)
.items(Joi.string().required()),
}),
})
.required()
.options({
abortEarly: true,
});
}
/**
* {@inheritDoc}
*/
/* istanbul ignore next */
getMetadata() {
return this.metadata;
}
/**
* {@inheritDoc}
*/
getValidationSchema() {
return this.schema;
}
/**
* {@inheritDoc}
*/
execute(options, context, snapshot, parameters) {
return __awaiter(this, void 0, void 0, function* () {
const k8sCleanupService = typedi_1.default.get(services_1.K8sCleanupService);
yield k8sCleanupService.cleanup(options, context, snapshot);
});
}
}
exports.K8sCleanupActionHandler = K8sCleanupActionHandler;
//# sourceMappingURL=K8sCleanupActionHandler.js.map