UNPKG

@axway/axway-central-cli

Version:

Manage APIs, services and publish to the Amplify Marketplace

122 lines (116 loc) 4.64 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.akamaiHelmOverrideTemplate = exports.akamaiEnvVarTemplate = exports.AkamaiAgentValues = void 0; var _types = require("../../../../common/types"); var _handlebars = _interopRequireDefault(require("handlebars")); function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } 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 Akamai handlebars templates. */ class AkamaiAgentValues { constructor() { _defineProperty(this, "namespace", void 0); _defineProperty(this, "baseUrl", void 0); _defineProperty(this, "clientId", void 0); _defineProperty(this, "clientSecret", void 0); _defineProperty(this, "segmentLength", void 0); _defineProperty(this, "environments", void 0); _defineProperty(this, "centralEnvironments", void 0); _defineProperty(this, "centralConfig", void 0); _defineProperty(this, "traceabilityConfig", void 0); _defineProperty(this, "akamaiSecret", void 0); _defineProperty(this, "agentKeysSecret", void 0); this.namespace = { name: '', isNew: false }; this.baseUrl = ''; this.clientId = ''; this.clientSecret = ''; this.segmentLength = 1; this.environments = []; this.centralEnvironments = []; this.centralConfig = new _types.CentralAgentConfig(); this.traceabilityConfig = new _types.TraceabilityConfig(); this.akamaiSecret = ''; this.agentKeysSecret = ''; } } exports.AkamaiAgentValues = AkamaiAgentValues; _handlebars.default.registerHelper('formatIndex', index => { return index + 1; }); /** * @description Generates the helm override file for the Amplify Akamai Agent. */ const akamaiHelmOverrideTemplate = () => { return `--- # Akamai Agent image overrides # image: # fullPath: # registry: docker.repository.axway.com # repository: ampc-beano-docker-prod/1.1 # name: akamai-agent # tag: # pullPolicy: IfNotPresent # pullSecret: akamai: baseUrl: {{baseUrl}} clientId: {{clientId}} clientSecret: {{clientSecret}} segmentLength: {{segmentLength}} {{#compare . environments.length 0 operator="!=" }} {{#environments}} akamai_environmentmapping_akamai_{{formatIndex @index}}={{.}} akamai_environmentmapping_amplify_{{formatIndex @index}}={{lookup ../centralEnvironments @index}} {{/environments}} {{/compare}} env: CENTRAL_REGION: {{centralConfig.region}} CENTRAL_ORGANIZATIONID: "{{centralConfig.orgId}}" CENTRAL_TEAM: {{centralConfig.ampcTeamName}} CENTRAL_ENVIRONMENT: {{centralConfig.environment}} CENTRAL_AGENTNAME: {{centralConfig.caAgentName}} CENTRAL_AUTH_CLIENTID: {{centralConfig.dosaAccount.clientId}} `; }; /** * @description Generates the Amplify Akamai Agent env vars file. */ exports.akamaiHelmOverrideTemplate = akamaiHelmOverrideTemplate; const akamaiEnvVarTemplate = () => { return `# Akamai configs AKAMAI_BASEURL={{baseUrl}} AKAMAI_CLIENTID={{clientId}} AKAMAI_CLIENTSECRET={{clientSecret}} AKAMAI_SEGMENTLENGTH={{segmentLength}} {{#compare . environments.length 0 operator="!=" }} {{#environments}} AKAMAI_ENVIRONMENTMAPPING_AKAMAI_{{formatIndex @index}}={{.}} AKAMAI_ENVIRONMENTMAPPING_AMPLIFY_{{formatIndex @index}}={{lookup ../centralEnvironments @index}} {{/environments}} {{/compare}} # Amplify Central configs CENTRAL_AGENTNAME={{centralConfig.caAgentName}} 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.akamaiEnvVarTemplate = akamaiEnvVarTemplate;