kubricate
Version:
A TypeScript framework for building reusable, type-safe Kubernetes infrastructure — without the YAML mess.
79 lines • 3.44 kB
TypeScript
import type { BaseLogger, ProviderInjection } from '@kubricate/core';
import { SecretsInjectionContext } from '../secret/index.js';
import type { AnySecretManager, EnvOptions } from '../secret/types.js';
import type { AnyKey, FunctionLike, InferConfigureComposerFunc } from '../types.js';
import { ResourceComposer } from './ResourceComposer.js';
export interface UseSecretsOptions<Key extends AnyKey> {
env?: EnvOptions<Key>[];
injectes?: ProviderInjection[];
}
export type SecretManagerId = number;
/**
* BaseStack is the base class for all stacks.
*
* @note BaseStack fields and methods need to be public, type inference is not working with private fields when using with `createSt`
*/
export declare abstract class BaseStack<ConfigureComposerFunc extends FunctionLike<any[], ResourceComposer> = FunctionLike<any, ResourceComposer>, SecretManager extends AnySecretManager = AnySecretManager> {
_composer: ReturnType<ConfigureComposerFunc>;
_secretManagers: Record<SecretManagerId, SecretManager>;
_targetInjects: ProviderInjection[];
readonly _defaultSecretManagerId = "default";
logger?: BaseLogger;
/**
* The name of the stack.
* This is used to identify the stack, generally used with Stack.
*/
_name?: string;
/**
* Registers a secret injection to be processed during stack build/render.
*/
registerSecretInjection(inject: ProviderInjection): void;
/**
* Retrieves all registered secret injections.
*/
getTargetInjects(): ProviderInjection<string, string>[];
useSecrets<NewSecretManager extends AnySecretManager>(secretManager: NewSecretManager, builder: (injector: SecretsInjectionContext<NewSecretManager>) => void): this;
/**
* Get the secret manager instance.
* @param id The ID of the secret manager. defaults to 'default'.
* @returns The secret manager instance.
*/
getSecretManager(id: number): SecretManager;
/**
* Get all secret managers in the stack.
* @returns The secret managers in the stack.
*/
getSecretManagers(): Record<number, SecretManager>;
/**
* Configure the stack with the provided data.
* @param data The configuration data for the stack.
* @returns The Kubricate Composer instance.
*/
abstract from(data: unknown): unknown;
override(data: Partial<InferConfigureComposerFunc<ConfigureComposerFunc>>): this;
/**
* Build the stack and return the resources.
* @returns The resources in the stack.
*/
build(): Record<string, unknown>;
setComposer(composer: ReturnType<ConfigureComposerFunc>): void;
getComposer(): ReturnType<ConfigureComposerFunc> | undefined;
/**
* Get the resources from the composer.
* @returns The resources from the composer.
*/
get resources(): ReturnType<ConfigureComposerFunc>;
getName(): string | undefined;
setName(name: string): void;
/**
* @internal
* This method is used to inject the logger into the stack.
* It is called by the orchestrator to inject the logger into all components of the stack.
*
* Inject a logger instance into all components of the stack e.g. secret managers, connector, providers, etc.
* This is useful for logging purposes and debugging.
* @param logger The logger instance to be injected.
*/
injectLogger(logger: BaseLogger): void;
}
//# sourceMappingURL=BaseStack.d.ts.map