UNPKG

@hashgraph/solo

Version:

An opinionated CLI tool to deploy and manage private Hedera Networks.

134 lines 5.04 kB
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; var __param = (this && this.__param) || function (paramIndex, decorator) { return function (target, key) { decorator(target, key, paramIndex); } }; import * as constants from './constants.js'; import { patchInject } from './dependency_injection/container_helper.js'; import { inject, injectable } from 'tsyringe-neo'; import { InjectTokens } from './dependency_injection/inject_tokens.js'; /** * Class to check if certain components are installed in the cluster. */ let ClusterChecks = class ClusterChecks { logger; k8Factory; constructor(logger, k8Factory) { this.logger = logger; this.k8Factory = k8Factory; this.logger = patchInject(logger, InjectTokens.SoloLogger, this.constructor.name); this.k8Factory = patchInject(k8Factory, InjectTokens.K8Factory, this.constructor.name); } /** * Check if cert-manager is installed inside any namespace. * @returns if cert-manager is found */ async isCertManagerInstalled() { try { const pods = await this.k8Factory.default().pods().listForAllNamespaces(['app=cert-manager']); return pods.length > 0; } catch (e) { this.logger.error('Failed to find cert-manager:', e); return false; } } /** * Check if minio is installed inside the namespace. * @returns if minio is found */ async isMinioInstalled(namespace) { try { // TODO DETECT THE OPERATOR const pods = await this.k8Factory.default().pods().list(namespace, ['app=minio']); return pods.length > 0; } catch (e) { this.logger.error('Failed to find minio:', e); return false; } } /** * Check if the ingress controller is installed inside any namespace. * @returns if ingress controller is found */ async isIngressControllerInstalled() { try { const ingressClassList = await this.k8Factory.default().ingressClasses().list(); return ingressClassList.length > 0; } catch (e) { this.logger.error('Failed to find ingress controller:', e); return false; } } /** * Check if the remote config is installed inside any namespace. * @returns if remote config is found */ async isRemoteConfigPresentInAnyNamespace() { try { const configmaps = await this.k8Factory .default() .configMaps() .listForAllNamespaces([constants.SOLO_REMOTE_CONFIGMAP_LABEL_SELECTOR]); return configmaps.length > 0; } catch (e) { this.logger.error('Failed to find remote config:', e); return false; } } /** * Check if the prometheus is installed inside the namespace. * @param namespace - namespace where to search * @returns if prometheus is found */ async isPrometheusInstalled(namespace) { try { const pods = await this.k8Factory .default() .pods() .list(namespace, ['app.kubernetes.io/name=prometheus']); return pods.length > 0; } catch (e) { this.logger.error('Failed to find prometheus:', e); return false; } } /** * Searches specific namespace for remote config's config map * * @param namespace - namespace where to search * @returns true if found else false */ async isRemoteConfigPresentInNamespace(namespace) { try { const configmaps = await this.k8Factory .default() .configMaps() .list(namespace, [constants.SOLO_REMOTE_CONFIGMAP_LABEL_SELECTOR]); return configmaps.length > 0; } catch (e) { this.logger.error('Failed to find remote config:', e); return false; } } }; ClusterChecks = __decorate([ injectable(), __param(0, inject(InjectTokens.SoloLogger)), __param(1, inject(InjectTokens.K8Factory)), __metadata("design:paramtypes", [Function, Object]) ], ClusterChecks); export { ClusterChecks }; //# sourceMappingURL=cluster_checks.js.map