UNPKG

kubricate

Version:

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

40 lines 1.38 kB
import c from 'ansis'; import '@kubricate/core'; import { MARK_CHECK } from '../internal/constant.js'; export class SecretCommand { options; logger; kubectl; constructor(options, logger, kubectl) { this.options = options; this.logger = logger; this.kubectl = kubectl; } async validate(orchestrator) { this.logger.info('Validating secrets configuration...'); await orchestrator.validate(); this.logger.log(c.green`${MARK_CHECK} All secret managers validated successfully.`); } async apply(orchestrator) { await orchestrator.validate(); const effects = await orchestrator.apply(); if (effects.length === 0) { this.logger.warn(`No secrets to apply.`); return; } for (const effect of effects) { if (effect.type === 'kubectl') { const name = effect.value?.metadata?.name ?? 'unnamed'; this.logger.info(`Applying secret: ${name}`); if (this.options.dryRun) { this.logger.log(c.yellow`${MARK_CHECK} [DRY RUN] Would apply: ${name} with kubectl using payload: ${JSON.stringify(effect.value)}`); } else { await this.kubectl.apply(effect.value); } this.logger.log(c.green`${MARK_CHECK} Applied: ${name}`); } } this.logger.log(c.green`${MARK_CHECK} All secrets applied successfully.`); } } //# sourceMappingURL=SecretCommand.js.map