@kui-shell/plugin-tekton
Version:
Visualizations for Tekton Pipelines
54 lines • 2.13 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());
});
};
import { fetchTask } from '../../lib/read';
const usage = (command) => ({
command,
strict: command,
required: [{ name: 'pipelineName', docs: 'Name of the pipeline' }],
optional: [
{ name: 'taskName', docs: 'Name of the task', positional: true },
{ name: '--file', alias: '-f', docs: 'Path to resource specification' }
]
});
const getTask = (cmd) => ({ tab, argvNoOptions, parsedOptions }) => __awaiter(void 0, void 0, void 0, function* () {
const pipelineName = argvNoOptions[argvNoOptions.indexOf(cmd) + 1];
const taskName = argvNoOptions[argvNoOptions.indexOf(cmd) + 2];
const task = yield fetchTask(tab, pipelineName, taskName, parsedOptions.f);
if (!task) {
const err = new Error('task not found');
err.code = 404;
throw err;
}
else if (!taskName) {
return task;
}
else {
return {
type: 'custom',
isEntity: true,
prettyType: 'task',
name: taskName,
packageName: pipelineName,
contentType: 'yaml',
content: task
};
}
});
export default (commandTree) => {
commandTree.listen('/tekton/get/task', getTask('task'), {
usage: usage('task'),
noAuthOk: true
});
commandTree.listen('/tekton/get/tasks', getTask('tasks'), {
usage: usage('tasks'),
noAuthOk: true
});
};
//# sourceMappingURL=task.js.map