UNPKG

@hashgraph/solo

Version:

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

102 lines (101 loc) 4.69 kB
import { RemoteConfigDataWrapper } from './remote_config_data_wrapper.js'; import { ComponentsDataWrapper } from './components_data_wrapper.js'; import { type K8Factory } from '../../kube/k8_factory.js'; import { type ClusterRef, type Context, type NamespaceNameAsString } from './types.js'; import { type SoloLogger } from '../../logging.js'; import { type ConfigManager } from '../../config_manager.js'; import { type LocalConfig } from '../local_config.js'; import type * as k8s from '@kubernetes/client-node'; import { type AnyObject } from '../../../types/aliases.js'; import { Cluster } from './cluster.js'; /** * Uses Kubernetes ConfigMaps to manage the remote configuration data by creating, loading, modifying, * and saving the configuration data to and from a Kubernetes cluster. */ export declare class RemoteConfigManager { private readonly k8Factory?; private readonly logger?; private readonly localConfig?; private readonly configManager?; /** Stores the loaded remote configuration data. */ private remoteConfig; /** * @param k8Factory - The Kubernetes client used for interacting with ConfigMaps. * @param logger - The logger for recording activity and errors. * @param localConfig - Local configuration for the remote config. * @param configManager - Manager to retrieve application flags and settings. */ constructor(k8Factory?: K8Factory, logger?: SoloLogger, localConfig?: LocalConfig, configManager?: ConfigManager); get currentCluster(): ClusterRef; /** @returns the components data wrapper cloned */ get components(): ComponentsDataWrapper; /** * @returns the remote configuration data's clusters cloned */ get clusters(): Record<ClusterRef, Cluster>; /** * Modifies the loaded remote configuration data using a provided callback function. * The callback operates on the configuration data, which is then saved to the cluster. * * @param callback - an async function that modifies the remote configuration data. * @throws {@link SoloError} if the configuration is not loaded before modification. */ modify(callback: (remoteConfig: RemoteConfigDataWrapper) => Promise<void>): Promise<void>; /** * Creates a new remote configuration in the Kubernetes cluster. * Gathers data from the local configuration and constructs a new ConfigMap * entry in the cluster with initial command history and metadata. */ private create; /** * Saves the currently loaded remote configuration data to the Kubernetes cluster. * @throws {@link SoloError} if there is no remote configuration data to save. */ private save; /** * Loads the remote configuration from the Kubernetes cluster if it exists. * @returns true if the configuration is loaded successfully. */ private load; /** * Loads the remote configuration, performs a validation and returns it * @returns RemoteConfigDataWrapper */ get(): Promise<RemoteConfigDataWrapper>; static compare(remoteConfig1: RemoteConfigDataWrapper, remoteConfig2: RemoteConfigDataWrapper): boolean; /** * Performs the loading of the remote configuration. * Checks if the configuration is already loaded, otherwise loads and adds the command to history. * * @param argv - arguments containing command input for historical reference. */ loadAndValidate(argv: { _: string[]; } & AnyObject): Promise<void>; private populateVersionsInMetadata; createAndValidate(clusterRef: ClusterRef, context: Context, namespace: NamespaceNameAsString, argv: AnyObject): Promise<void>; /** Empties the component data inside the remote config */ deleteComponents(): Promise<void>; isLoaded(): boolean; unload(): void; /** * Retrieves the ConfigMap containing the remote configuration from the Kubernetes cluster. * * @returns the remote configuration data. * @throws {@link SoloError} if the ConfigMap could not be read and the error is not a 404 status. */ getConfigMap(): Promise<k8s.V1ConfigMap>; /** * Creates a new ConfigMap entry in the Kubernetes cluster with the remote configuration data. */ private createConfigMap; /** Replaces an existing ConfigMap in the Kubernetes cluster with the current remote configuration data. */ private replaceConfigMap; private setDefaultNamespaceIfNotSet; private setDefaultContextIfNotSet; /** * Retrieves the namespace value from the configuration manager's flags. * @returns string - The namespace value if set. */ private getNamespace; }