UNPKG

kubricate

Version:

A TypeScript framework for building reusable, type-safe Kubernetes infrastructure — without the YAML mess.

62 lines 1.56 kB
import { createMergeHandler } from './merge-utils.js'; export class InMemoryProvider { name; injectes = []; allowMerge = true; secretType = 'Kubricate.InMemory'; supportedStrategies = ['env']; targetKind = 'Deployment'; config; constructor(config = {}) { this.config = config; } setInjects(injectes) { this.injectes = injectes; } getTargetPath(strategy) { if (strategy.kind === 'env') { const index = strategy.containerIndex ?? 0; return `spec.template.spec.containers[${index}].env`; } throw new Error(`[InMemoryProvider] Unsupported strategy: ${strategy.kind}`); } getInjectionPayload() { return this.injectes.map(inject => ({ name: inject.meta?.targetName, valueFrom: { secretKeyRef: { name: this.config.name ?? 'in-memory', key: inject.meta?.secretName } } })); } getEffectIdentifier(effect) { return effect.value?.storeName; } /** * Merge provider-level effects into final applyable resources. * Used to deduplicate (e.g. K8s secret name + ns). */ mergeSecrets(effects) { const merge = createMergeHandler(); return merge(effects); } /** * Prepare the secret value for in-memory storage. */ prepare(name, value) { return [{ secretName: name, providerName: this.name, type: 'custom', value: { storeName: this.config.name ?? 'in-memory', rawData: { [name]: value } } }]; } } //# sourceMappingURL=InMemoryProvider.js.map