@hashgraph/solo
Version:
An opinionated CLI tool to deploy and manage private Hedera Networks.
169 lines (168 loc) • 9.04 kB
TypeScript
import { PrivateKey, ServiceEndpoint, type Long } from '@hiero-ledger/sdk';
import { type AnyYargs, type AnyListrContext, type NodeAlias, type NodeAliases } from '../types/aliases.js';
import { type CommandFlag } from '../types/flag-types.js';
import { type SoloLogger } from './logging/solo-logger.js';
import { type Duration } from './time/duration.js';
import { type NodeAddConfigClass } from '../commands/node/config-interfaces/node-add-config-class.js';
import { type ConsensusNode } from './model/consensus-node.js';
import { type ClusterReferenceName, type ClusterReferences, type Optional, type ReleaseNameData } from '../types/index.js';
import { NamespaceName } from '../types/namespace/namespace-name.js';
import { type K8Factory } from '../integration/kube/k8-factory.js';
import { type ConfigManager } from './config-manager.js';
import { type Realm, type Shard } from './../types/index.js';
import { type ConfigMap } from '../integration/kube/resources/config-map/config-map.js';
import { SemanticVersion } from '../business/utils/semantic-version.js';
export declare function getInternalAddress(releaseVersion: SemanticVersion<string> | string, namespaceName: NamespaceName, nodeAlias: NodeAlias): string;
export declare function sleep(duration: Duration): Promise<void>;
export declare function parseNodeAliases(input: string, consensusNodes?: ConsensusNode[], configManager?: ConfigManager): NodeAliases;
export declare function splitFlagInput(input: string, separator?: string): string[];
/**
* @param arr - The array to be cloned
* @returns a new array with the same elements as the input array
*/
export declare function cloneArray<T>(array: T[]): T[];
export declare function getTemporaryDirectory(): string;
export declare function createBackupDirectory(destinationDirectory: string, prefix?: string, currentDate?: Date): string;
export declare function makeBackup(fileMap?: Map<string, string>, removeOld?: boolean): void;
export declare function backupOldTlsKeys(nodeAliases: NodeAliases, keysDirectory: string, currentDate?: Date, directoryPrefix?: string): string;
export declare function backupOldPemKeys(nodeAliases: NodeAliases, keysDirectory: string, currentDate?: Date, directoryPrefix?: string): string;
export declare function getEnvironmentValue(environmentVariableArray: string[], name: string): string;
export declare function parseIpAddressToUint8Array(ipAddress: string): Uint8Array<ArrayBuffer>;
/** If the basename of the src did not match expected basename, rename it first, then copy to destination */
export declare function renameAndCopyFile(sourceFilePath: string, expectedBaseName: string, destinationDirectory: string): void;
/**
* Append root.image registry/repository/tag settings for a given node path to a Helm values argument string.
* @param valuesArgument - existing values argument string (may be empty)
* @param nodePath - base node path, e.g. `hedera.nodes[0]`
* @param registry - image registry
* @param repository - image repository
* @param tag - image tag
* @returns updated values argument string
*/
export declare function addRootImageValues(valuesArgument: string | undefined, nodePath: string, registry: string, repository: string, tag: string): string;
/**
* Returns an object that can be written to a file without data loss.
* Contains fields needed for adding a new node through separate commands
* @param ctx
* @returns file writable object
*/
export declare function addSaveContextParser(context_: AnyListrContext): Record<string, string>;
type AddLoadContext = AnyListrContext & {
config: NodeAddConfigClass;
signingCertDer: Uint8Array;
gossipEndpoints: ServiceEndpoint[];
grpcServiceEndpoints: ServiceEndpoint[];
adminKey: PrivateKey;
tlsCertHash: unknown;
upgradeZipHash: unknown;
newNode: unknown;
};
type AddLoadContextData = {
signingCertDer: string;
gossipEndpoints: string[];
grpcServiceEndpoints: string[];
adminKey: string;
newNode: {
name: NodeAlias;
};
existingNodeAliases: NodeAliases;
tlsCertHash: unknown;
upgradeZipHash: unknown;
};
/**
* Initializes objects in the context from a provided string
* Contains fields needed for adding a new node through separate commands
* @param ctx - accumulator object
* @param ctxData - data in string format
* @returns file writable object
*/
export declare function addLoadContextParser(context_: AddLoadContext, contextData: AddLoadContextData): void;
export declare function prepareEndpoints(endpointType: string, endpoints: string[], defaultPort: number | string): ServiceEndpoint[];
/** Adds all the types of flags as properties on the provided argv object */
export declare function addFlagsToArgv(argv: AnyYargs, flags: {
required: CommandFlag[];
optional: CommandFlag[];
}): AnyYargs;
export declare function resolveValidJsonFilePath(filePath: string, defaultPath?: string): string;
export declare function prepareValuesFiles(valuesFile: string): string;
export declare function populateHelmArguments(valuesMapping: Record<string, string | boolean | number>): string;
/**
* @param nodeAlias
* @param consensusNodes
* @returns context of the node
*/
export declare function extractContextFromConsensusNodes(nodeAlias: NodeAlias, consensusNodes: ConsensusNode[]): Optional<string>;
/**
* Check if the namespace exists in the context of given consensus nodes
* @param consensusNodes
* @param k8Factory
* @param namespace
*/
export declare function checkNamespace(consensusNodes: ConsensusNode[], k8Factory: K8Factory, namespace: NamespaceName): Promise<void>;
/**
* Show a banner with the chart name and version
* @param logger
* @param chartName The name of the chart
* @param version The version of the chart
* @param type The action that was performed such as 'Installed' or 'Upgraded'
*/
export declare function showVersionBanner(logger: SoloLogger, chartName: string, version: string, type?: 'Installed' | 'Upgraded'): void;
/**
* Check if the input is a valid IPv4 address
* @param input
* @returns true if the input is a valid IPv4 address, false otherwise
*/
export declare function isIpV4Address(input: string): boolean;
/**
* Convert an IPv4 address to a base64 string
* @param ipv4 The IPv4 address to convert
* @returns The base64 encoded string representation of the IPv4 address
*/
export declare function ipV4ToBase64(ipv4: string): string;
export declare function entityId(shard: Shard, realm: Realm, number: Long | number | string): string;
export declare function withTimeout<T>(promise: Promise<T>, duration: Duration, errorMessage?: string): Promise<T>;
/**
* Checks if a Docker image with the given name and tag exists locally.
* @param imageName The name of the Docker image (e.g., "block-node-server").
* @param imageTag The tag of the Docker image (e.g., "0.12.0").
* @returns True if the image exists, false otherwise.
*/
export declare function checkDockerImageExists(imageName: string, imageTag: string): boolean;
export declare function createDirectoryIfNotExists(file: string): void;
export declare function findMinioOperator(context: string, k8: K8Factory): Promise<ReleaseNameData>;
export declare function remoteConfigsToDeploymentsTable(remoteConfigs: ConfigMap[]): string[];
/**
* Prepare the values files map for each cluster
*
* Order of precedence:
* 1. Chart's default values file (if chartDirectory is set)
* 2. Profile values file
* 3. User's values file
* @param clusterReferences
* @param valuesFileInput - the values file input string
* @param chartDirectory - the chart directory
* @param profileValuesFile - the profile values file full path
*/
export declare function prepareValuesFilesMap(clusterReferences: ClusterReferences, chartDirectory?: string, profileValuesFile?: string, valuesFileInput?: string): Record<ClusterReferenceName, string>;
/**
* Prepare the values files map for each cluster
*
* Order of precedence:
* 1. Chart's default values file (if chartDirectory is set)
* 2. Base values files (applied after chart defaults, before the generated profile values file)
* 3. Profile values file
* 4. User's values file
* @param clusterReferences
* @param chartDirectory - the chart directory
* @param profileValuesFile - mapping of clusterRef to the profile values file full path
* @param valuesFileInput - the values file input string
* @param baseValuesFiles - optional list of values file paths inserted between chart defaults and profile values
*/
export declare function prepareValuesFilesMapMultipleCluster(clusterReferences: ClusterReferences, chartDirectory?: string, profileValuesFile?: Record<ClusterReferenceName, string>, valuesFileInput?: string, baseValuesFiles?: string[]): Record<ClusterReferenceName, string>;
/**
* @param consensusNode - the targeted consensus node
* @param logger
* @param k8Factory
*/
export declare function createAndCopyBlockNodeJsonFileForConsensusNode(consensusNode: ConsensusNode, logger: SoloLogger, k8Factory: K8Factory): Promise<void>;
export {};