UNPKG

@hashgraph/solo

Version:

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

52 lines 2.09 kB
import { SoloError } from '../../errors.js'; export class Cluster { name; namespace; deployment; dnsBaseDomain; dnsConsensusNodePattern; constructor(name, namespace, deployment, dnsBaseDomain = 'cluster.local', // example: 'us-west-2.gcp.charlie.sphere'` dnsConsensusNodePattern = 'network-${nodeAlias}-svc.${namespace}.svc') { this.name = name; this.namespace = namespace; this.deployment = deployment; this.dnsBaseDomain = dnsBaseDomain; this.dnsConsensusNodePattern = dnsConsensusNodePattern; if (!name) throw new SoloError('name is required'); if (typeof name !== 'string') throw new SoloError(`Invalid type for name: ${typeof name}`); if (!namespace) throw new SoloError('namespace is required'); if (typeof namespace !== 'string') throw new SoloError(`Invalid type for namespace: ${typeof namespace}`); if (!deployment) throw new SoloError('deployment is required'); if (typeof deployment !== 'string') throw new SoloError(`Invalid type for deployment: ${typeof deployment}`); } toObject() { return { name: this.name, namespace: this.namespace, deployment: this.deployment, dnsBaseDomain: this.dnsBaseDomain, dnsConsensusNodePattern: this.dnsConsensusNodePattern, }; } static fromObject(cluster) { return new Cluster(cluster.name, cluster.namespace, cluster.deployment, cluster.dnsBaseDomain, cluster.dnsConsensusNodePattern); } static toClustersMapObject(clustersMap) { const entries = Object.entries(clustersMap).map(([ref, cluster]) => [ref, cluster.toObject()]); return Object.fromEntries(entries); } static fromClustersMapObject(obj) { const clusters = {}; for (const [ref, cluster] of Object.entries(obj)) { clusters[ref] = Cluster.fromObject(cluster); } return clusters; } } //# sourceMappingURL=cluster.js.map