UNPKG

kui-shell

Version:

This is the monorepo for Kui, the hybrid command-line/GUI electron-based Kubernetes tool

51 lines 2.55 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 }); const debug_1 = require("debug"); const i18n_1 = require("@kui-shell/core/api/i18n"); const repl_util_1 = require("@kui-shell/core/api/repl-util"); const strings = i18n_1.i18n('plugin-k8s'); const debug = debug_1.default('k8s/view/modes/status'); exports.statusButton = (command, resource, finalState, overrides) => Object.assign({}, { mode: 'status', label: strings('status'), direct: { plugin: 'k8s/dist/index', operation: 'renderAndViewStatus', parameters: { command, resource, finalState } } }, overrides || {}); exports.renderStatus = (tab, command, resource, finalState) => __awaiter(void 0, void 0, void 0, function* () { debug('renderStatus', command, resource.filepathForDrilldown, resource.kind, resource.name, finalState, resource.resource); const final = command === 'kubectl' ? `--final-state ${finalState.toString()}` : ''; const commandForRepl = command === 'kubectl' ? 'k8s' : command; const fetchModels = `${commandForRepl} status ${repl_util_1.encodeComponent(resource.filepathForDrilldown || resource.kind || resource.resource.kind)} ${repl_util_1.encodeComponent(resource.name)} ${final} -n "${resource.resource.metadata.namespace}"`; debug('issuing command', fetchModels); try { const model = yield tab.REPL.qexec(fetchModels); debug('renderStatus.models', model); return model; } catch (error) { const err = error; if (err.code === 404) { return { body: [] }; } else { throw err; } } }); exports.renderAndViewStatus = (tab, parameters) => { const { command, resource, finalState } = parameters; return exports.renderStatus(tab, command, resource, finalState); }; //# sourceMappingURL=status.js.map