@axway/axway-central-cli
Version:
Manage APIs, services and publish to the Amplify Marketplace
140 lines (131 loc) • 5.13 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.traceableHelmOverrideTemplate = exports.traceableEnvVarTemplate = exports.TraceableAgentValues = exports.ComplianceAgentValues = 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); }
class ComplianceAgentValues {
constructor() {
_defineProperty(this, "centralEnvironments", void 0);
this.centralEnvironments = [];
}
}
/**
* @description Parameters to provide to the Traceable handlebars templates.
*/
exports.ComplianceAgentValues = ComplianceAgentValues;
class TraceableAgentValues extends ComplianceAgentValues {
constructor() {
super();
_defineProperty(this, "namespace", void 0);
_defineProperty(this, "traceableToken", void 0);
_defineProperty(this, "traceableRegion", void 0);
_defineProperty(this, "environments", void 0);
_defineProperty(this, "centralConfig", void 0);
_defineProperty(this, "traceabilityConfig", void 0);
_defineProperty(this, "traceableSecret", void 0);
_defineProperty(this, "agentKeysSecret", void 0);
this.namespace = {
name: '',
isNew: false
};
this.traceableToken = '';
this.traceableRegion = _types.TraceableRegionType.US;
this.environments = [];
this.centralConfig = new _types.CentralAgentConfig();
this.traceabilityConfig = new _types.TraceabilityConfig();
this.traceableSecret = '';
this.agentKeysSecret = '';
}
}
exports.TraceableAgentValues = TraceableAgentValues;
_handlebars.default.registerHelper('formatIndex', index => {
return index + 1;
});
/**
* @description Generates the helm override file for the Amplify Traceable Agent.
*/
const traceableHelmOverrideTemplate = () => {
return `---
# Traceable Agent image overrides
# image:
# fullPath:
# registry: docker.repository.axway.com
# repository: ampc-beano-docker-prod/1.1
# name: graylog-agent
# tag:
# pullPolicy: IfNotPresent
# pullSecret:
secrets:
traceable:
name: {{traceableSecret}}
agent:
name: {{agentKeysSecret}}
traceable:
token: {{traceableToken}}
{{#compare . environments.length 0 operator="!=" }}
{{#environments}}
traceable_environmentmapping_traceable_{{formatIndex }}={{.}}
{{/environments}}
{{/compare}}
{{#compare . centralEnvironments.length 0 operator="!=" }}
{{#centralEnvironments}}
traceable_environmentmapping_amplify_{{formatIndex }}={{.}}
{{/centralEnvironments}}
{{/compare}}
region: {{traceableRegion}}
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}}
TRACEABILITY_PROTOCOL: {{traceabilityConfig.protocol}}
`;
};
/**
* @description Generates the Amplify Traceable Agent env vars file.
*/
exports.traceableHelmOverrideTemplate = traceableHelmOverrideTemplate;
const traceableEnvVarTemplate = () => {
return `# Traceable configs
TRACEABLE_TOKEN={{traceableToken}}
TRACEABLE_REGION={{traceableRegion}}
{{#compare . environments.length 0 operator="!=" }}
{{#environments}}
TRACEABLE_ENVIRONMENTMAPPING_TRACEABLE_{{formatIndex }}={{.}}
{{/environments}}
{{/compare}}
{{#compare . centralEnvironments.length 0 operator="!=" }}
{{#centralEnvironments}}
TRACEABLE_ENVIRONMENTMAPPING_AMPLIFY_{{formatIndex }}={{.}}
{{/centralEnvironments}}
{{/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}}
{{#compare . traceabilityConfig.protocol "https"}}
TRACEABILITY_PROTOCOL={{traceabilityConfig.protocol}}
{{/compare}}
# 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.traceableEnvVarTemplate = traceableEnvVarTemplate;