UNPKG

@axway/axway-central-cli

Version:

Manage APIs, services and publish to the Amplify Marketplace

128 lines (120 loc) 5.05 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.azureTAEnvVarTemplate = exports.azureDAEnvVarTemplate = exports.AzureAgentValues = void 0; var _types = require("../../../../common/types"); function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; } function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; } function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /** * @description Parameters to provide to the Azure handlebars templates. */ class AzureAgentValues { constructor() { _defineProperty(this, "apiManagementServiceName", void 0); _defineProperty(this, "eventHubName", void 0); _defineProperty(this, "eventHubNamespace", void 0); _defineProperty(this, "policyKey", void 0); _defineProperty(this, "policyName", void 0); _defineProperty(this, "resourceGroupName", void 0); _defineProperty(this, "servicePrincipalClientId", void 0); _defineProperty(this, "servicePrincipalClientSecret", void 0); _defineProperty(this, "subscriptionId", void 0); _defineProperty(this, "tenantId", void 0); _defineProperty(this, "isAzureEventHub", void 0); _defineProperty(this, "centralConfig", void 0); _defineProperty(this, "traceabilityConfig", void 0); this.apiManagementServiceName = ''; this.eventHubName = ''; this.eventHubNamespace = ''; this.policyKey = ''; this.policyName = ''; this.resourceGroupName = ''; this.servicePrincipalClientId = ''; this.servicePrincipalClientSecret = ''; this.subscriptionId = ''; this.tenantId = ''; this.isAzureEventHub = false; this.centralConfig = new _types.CentralAgentConfig(); this.traceabilityConfig = new _types.TraceabilityConfig(); } } /** * @description Generates the Azure TA env vars file. */ exports.AzureAgentValues = AzureAgentValues; const azureTAEnvVarTemplate = () => { return `# Azure configs AZURE_EVENTHUBNAME={{eventHubName}} AZURE_EVENTHUBNAMESPACE={{eventHubNamespace}} AZURE_SHAREDACCESSKEYNAME={{policyName}} AZURE_SHAREDACCESSKEYVALUE={{policyKey}} AZURE_TENANTID={{tenantId}} AZURE_SUBSCRIPTIONID={{subscriptionId}} AZURE_RESOURCEGROUPNAME={{resourceGroupName}} AZURE_CLIENTID={{servicePrincipalClientId}} AZURE_CLIENTSECRET={{servicePrincipalClientSecret}} AZURE_APIMSERVICENAME={{apiManagementServiceName}} # Amplify Central configs {{#if traceabilityConfig.usageReportingOffline}} CENTRAL_USAGEREPORTING_OFFLINE={{traceabilityConfig.usageReportingOffline}} CENTRAL_ENVIRONMENTID={{centralConfig.environmentId}} CENTRAL_AGENTNAME={{centralConfig.taAgentName}} {{else}} CENTRAL_AGENTNAME={{centralConfig.taAgentName}} CENTRAL_AUTH_CLIENTID={{centralConfig.dosaAccount.clientId}} CENTRAL_AUTH_PRIVATEKEY={{centralConfig.dosaAccount.templatePrivateKey}} CENTRAL_AUTH_PUBLICKEY={{centralConfig.dosaAccount.templatePublicKey}} CENTRAL_ENVIRONMENT={{centralConfig.environment}} CENTRAL_ORGANIZATIONID={{centralConfig.orgId}} CENTRAL_TEAM={{centralConfig.ampcTeamName}} CENTRAL_REGION={{centralConfig.region}} {{#compare . traceabilityConfig.protocol "https"}} TRACEABILITY_PROTOCOL={{traceabilityConfig.protocol}} {{/compare}} {{/if}} # Logging configs # Define the logging level: info, debug, error LOG_LEVEL=info # Specify where to send the log: stdout, file, both LOG_OUTPUT=stdout # Define where the log files are written LOG_FILE_PATH=logs `; }; /** * @description Generates the Azure DA env vars file. */ exports.azureTAEnvVarTemplate = azureTAEnvVarTemplate; const azureDAEnvVarTemplate = () => { return `# Azure configs AZURE_TENANTID={{tenantId}} AZURE_SUBSCRIPTIONID={{subscriptionId}} AZURE_RESOURCEGROUPNAME={{resourceGroupName}} AZURE_CLIENTID={{servicePrincipalClientId}} AZURE_CLIENTSECRET={{servicePrincipalClientSecret}} {{#if isAzureEventHub}} AZURE_EVENTHUBNAMESPACE={{eventHubNamespace}} {{else}} AZURE_APIMSERVICENAME={{apiManagementServiceName}} {{/if}} # Amplify Central configs CENTRAL_AGENTNAME={{centralConfig.daAgentName}} CENTRAL_AUTH_CLIENTID={{centralConfig.dosaAccount.clientId}} CENTRAL_AUTH_PRIVATEKEY={{centralConfig.dosaAccount.templatePrivateKey}} CENTRAL_AUTH_PUBLICKEY={{centralConfig.dosaAccount.templatePublicKey}} CENTRAL_ENVIRONMENT={{centralConfig.environment}} CENTRAL_ORGANIZATIONID={{centralConfig.orgId}} CENTRAL_TEAM={{centralConfig.ampcTeamName}} CENTRAL_REGION={{centralConfig.region}} # Logging configs # Define the logging level: info, debug, error LOG_LEVEL=info # Specify where to send the log: stdout, file, both LOG_OUTPUT=stdout # Define where the log files are written LOG_FILE_PATH=logs `; }; exports.azureDAEnvVarTemplate = azureDAEnvVarTemplate;