UNPKG

kubricate

Version:

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

52 lines (51 loc) 1.78 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SecretCommand = void 0; var _ansis = /*#__PURE__*/_interopRequireDefault(/*#__PURE__*/require("ansis")); require("@kubricate/core"); var _constant = /*#__PURE__*/require("../internal/constant.js"); function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } 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(_ansis.default.green`${_constant.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(_ansis.default.yellow`${_constant.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(_ansis.default.green`${_constant.MARK_CHECK} Applied: ${name}`); } } this.logger.log(_ansis.default.green`${_constant.MARK_CHECK} All secrets applied successfully.`); } } exports.SecretCommand = SecretCommand; //# sourceMappingURL=SecretCommand.js.map