Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"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 k8s = require("@kubernetes/client-node");
const Table = require("easy-table");
const kc = new k8s.KubeConfig();
kc.loadFromDefault();
const appsV1Api = kc.makeApiClient(k8s.AppsV1Api);
const coreV1Api = kc.makeApiClient(k8s.CoreV1Api);
const roles = ['blue', 'green'];
getDeployments().catch(console.error.bind(console));
function getDeployments() {
return __awaiter(this, void 0, void 0, function* () {
const deploymentsRes = yield appsV1Api.listNamespacedDeployment('default');
let deployments = [];
for (const deployment of deploymentsRes.body.items) {
let role = deployment.spec.template.metadata.labels.role;
if (role && roles.includes(role)) {
deployments.push({
name: deployment.metadata.name,
role,
status: deployment.status.conditions[0].status,
image: deployment.spec.template.spec.containers[0].image,
ports: [],
import * as k8s from '@kubernetes/client-node';
import * as Table from 'easy-table';
const kc = new k8s.KubeConfig();
kc.loadFromDefault();
const appsV1Api = kc.makeApiClient(k8s.AppsV1Api);
const coreV1Api = kc.makeApiClient(k8s.CoreV1Api);
const roles = ['blue', 'green'];
getDeployments().catch(console.error.bind(console));
async function getDeployments() {
const deploymentsRes = await appsV1Api.listNamespacedDeployment('default');
let deployments = [];
for (const deployment of deploymentsRes.body.items) {
let role = deployment.spec.template.metadata.labels.role;
if (role && roles.includes(role)) {
deployments.push({
name: deployment.metadata.name,
role,
status: deployment.status.conditions[0].status,
image: deployment.spec.template.spec.containers[0].image,
constructor() {
const kc = new k8s.KubeConfig();
kc.loadFromCluster();
this.CoreV1Api = kc.makeApiClient(k8s.CoreV1Api);
this.AppsV1Api = kc.makeApiClient(k8s.AppsV1Api);
this.ExtensionsV1beta1Api = kc.makeApiClient(k8s.ExtensionsV1beta1Api);
}
constructor() {
const kc = new k8s.KubeConfig();
kc.loadFromCluster();
this.k8sAppsApi = kc.makeApiClient(k8s.AppsV1Api);
this.k8sCoreApi = kc.makeApiClient(k8s.CoreV1Api);
}