@axway/axway-central-cli 2.18.0 → 2.19.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -17,6 +17,7 @@ var _types = require("../../common/types");
17
17
  var _utils = require("../../common/utils");
18
18
  var awsAgents = _interopRequireWildcard(require("./awsAgents"));
19
19
  var gitHubAgents = _interopRequireWildcard(require("./gitHubSaasAgents"));
20
+ var gitLabAgents = _interopRequireWildcard(require("./gitLabAgents"));
20
21
  var azureAgents = _interopRequireWildcard(require("./azureAgents"));
21
22
  var edgeAgents = _interopRequireWildcard(require("./edgeAgents"));
22
23
  var apigeeSaaSAgents = _interopRequireWildcard(require("./apigeexSaasAgents"));
@@ -40,6 +41,7 @@ const agentInstallFlows = {
40
41
  [_types.GatewayTypes.EDGE_GATEWAY_ONLY]: edgeAgents.EdgeGWOnlyInstallMethods,
41
42
  [_types.GatewayTypes.AWS_GATEWAY]: awsAgents.AWSInstallMethods,
42
43
  [_types.GatewayTypes.GITHUB]: gitHubAgents.GitHubSaaSInstallMethods,
44
+ [_types.GatewayTypes.GITLAB]: gitLabAgents.GitLabInstallMethods,
43
45
  [_types.GatewayTypes.APIGEEX_GATEWAY]: apigeeSaaSAgents.APIGEEXSaaSInstallMethods,
44
46
  [_types.GatewayTypes.AZURE_GATEWAY]: azureAgents.AzureInstallMethods,
45
47
  [_types.GatewayTypes.ISTIO]: istioAgents.IstioInstallMethods
@@ -0,0 +1,174 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.testables = exports.installPreprocess = exports.gitLabPrompts = exports.gatewayConnectivity = exports.completeInstall = exports.askConfigType = exports.askBundleType = exports.GitLabInstallMethods = exports.ConfigFiles = void 0;
7
+ var _chalk = _interopRequireDefault(require("chalk"));
8
+ var _snooplogg = _interopRequireDefault(require("snooplogg"));
9
+ var _basicPrompts = require("../../common/basicPrompts");
10
+ var _types = require("../../common/types");
11
+ var _utils = require("../../common/utils");
12
+ var helpers = _interopRequireWildcard(require("./helpers"));
13
+ var _gitLabTemplates = require("./helpers/templates/gitLabTemplates");
14
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
15
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
16
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
+ // @ts-ignore
18
+ const {
19
+ log
20
+ } = (0, _snooplogg.default)('central: install: agents: gitLab:');
21
+ const daImage = `${_types.PublicDockerRepoBaseUrl}${_types.BasePaths.DockerAgentPublicRepo}/${_types.AgentNames.GITLAB_DA}`;
22
+
23
+ // ConfigFiles - all the config file that are used in the setup
24
+ const ConfigFiles = exports.ConfigFiles = {
25
+ DAEnvVars: `${helpers.configFiles.DA_ENV_VARS}`
26
+ };
27
+ const gitLabPrompts = exports.gitLabPrompts = {
28
+ ACCESS_TOKEN: 'Enter the GitLab Access Token the agent will use',
29
+ BASE_URL: 'Enter the GitLab base URL that the agent will use',
30
+ REPOSITORY_ID: 'Enter the GitLab Repository ID the agent will use',
31
+ REPOSITORY_BRANCH: 'Enter the Repository Branch the agent will use',
32
+ PATHS: 'Enter a Path within the repository that the agent will use',
33
+ FILTERS: 'Enter a filter that the agent will use (Optional)',
34
+ DA_FREQUENCY: 'How often should the discovery run, leave blank for integrating in CI/CD process',
35
+ QUEUE: 'Do you want to discover immediately after installation',
36
+ ENTER_MORE_PATHS: 'Do you want to enter another path ?',
37
+ ENTER_MORE_FILTERS: 'Do you want to enter another filter ?'
38
+ };
39
+ const askBundleType = async () => {
40
+ return _types.BundleType.DISCOVERY;
41
+ };
42
+ exports.askBundleType = askBundleType;
43
+ const askConfigType = async () => {
44
+ return _types.AgentConfigTypes.DOCKERIZED;
45
+ };
46
+
47
+ // Questions for the gitLab configuration
48
+ exports.askConfigType = askConfigType;
49
+ const askForGitLabToken = async () => await (0, _basicPrompts.askInput)({
50
+ msg: gitLabPrompts.ACCESS_TOKEN,
51
+ validate: (0, _basicPrompts.validateRegex)(helpers.GitLabRegexPatterns.gitLabAccessTokenRegex, helpers.invalidValueExampleErrMsg('AccessToken', 'mockToken'))
52
+ });
53
+ const askForGitLabBaseURL = async () => await (0, _basicPrompts.askInput)({
54
+ msg: gitLabPrompts.BASE_URL
55
+ });
56
+ const askForGitLabRepositoryID = async () => await (0, _basicPrompts.askInput)({
57
+ msg: gitLabPrompts.REPOSITORY_ID,
58
+ validate: (0, _basicPrompts.validateRegex)(helpers.GitLabRegexPatterns.gitHubRepositoryIDRegex, helpers.invalidValueExampleErrMsg('RepositoryID', '12312'))
59
+ });
60
+ const askForGitLabRepositoryBranch = async () => await (0, _basicPrompts.askInput)({
61
+ msg: gitLabPrompts.REPOSITORY_BRANCH
62
+ });
63
+ const askForGitLabPaths = async () => {
64
+ let askPaths = true;
65
+ let paths = [];
66
+ console.log(_chalk.default.gray("An array of paths within the repository that the agent will gather files for looking for specs"));
67
+ while (askPaths) {
68
+ const path = await (0, _basicPrompts.askInput)({
69
+ msg: gitLabPrompts.PATHS,
70
+ allowEmptyInput: false,
71
+ validate: (0, _basicPrompts.validateRegex)(helpers.GitLabRegexPatterns.gitLabPathRegex, helpers.invalidValueExampleErrMsg('File Path', '/apis'))
72
+ });
73
+ paths.push(path);
74
+ askPaths = (await (0, _basicPrompts.askList)({
75
+ msg: gitLabPrompts.ENTER_MORE_PATHS,
76
+ default: _types.YesNo.No,
77
+ choices: _types.YesNoChoices
78
+ })) === _types.YesNo.Yes;
79
+ }
80
+ return paths;
81
+ };
82
+ const askForGitLabFilters = async () => {
83
+ let askFilters = true;
84
+ let filters = [];
85
+ console.log(_chalk.default.gray("An array of regular expressions that a file name must match to be discovered"));
86
+ while (askFilters) {
87
+ const filter = await (0, _basicPrompts.askInput)({
88
+ msg: gitLabPrompts.FILTERS,
89
+ allowEmptyInput: true
90
+ });
91
+ filters.push(filter);
92
+ askFilters = (await (0, _basicPrompts.askList)({
93
+ msg: gitLabPrompts.ENTER_MORE_FILTERS,
94
+ default: _types.YesNo.No,
95
+ choices: _types.YesNoChoices
96
+ })) === _types.YesNo.Yes;
97
+ }
98
+ return filters;
99
+ };
100
+ const gatewayConnectivity = async installConfig => {
101
+ let gitLabAgentValues = new _gitLabTemplates.GitLabAgentValues();
102
+ if (installConfig.switches.isDockerInstall) {
103
+ console.log('\nCONNECTION TO GitHub API GATEWAY:');
104
+ console.log(_chalk.default.gray("The Discovery Agent needs to connect to the GitHub API Gateway to discover API's for publishing to Amplify Central"));
105
+ gitLabAgentValues.token = await askForGitLabToken();
106
+ gitLabAgentValues.baseURL = await askForGitLabBaseURL();
107
+ gitLabAgentValues.repositoryID = await askForGitLabRepositoryID();
108
+ gitLabAgentValues.repositoryBranch = await askForGitLabRepositoryBranch();
109
+ gitLabAgentValues.paths = await askForGitLabPaths();
110
+ gitLabAgentValues.filters = await askForGitLabFilters();
111
+ }
112
+ return gitLabAgentValues;
113
+ };
114
+ exports.gatewayConnectivity = gatewayConnectivity;
115
+ const dockerSuccessMsg = installConfig => {
116
+ let dockerInfo;
117
+ const runDaLinuxMsg = `docker run -it --env-file ${helpers.pwd}/${helpers.configFiles.DA_ENV_VARS} -v ${helpers.pwd}:/keys ${helpers.eolChar}`;
118
+ const runDaWinMsg = `docker run -it --env-file ${helpers.pwdWin}/${helpers.configFiles.DA_ENV_VARS} -v ${helpers.pwdWin}:/keys ${helpers.eolCharWin}`;
119
+ const startDaLinuxMsg = `\nStart the Discovery Agent on a Linux based machine`;
120
+ const startDaWinMsg = `\nStart the Discovery Agent on a Windows machine`;
121
+ if (installConfig.switches.isDaEnabled) {
122
+ dockerInfo = `To utilize the discovery agent, pull the latest Docker image and run it using the supplied environment file, (${helpers.configFiles.DA_ENV_VARS}):`;
123
+ }
124
+ console.log(_chalk.default.whiteBright(dockerInfo), '\n');
125
+ if (installConfig.switches.isDaEnabled) {
126
+ const daImageVersion = `${daImage}:${installConfig.daVersion}`;
127
+ console.log(_chalk.default.white('Pull the latest image of the Discovery Agent:'));
128
+ console.log(_chalk.default.cyan(`docker pull ${daImageVersion}`));
129
+ console.log(_chalk.default.white(_utils.isWindows ? startDaWinMsg : startDaLinuxMsg));
130
+ console.log(_chalk.default.cyan(_utils.isWindows ? runDaWinMsg : runDaLinuxMsg));
131
+ console.log('\t', _chalk.default.cyan(`-v /data ${daImageVersion}`));
132
+ }
133
+ };
134
+ const generateSuccessHelpMsg = installConfig => {
135
+ const configType = installConfig.deploymentType;
136
+ if (configType === _types.AgentConfigTypes.DOCKERIZED) {
137
+ dockerSuccessMsg(installConfig);
138
+ }
139
+ };
140
+ const installPreprocess = async installConfig => {
141
+ return installConfig;
142
+ };
143
+ exports.installPreprocess = installPreprocess;
144
+ const completeInstall = async installConfig => {
145
+ /**
146
+ * Create agent resources
147
+ */
148
+ const gitLabAgentValues = installConfig.gatewayConfig;
149
+
150
+ // Add final settings to gitLabAgentValues
151
+ gitLabAgentValues.centralConfig = installConfig.centralConfig;
152
+ gitLabAgentValues.daVersion = installConfig.daVersion;
153
+ if (installConfig.switches.isDockerInstall) {
154
+ if (installConfig.switches.isDaEnabled) {
155
+ (0, _utils.writeTemplates)(ConfigFiles.DAEnvVars, gitLabAgentValues, helpers.gitLabDAEnvVarTemplate);
156
+ }
157
+ }
158
+ console.log('Configuration file(s) have been successfully created.\n');
159
+ generateSuccessHelpMsg(installConfig);
160
+ };
161
+ exports.completeInstall = completeInstall;
162
+ const GitLabInstallMethods = exports.GitLabInstallMethods = {
163
+ GetBundleType: askBundleType,
164
+ GetDeploymentType: askConfigType,
165
+ AskGatewayQuestions: gatewayConnectivity,
166
+ InstallPreprocess: installPreprocess,
167
+ FinalizeGatewayInstall: completeInstall,
168
+ ConfigFiles: Object.values(ConfigFiles),
169
+ GatewayDisplay: _types.GatewayTypes.GITLAB
170
+ };
171
+ const testables = exports.testables = {
172
+ gitLabPrompts,
173
+ ConfigFiles
174
+ };
@@ -128,6 +128,18 @@ Object.keys(_istioTemplates).forEach(function (key) {
128
128
  }
129
129
  });
130
130
  });
131
+ var _gitLabTemplates = require("./templates/gitLabTemplates");
132
+ Object.keys(_gitLabTemplates).forEach(function (key) {
133
+ if (key === "default" || key === "__esModule") return;
134
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
135
+ if (key in exports && exports[key] === _gitLabTemplates[key]) return;
136
+ Object.defineProperty(exports, key, {
137
+ enumerable: true,
138
+ get: function () {
139
+ return _gitLabTemplates[key];
140
+ }
141
+ });
142
+ });
131
143
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
132
144
  const streamPipeline = exports.streamPipeline = _util.default.promisify(_stream.default.pipeline);
133
145
  const unzip = async filePath => {
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.resourceRegex = exports.percentageRegex = exports.namespaceRegex = exports.maskingRegex = exports.invalidResourceMsg = exports.invalidPercentage = exports.invalidNamespace = exports.invalidDosaName = exports.invalidDomainName = exports.frequencyRegex = exports.dosaRegex = exports.domainNameRegex = exports.GitHubRegexPatterns = exports.AzureRegexPatterns = exports.AWSRegexPatterns = exports.APIGEEXRegexPatterns = void 0;
6
+ exports.resourceRegex = exports.percentageRegex = exports.namespaceRegex = exports.maskingRegex = exports.invalidResourceMsg = exports.invalidPercentage = exports.invalidNamespace = exports.invalidDosaName = exports.invalidDomainName = exports.frequencyRegex = exports.dosaRegex = exports.domainNameRegex = exports.GitLabRegexPatterns = exports.GitHubRegexPatterns = exports.AzureRegexPatterns = exports.AWSRegexPatterns = exports.APIGEEXRegexPatterns = void 0;
7
7
  const resourceRegex = exports.resourceRegex = '^(?:[a-z0-9]*(?:\\.(?=[a-z0-9])|-+(?=[a-z0-9]))?)+[a-z0-9]$';
8
8
  const namespaceRegex = exports.namespaceRegex = '^[a-z0-9]?(?:[-a-z0-9]*[a-z0-9]){1,100}?$';
9
9
  const domainNameRegex = exports.domainNameRegex = '^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9])\\.)+([A-Za-z]){2,}$';
@@ -51,4 +51,9 @@ const GitHubRegexPatterns = exports.GitHubRegexPatterns = {
51
51
  gitHubRepositoryOwnerRegex: '^(?!-)(?!.*--)[a-zA-Z0-9-]{1,37}(?<!-)$',
52
52
  gitHubRepositoryNameRegex: '^[\w-\.]+$',
53
53
  gitHubFilePathRegex: '^\/.*$'
54
+ };
55
+ const GitLabRegexPatterns = exports.GitLabRegexPatterns = {
56
+ gitLabAccessTokenRegex: '^[0-9a-zA-Z\-]{20}$',
57
+ gitHubRepositoryIDRegex: '^[0-9]*$',
58
+ gitLabPathRegex: '^\/.*$'
54
59
  };
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.gitLabDAEnvVarTemplate = exports.GitLabAgentValues = void 0;
7
+ var _types = require("../../../../common/types");
8
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
9
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
10
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } /**
11
+ * @description Values to provide to the gitLab templates.
12
+ */
13
+ class GitLabAgentValues {
14
+ constructor() {
15
+ _defineProperty(this, "token", void 0);
16
+ _defineProperty(this, "baseURL", void 0);
17
+ _defineProperty(this, "repositoryID", void 0);
18
+ _defineProperty(this, "repositoryBranch", void 0);
19
+ _defineProperty(this, "paths", void 0);
20
+ _defineProperty(this, "filters", void 0);
21
+ _defineProperty(this, "daQueueName", void 0);
22
+ _defineProperty(this, "daVersion", void 0);
23
+ _defineProperty(this, "centralConfig", void 0);
24
+ this.token = '';
25
+ this.baseURL = '';
26
+ this.repositoryID = '';
27
+ this.repositoryBranch = '';
28
+ this.daQueueName = '';
29
+ this.daVersion = '';
30
+ this.paths = [];
31
+ this.filters = [];
32
+ this.centralConfig = new _types.CentralAgentConfig();
33
+ }
34
+ }
35
+ exports.GitLabAgentValues = GitLabAgentValues;
36
+ const gitLabDAEnvVarTemplate = () => {
37
+ return `# GitLab configs
38
+ GITLAB_TOKEN={{token}}
39
+ GITLAB_BASE_URL={{baseURL}}
40
+ GITLAB_REPOSITORY_ID={{repositoryID}}
41
+ GITLAB_REPOSITORY_BRANCH={{repositoryBranch}}
42
+ GITLAB_PATHS={{paths}}
43
+ GITLAB_FILTERS={{filters}}
44
+
45
+ # Amplify Central configs
46
+ CENTRAL_AGENTNAME={{centralConfig.daAgentName}}
47
+ CENTRAL_AUTH_CLIENTID={{centralConfig.dosaAccount.clientId}}
48
+ CENTRAL_AUTH_PRIVATEKEY={{centralConfig.dosaAccount.templatePrivateKey}}
49
+ CENTRAL_AUTH_PUBLICKEY={{centralConfig.dosaAccount.templatePublicKey}}
50
+ CENTRAL_ENVIRONMENT={{centralConfig.environment}}
51
+ CENTRAL_ORGANIZATIONID={{centralConfig.orgId}}
52
+ {{#compare . centralConfig.ampcTeamName "" operator="!=" }}
53
+ CENTRAL_TEAM={{centralConfig.ampcTeamName}}
54
+ {{/compare}}
55
+ CENTRAL_SINGLEURL={{centralConfig.singleEntryPointUrl}}
56
+ {{#compare . centralConfig.region "US" operator="!="}}
57
+ CENTRAL_URL={{centralConfig.url}}
58
+ {{/compare}}
59
+
60
+ # Logging configs
61
+ # Define the logging level: info, debug, error
62
+ LOG_LEVEL=info
63
+ # Specify where to send the log: stdout, file, both
64
+ LOG_OUTPUT=stdout
65
+ # Define where the log files are written
66
+ LOG_FILE_PATH=logs
67
+ `;
68
+ };
69
+ exports.gitLabDAEnvVarTemplate = gitLabDAEnvVarTemplate;
@@ -215,6 +215,7 @@ let AgentNames = exports.AgentNames = /*#__PURE__*/function (AgentNames) {
215
215
  AgentNames["AWS_DA"] = "aws-apigw-discovery-agent";
216
216
  AgentNames["AWS_TA"] = "aws-apigw-traceability-agent";
217
217
  AgentNames["GITHUB_DA"] = "github-discovery-agent";
218
+ AgentNames["GITLAB_DA"] = "gitlab-discovery-agent";
218
219
  AgentNames["APIGEEX_DA"] = "apigee-discovery-agent";
219
220
  AgentNames["APIGEEX_TA"] = "apigee-traceability-agent";
220
221
  AgentNames["AZURE_DA"] = "azure-discovery-agent";
@@ -229,6 +230,7 @@ let GatewayTypes = exports.GatewayTypes = /*#__PURE__*/function (GatewayTypes) {
229
230
  GatewayTypes["APIGEEX_GATEWAY"] = "Apigee X Gateway";
230
231
  GatewayTypes["AZURE_GATEWAY"] = "Azure API Gateway";
231
232
  GatewayTypes["GITHUB"] = "GitHub";
233
+ GatewayTypes["GITLAB"] = "GitLab";
232
234
  GatewayTypes["ISTIO"] = "Istio";
233
235
  GatewayTypes["EDGE_GATEWAY_ONLY"] = "Amplify API Gateway only";
234
236
  return GatewayTypes;
@@ -243,6 +245,7 @@ let DataPlaneNames = exports.DataPlaneNames = /*#__PURE__*/function (DataPlaneNa
243
245
  DataPlaneNames["APIGEE"] = "Apigee";
244
246
  DataPlaneNames["AWS"] = "AWS";
245
247
  DataPlaneNames["GITHUB"] = "GitHub";
248
+ DataPlaneNames["GITLAB"] = "GitLab";
246
249
  DataPlaneNames["AZURE"] = "Azure";
247
250
  DataPlaneNames["EDGE"] = "Edge";
248
251
  DataPlaneNames["KONG"] = "Kong";
@@ -256,6 +259,7 @@ const GatewayTypeToDataPlane = exports.GatewayTypeToDataPlane = {
256
259
  [GatewayTypes.EDGE_GATEWAY_ONLY]: DataPlaneNames.EDGE,
257
260
  [GatewayTypes.AWS_GATEWAY]: DataPlaneNames.AWS,
258
261
  [GatewayTypes.GITHUB]: DataPlaneNames.GITHUB,
262
+ [GatewayTypes.GITLAB]: DataPlaneNames.GITLAB,
259
263
  [GatewayTypes.AZURE_GATEWAY]: DataPlaneNames.AZURE,
260
264
  [GatewayTypes.ISTIO]: 'Istio',
261
265
  [GatewayTypes.APIGEEX_GATEWAY]: DataPlaneNames.APIGEE
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axway/axway-central-cli",
3
- "version": "2.18.0",
3
+ "version": "2.19.0-rc.0",
4
4
  "description": "Manage APIs, services and publish to the Unified Catalog",
5
5
  "homepage": "https://platform.axway.com",
6
6
  "author": {