@axway/axway-central-cli
Version:
Manage APIs, services and publish to the Amplify Marketplace
194 lines (186 loc) • 8.04 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.kafkaTAEnvVarTemplate = exports.kafkaDAEnvVarTemplate = exports.KafkaAgentValues = 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 Kafka handlebars templates.
*/
class KafkaAgentValues {
constructor() {
_defineProperty(this, "cloudEnabled", void 0);
_defineProperty(this, "cloudEnvironmentId", void 0);
_defineProperty(this, "cloudAPIKey", void 0);
_defineProperty(this, "cloudAPISecret", void 0);
_defineProperty(this, "cloudClusterId", void 0);
_defineProperty(this, "clusterServer", void 0);
_defineProperty(this, "clusterAPIKey", void 0);
_defineProperty(this, "clusterAPISecret", void 0);
_defineProperty(this, "clusterSaslMechanism", void 0);
_defineProperty(this, "clusterSaslUser", void 0);
_defineProperty(this, "clusterSaslPassword", void 0);
_defineProperty(this, "saslOauthTokenUrl", void 0);
_defineProperty(this, "saslOauthClientId", void 0);
_defineProperty(this, "saslOauthClientSecret", void 0);
_defineProperty(this, "saslOauthClientScopes", void 0);
_defineProperty(this, "schemaRegistryEnabled", void 0);
_defineProperty(this, "schemaRegistryUrl", void 0);
_defineProperty(this, "schemaRegistryAuthEnabled", void 0);
_defineProperty(this, "schemaRegistryAPIKey", void 0);
_defineProperty(this, "schemaRegistryAPISecret", void 0);
_defineProperty(this, "centralConfig", void 0);
_defineProperty(this, "traceabilityConfig", void 0);
this.cloudEnabled = false;
this.cloudEnvironmentId = '';
this.cloudAPIKey = '';
this.cloudAPISecret = '';
this.cloudClusterId = '';
this.clusterServer = '';
this.clusterAPIKey = '';
this.clusterAPISecret = '';
this.clusterSaslMechanism = '';
this.clusterSaslUser = '';
this.clusterSaslPassword = '';
this.saslOauthTokenUrl = '';
this.saslOauthClientId = '';
this.saslOauthClientSecret = '';
this.saslOauthClientScopes = '';
this.schemaRegistryEnabled = false;
this.schemaRegistryUrl = '';
this.schemaRegistryAuthEnabled = true;
this.schemaRegistryAPIKey = '';
this.schemaRegistryAPISecret = '';
this.centralConfig = new _types.CentralAgentConfig();
this.traceabilityConfig = new _types.TraceabilityConfig();
}
}
/**
* @description Generates the Kafka DA env vars file.
*/
exports.KafkaAgentValues = KafkaAgentValues;
const kafkaDAEnvVarTemplate = () => {
return `# Kafka cluster configs
{{#if cloudEnabled}}
KAFKA_CLOUD_ENABLED={{cloudEnabled}}
KAFKA_CLOUD_ENVIRONMENT={{cloudEnvironmentId}}
KAFKA_CLOUD_AUTH_APIKEY_ID={{cloudAPIKey}}
KAFKA_CLOUD_AUTH_APIKEY_SECRET={{cloudAPISecret}}
KAFKA_CLUSTER_ID={{cloudClusterId}}
KAFKA_CLUSTER_AUTH_APIKEY_ID={{clusterAPIKey}}
KAFKA_CLUSTER_AUTH_APIKEY_SECRET={{clusterAPISecret}}
{{else}}
KAFKA_CLUSTER_SERVERS={{clusterServer}}
{{#compare . clusterSaslMechanism "NONE" operator="!="}}
KAFKA_CLUSTER_AUTH_SASL_MECHANISM={{clusterSaslMechanism}}
{{#compare . clusterSaslMechanism "OAUTHBEARER" operator="=="}}
KAFKA_CLUSTER_AUTH_SASL_OAUTH_TOKENURL={{saslOauthTokenUrl}}
KAFKA_CLUSTER_AUTH_SASL_OAUTH_CLIENTID={{saslOauthClientId}}
KAFKA_CLUSTER_AUTH_SASL_OAUTH_CLIENTSECRET={{saslOauthClientSecret}}
{{#compare . saslOauthClientScopes "" operator="!=" }}
KAFKA_CLUSTER_AUTH_SASL_OAUTH_SCOPES={{saslOauthClientScopes}}
{{/compare}}
{{/compare}}
{{#compare . clusterSaslMechanism "OAUTHBEARER" operator="!="}}
KAFKA_CLUSTER_AUTH_SASL_USERNAME={{clusterSaslUser}}
KAFKA_CLUSTER_AUTH_SASL_PASSWORD={{clusterSaslPassword}}
{{/compare}}
{{/compare}}
{{/if}}
{{#if cloudEnabled}}
KAFKA_SCHEMAREGISTRY_ENABLED=true
KAFKA_SCHEMAREGISTRY_AUTH_APIKEY_ID={{schemaRegistryAPIKey}}
KAFKA_SCHEMAREGISTRY_AUTH_APIKEY_SECRET={{schemaRegistryAPISecret}}
{{else}}
{{#if schemaRegistryEnabled}}
KAFKA_SCHEMAREGISTRY_ENABLED=true
KAFKA_SCHEMAREGISTRY_URL={{schemaRegistryUrl}}
{{#if schemaRegistryAuthEnabled}}
KAFKA_SCHEMAREGISTRY_AUTH_SASL_MECHANISM={{clusterSaslMechanism}}
{{#compare . clusterSaslMechanism "OAUTHBEARER" operator="=="}}
KAFKA_SCHEMAREGISTRY_AUTH_SASL_OAUTH_TOKENURL={{saslOauthTokenUrl}}
KAFKA_SCHEMAREGISTRY_AUTH_SASL_OAUTH_CLIENTID={{saslOauthClientId}}
KAFKA_SCHEMAREGISTRY_AUTH_SASL_OAUTH_CLIENTSECRET={{saslOauthClientSecret}}
{{#compare . saslOauthClientScopes "" operator="!=" }}
KAFKA_SCHEMAREGISTRY_AUTH_SASL_OAUTH_SCOPES={{saslOauthClientScopes}}
{{/compare}}
{{/compare}}
{{#compare . clusterSaslMechanism "OAUTHBEARER" operator="!="}}
KAFKA_SCHEMAREGISTRY_AUTH_SASL_USERNAME={{clusterSaslUser}}
KAFKA_SCHEMAREGISTRY_AUTH_SASL_PASSWORD={{clusterSaslPassword}}
{{/compare}}
{{/if}}
{{/if}}
{{/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
`;
};
/**
* @description Generates the Kafka TA env vars file.
*/
exports.kafkaDAEnvVarTemplate = kafkaDAEnvVarTemplate;
const kafkaTAEnvVarTemplate = () => {
return `# Kafka cluster configs
{{#if cloudEnabled}}
KAFKA_CLOUD_ENABLED={{cloudEnabled}}
KAFKA_CLOUD_ENVIRONMENT={{cloudEnvironmentId}}
KAFKA_CLOUD_AUTH_APIKEY_ID={{cloudAPIKey}}
KAFKA_CLOUD_AUTH_APIKEY_SECRET={{cloudAPISecret}}
KAFKA_CLUSTER_ID={{cloudClusterId}}
KAFKA_CLUSTER_AUTH_APIKEY_ID={{clusterAPIKey}}
KAFKA_CLUSTER_AUTH_APIKEY_SECRET={{clusterAPISecret}}
{{else}}
KAFKA_CLUSTER_SERVERS={{clusterServer}}
{{#compare . clusterSaslMechanism "NONE" operator="!="}}
KAFKA_CLUSTER_AUTH_SASL_MECHANISM={{clusterSaslMechanism}}
{{#compare . clusterSaslMechanism "OAUTHBEARER" operator="=="}}
KAFKA_CLUSTER_AUTH_SASL_OAUTH_TOKENURL={{saslOauthTokenUrl}}
KAFKA_CLUSTER_AUTH_SASL_OAUTH_CLIENTID={{saslOauthClientId}}
KAFKA_CLUSTER_AUTH_SASL_OAUTH_CLIENTSECRET={{saslOauthClientSecret}}
{{#compare . saslOauthClientScopes "" operator="!=" }}
KAFKA_CLUSTER_AUTH_SASL_OAUTH_SCOPES={{saslOauthClientScopes}}
{{/compare}}
{{/compare}}
{{#compare . clusterSaslMechanism "OAUTHBEARER" operator="!="}}
KAFKA_CLUSTER_AUTH_SASL_USERNAME={{clusterSaslUser}}
KAFKA_CLUSTER_AUTH_SASL_PASSWORD={{clusterSaslPassword}}
{{/compare}}
{{/compare}}
{{/if}}
# Amplify Central configs
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}}
# 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.kafkaTAEnvVarTemplate = kafkaTAEnvVarTemplate;