UNPKG

sleeveforarm

Version:
83 lines 3.68 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); const CommonUtilities = require("./common-utilities"); const data = require("./data"); const keyvault_1 = require("./keyvault"); const promiseGate_1 = require("./promiseGate"); class BaseDeployKeyVaultInfrastructure { constructor(baseKeyVault) { this.baseKeyVault = baseKeyVault; } setSecret(secretName, password) { return __awaiter(this, void 0, void 0, function* () { yield CommonUtilities.runAzCommand(`az keyvault secret set --name ${secretName} \ --vault-name ${this.baseKeyVault.keyVaultFullName} --value ${password}`); return this; }); } } exports.BaseDeployKeyVaultInfrastructure = BaseDeployKeyVaultInfrastructure; class KeyVaultInfrastructure extends keyvault_1.default { constructor() { super(...arguments); this.promiseGate = new promiseGate_1.default(); } initialize(resource, targetDirectoryPath) { super.initialize(resource, targetDirectoryPath); if (resource !== null) { Object.assign(this, resource); } return this; } setup() { return __awaiter(this, void 0, void 0, function* () { return yield KeyVaultInfrastructure .internalSetup(__filename, this.targetDirectoryPath, data.data.KeyVaultNameLength); }); } hydrate(resourcesInEnvironment, deploymentType) { const _super = name => super[name]; return __awaiter(this, void 0, void 0, function* () { yield _super("hydrate").call(this, resourcesInEnvironment, deploymentType); if (this.keyVaultFullName === undefined) { this.keyVaultFullName = this.resourceGroup.resourceGroupName + this.baseName; } return this; }); } deployResource() { return __awaiter(this, void 0, void 0, function* () { try { yield this.resourceGroup.getBaseDeployClassInstance(); yield CommonUtilities.runAzCommand(`az keyvault create --name ${this.keyVaultFullName} \ --resource-group ${this.resourceGroup.resourceGroupName} \ --enable-soft-delete ${this.isEnabledForSoftDelete} \ --enabled-for-deployment ${this.isEnabledForDeployment} \ --enabled-for-disk-encryption ${this.isEnabledForDiskEncryption} \ --enabled-for-template-deployment ${this.isEnabledForTemplateDeployment}`); this.promiseGate.openGateSuccess(new BaseDeployKeyVaultInfrastructure(this)); return this; } catch (err) { this.promiseGate.openGateError(err); throw err; } }); } getBaseDeployClassInstance() { return this.promiseGate.promise.then(function (baseClass) { return baseClass; }); } } exports.KeyVaultInfrastructure = KeyVaultInfrastructure; //# sourceMappingURL=keyvaultInfrastructure.js.map