@hashgraph/solo
Version:
An opinionated CLI tool to deploy and manage private Hedera Networks.
108 lines (107 loc) • 5.92 kB
TypeScript
import { type ConfigManager } from './config-manager.js';
import { type SoloLogger } from './logging/solo-logger.js';
import { type AnyObject, type DirectoryPath, type NodeAlias, type NodeAliases, type Path } from '../types/aliases.js';
import { type ConsensusNode } from './model/consensus-node.js';
import { type K8Factory } from '../integration/kube/k8-factory.js';
import { type ClusterReferenceName, DeploymentName } from './../types/index.js';
import { AccountManager } from './account-manager.js';
import { LocalConfigRuntimeState } from '../business/runtime-state/config/local/local-config-runtime-state.js';
import { type RemoteConfigRuntimeStateApi } from '../business/runtime-state/api/remote-config-runtime-state-api.js';
export interface ProfileManagerStagingOptions {
cacheDir: DirectoryPath;
releaseTag: string;
appName: string;
chainId: string;
}
export declare class ProfileManager {
private readonly logger;
private readonly configManager;
private readonly cacheDir;
private readonly k8Factory;
private readonly remoteConfig;
private readonly accountManager;
private readonly localConfig;
constructor(logger?: SoloLogger, configManager?: ConfigManager, cacheDirectory?: DirectoryPath, k8Factory?: K8Factory, remoteConfig?: RemoteConfigRuntimeStateApi, accountManager?: AccountManager, localConfig?: LocalConfigRuntimeState);
/**
* Set value in the YAML object
* @param itemPath - item path in the yaml
* @param value - value to be set
* @param yamlRoot - root of the YAML object
* @returns
*/
_setValue(itemPath: string, value: unknown, yamlRoot: AnyObject): AnyObject;
/**
* Set items for the chart
* @param itemPath - item path in the YAML, if empty then root of the YAML object will be used
* @param items - the element object
* @param yamlRoot - root of the YAML object to update
*/
_setChartItems(itemPath: string, items: AnyObject | undefined, yamlRoot: AnyObject): void;
prepareStagingDirectory(consensusNodes: ConsensusNode[], nodeAliases: NodeAliases, yamlRoot: AnyObject, deploymentName: DeploymentName, applicationPropertiesPath: string, stagingOptions?: Partial<ProfileManagerStagingOptions>): Promise<void>;
/**
* Parse a KEY=VALUE env file and override defaults.root.extraEnvironment in the Helm values
* so that pod-level environment variables match the application.env content.
*/
private applyApplicationEnvToExtraEnv;
resourcesForNetworkUpgrade(itemPath: string, fileName: string, stagingDirectory: string, yamlRoot: AnyObject): void;
/**
* Prepare a values file for Solo Helm chart
* @param consensusNodes - the list of consensus nodes
* @param deploymentName
* @param applicationPropertiesPath
* @param jfrFile - the name of the custom JFR settings file to use for recording (basename only)
* @param stagingOptions
* @returns mapping of cluster-ref to the full path to the values file
*/
prepareValuesForSoloChart(consensusNodes: ConsensusNode[], deploymentName: DeploymentName, applicationPropertiesPath: string, jfrFile?: string, stagingOptions?: Partial<ProfileManagerStagingOptions>): Promise<Record<ClusterReferenceName, string>>;
private resolveStagingOptions;
private bumpHederaConfigVersion;
/**
* Merge a user-supplied application.properties into the existing staging file.
* Solo's defaults (already written to stagingPath) are the base; for each key in the
* user's file the existing line is replaced in-place. Keys not present in the base
* are appended at the end. This avoids duplicate entries while preserving every
* Solo default the user did not explicitly override.
*/
private mergeApplicationProperties;
private updateApplicationPropertiesForBlockNode;
private updateApplicationPropertiesWithChainId;
private updateBoostrapPropertiesWithChainId;
private updateApplicationPropertiesWithRealmAndShard;
prepareValuesForNodeTransaction(applicationPropertiesPath: string, configTxtPath?: string): Promise<string>;
/**
* Writes the YAML to file.
*
* @param cachedValuesFile - the target file to write the YAML root to.
* @param yamlRoot - object to turn into YAML and write to file.
*/
writeToYaml(cachedValuesFile: Path, yamlRoot: AnyObject): Promise<string>;
/**
* Writes the contents of a file as a value for the given nested item path in the YAML object
* @param itemPath - nested item path in the YAML object to store the file contents
* @param valueFilePath - path to the file whose contents will be stored in the YAML object
* @param yamlRoot - root of the YAML object
*/
private _setFileContentsAsValue;
/**
* Extracts gossip endpoints from saved state (network.json) if it exists
* @param consensusNode - the consensus node to check
* @param nodeSeq - the node sequence number (index in roster)
* @returns the saved endpoint address or undefined if no saved state exists or IP is no longer valid
* @private
*/
private extractSavedEndpoint;
/**
* Prepares config.txt file for the node
* @param nodeAccountMap - the map of node aliases to account IDs
* @param consensusNodes - the list of consensus nodes
* @param destinationPath
* @param releaseTagOverride - release tag override
* @param [appName] - the app name (default: HederaNode.jar)
* @param [chainId] - chain ID (298 for local network)
* @returns the config.txt file path
*/
prepareConfigTxt(nodeAccountMap: Map<NodeAlias, string>, consensusNodes: ConsensusNode[], destinationPath: string, releaseTagOverride: string, appName?: string, chainId?: string, gossipFqdnRestricted?: boolean): Promise<string>;
private parseGossipFqdnRestricted;
private getGossipFqdnRestricted;
}