@kui-shell/plugin-tekton
Version:
Visualizations for Tekton Pipelines
56 lines • 2.39 kB
JavaScript
;
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 });
const read_1 = require("../../lib/read");
const usage = {
command: 'step',
strict: 'step',
required: [
{ name: 'pipelineName', docs: 'Name of the enclosing pipeline' },
{ name: 'taskName', docs: 'Name of the enclosing task' },
{ name: 'stepName', docs: 'Name of the step' }
],
optional: [{ name: '--file', alias: '-f', docs: 'Path to resource specification' }]
};
const getStep = ({ tab, argvNoOptions, parsedOptions }) => __awaiter(void 0, void 0, void 0, function* () {
const pipelineName = argvNoOptions[argvNoOptions.indexOf('step') + 1];
const taskName = argvNoOptions[argvNoOptions.indexOf('step') + 2];
const stepName = argvNoOptions[argvNoOptions.indexOf('step') + 3];
const task = yield read_1.fetchTask(tab, pipelineName, taskName, parsedOptions.f);
if (!task) {
const err = new Error('task not found');
err.code = 404;
throw err;
}
else {
const step = task.spec.steps && task.spec.steps.find(_ => _.name === stepName);
if (!step) {
const err = new Error('step not found');
err.code = 404;
throw err;
}
else {
return {
type: 'custom',
isEntity: true,
prettyType: 'step',
name: stepName,
packageName: taskName,
contentType: 'yaml',
content: step
};
}
}
});
exports.default = (commandTree) => {
commandTree.listen('/tekton/get/step', getStep, { usage, noAuthOk: true });
};
//# sourceMappingURL=step.js.map