@topgroup/diginext
Version:
A BUILD SERVER & CLI to deploy apps to any Kubernetes clusters.
42 lines (41 loc) • 1.81 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.checkCertManagerInstalled = exports.checkNginxIngressInstalled = void 0;
const string_1 = require("../../plugins/string");
const index_1 = __importDefault(require("./index"));
/**
* Check the cluster has NGINX Ingress installed or not
* @copyright https://kubernetes.github.io/ingress-nginx/
* @returns Error message in string or TRUE
*/
const checkNginxIngressInstalled = async (cluster) => {
const { slug, contextName: context, isVerified } = cluster;
if (!isVerified)
return `Cluster (${slug}) hasn't been verified yet.`;
const allNamespaces = await index_1.default.getAllNamespaces({ context });
let nginxIngressInstalled = false;
if (allNamespaces.length > 0) {
allNamespaces.map((ns) => {
if ((0, string_1.contains)(ns.metadata.name, ["nginx", "ingress"]))
nginxIngressInstalled = true;
});
}
return nginxIngressInstalled;
};
exports.checkNginxIngressInstalled = checkNginxIngressInstalled;
/**
* Check the cluster has Cert Manager installed or not
* @copyright https://cert-manager.io/
* @returns Error message in string or TRUE
*/
const checkCertManagerInstalled = async (cluster) => {
const { slug, contextName: context, isVerified } = cluster;
if (!isVerified)
return `Cluster (${slug}) hasn't been verified yet.`;
const certManagerNamespaces = await index_1.default.getAllNamespaces({ context, filterLabel: "kubernetes.io/metadata.name=cert-manager" });
return certManagerNamespaces.length > 0;
};
exports.checkCertManagerInstalled = checkCertManagerInstalled;