@kui-shell/plugin-tekton
Version:
Visualizations for Tekton Pipelines
78 lines • 3.47 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 core_1 = require("@kui-shell/core");
const strings = core_1.i18n('plugin-tekton', 'modes');
const mode = {
mode: 'Logs',
label: strings('logs'),
content: (tab, run) => __awaiter(void 0, void 0, void 0, function* () {
const [{ items: taskRuns }, { items: pods }] = yield Promise.all([
tab.REPL.qexec(`kubectl get taskrun -l tekton.dev/pipelineRun=${run.metadata.name} -o json`),
tab.REPL.qexec(`kubectl get pods -n ${run.metadata.namespace} -l tekton.dev/pipelineRun=${run.metadata.name} -o json`)
]);
const containers = core_1.flatten(pods.map(pod => {
const taskName = pod.metadata.labels['tekton.dev/task'];
const taskRun = taskRuns.find(_ => _.metadata.labels['tekton.dev/task'] === taskName);
return pod.spec.containers.map((container, idx) => {
const { containerID } = pod.status.containerStatuses[idx];
const stepRun = taskRun.status.steps.find(_ => _.terminated.containerID === containerID);
const status = stepRun && stepRun.terminated.reason;
return {
name: taskName,
css: 'slightly-deemphasize',
onclick: `kubectl get task ${taskName} -o yaml`,
attributes: [
{
key: 'STEP',
value: container.name
},
{
key: 'STATUS',
value: status,
tag: 'badge'
},
{
key: 'ACTIONS',
value: 'View Logs',
outerCSS: 'clickable clickable-color',
onclick: `kubectl logs ${pod.metadata.name} ${container.name} -n ${pod.metadata.namespace}`
}
]
};
});
}));
const table = {
title: 'Container Logs',
body: containers,
header: {
name: 'TASK',
attributes: [
{
key: 'STEP',
value: 'STEP'
},
{
key: 'STATUS',
value: 'STATUS'
},
{
key: 'ACTIONS',
value: 'ACTIONS'
}
]
}
};
return table;
})
};
exports.default = mode;
//# sourceMappingURL=logs.js.map