UNPKG

@fbl-plugins/k8s-kubectl

Version:
88 lines 3.48 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 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) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.WaitActionProcessor = void 0; const Joi = require("joi"); const BaseActionProcessor_1 = require("./BaseActionProcessor"); class WaitActionProcessor extends BaseActionProcessor_1.BaseActionProcessor { /** * @inheritdoc */ getValidationSchema() { return WaitActionProcessor.validationSchema; } /** * @inheritdoc */ execute() { return __awaiter(this, void 0, void 0, function* () { const args = yield this.prepareCLIArgs(); yield this.execKubectlCommand(args, this.options.debug); }); } /** * Prepare CLI args */ prepareCLIArgs() { return __awaiter(this, void 0, void 0, function* () { const args = ['wait']; this.pushWithValue(args, '--namespace', this.options.namespace); this.pushWithValue(args, '--timeout', this.options.timeout); this.pushWithoutValue(args, '--all', this.options.all); if (this.options.extra) { args.push(...this.options.extra); } if (this.options.for.delete) { args.push('--for=delete'); } if (this.options.for.condition) { args.push(`--for=condition=${this.options.for.condition}`); } if (this.options.labels) { for (const label of Object.keys(this.options.labels)) { const value = this.options.labels[label]; args.push('-l', `${label}=${value}`); } } args.push(this.options.resource); if (this.options.name) { args.push(this.options.name); } return args; }); } } exports.WaitActionProcessor = WaitActionProcessor; WaitActionProcessor.validationSchema = Joi.object({ resource: Joi.string().min(1).required(), name: Joi.string().min(1), labels: Joi.object().pattern(Joi.string().min(1).required(), Joi.string().required().min(1)), all: Joi.boolean(), for: Joi.object({ delete: Joi.boolean(), condition: Joi.string().min(1), }) .xor('delete', 'condition') .required() .options({ abortEarly: true, allowUnknown: false }), // enable verbose output debug: Joi.boolean(), // Namespace namespace: Joi.string(), timeout: Joi.string().min(1), // extra arguments to append to the command // refer to `kubectl wait --help` for all available options extra: Joi.array().items(Joi.string()), }) .xor('name', 'labels', 'all') .required() .options({ abortEarly: true, allowUnknown: false }); //# sourceMappingURL=WaitActionProcessor.js.map