@axway/axway-central-cli
Version:
Manage APIs, services and publish to the Amplify Marketplace
132 lines (123 loc) • 5.23 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.awsTAEnvVarTemplate = exports.awsDAEnvVarTemplate = exports.AWSAgentValues = 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 Values to provide to the aws handlebars templates.
*/
class AWSAgentValues {
constructor(awsDeployment) {
_defineProperty(this, "accessKey", void 0);
_defineProperty(this, "secretKey", void 0);
_defineProperty(this, "logGroup", void 0);
_defineProperty(this, "stageTagName", void 0);
_defineProperty(this, "fullTransactionLogging", void 0);
_defineProperty(this, "region", void 0);
_defineProperty(this, "apigwAgentConfigZipFile", void 0);
_defineProperty(this, "centralConfig", void 0);
_defineProperty(this, "traceabilityConfig", void 0);
_defineProperty(this, "cloudFormationConfig", void 0);
_defineProperty(this, "updateCloudFormationConfig", () => {
this.cloudFormationConfig.ECSCentralRegion = this.centralConfig.region;
if (this.cloudFormationConfig.DeploymentType === 'ECS Fargate') {
this.cloudFormationConfig.ECSCentralOrganizationID = this.centralConfig.orgId;
this.cloudFormationConfig.ECSCentralEnvironmentName = this.centralConfig.environment;
this.cloudFormationConfig.ECSCentralClientID = this.centralConfig.dosaAccount.clientId;
this.cloudFormationConfig.ECSCentralDiscoveryAgentName = this.centralConfig.daAgentName;
this.cloudFormationConfig.ECSCentralTraceabilityAgentName = this.centralConfig.taAgentName;
}
});
this.accessKey = awsDeployment === 'Other' ? '**Insert Access Key**' : '';
this.secretKey = awsDeployment === 'Other' ? '**Insert Secret Key**' : '';
this.logGroup = '';
this.stageTagName = '';
this.fullTransactionLogging = false;
this.region = '';
this.apigwAgentConfigZipFile = '';
this.centralConfig = new _types.CentralAgentConfig();
this.traceabilityConfig = new _types.TraceabilityConfig();
this.cloudFormationConfig = new _types.CloudFormationConfig();
}
}
/**
* @description Generates the AWS TA env vars file.
*/
exports.AWSAgentValues = AWSAgentValues;
const awsTAEnvVarTemplate = () => {
return `# AWS configs
AWS_REGION={{region}}
{{#if accessKey}}
AWS_AUTH_ACCESSKEY={{accessKey}}
{{/if}}
{{#if secretKey}}
AWS_AUTH_SECRETKEY={{secretKey}}
{{/if}}
{{#if fullTransactionLogging}}
AWS_FULLTRANSACTIONLOGGING={{fullTransactionLogging}}
{{/if}}
# 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 AWS DA env vars file.
*/
exports.awsTAEnvVarTemplate = awsTAEnvVarTemplate;
const awsDAEnvVarTemplate = () => {
return `# AWS configs
AWS_REGION={{region}}
{{#if accessKey}}
AWS_AUTH_ACCESSKEY={{accessKey}}
{{/if}}
{{#if secretKey}}
AWS_AUTH_SECRETKEY={{secretKey}}
{{/if}}
AWS_LOGGROUP={{logGroup}}
AWS_STAGETAGNAME={{stageTagName}}
# 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.awsDAEnvVarTemplate = awsDAEnvVarTemplate;