@axway/axway-central-cli 2.17.0-rc.5 → 2.17.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.
- package/dist/cli.js +28 -6
- package/dist/commands/apply/index.js +24 -9
- package/dist/commands/completion/index.js +9 -3
- package/dist/commands/config/common/index.js +11 -2
- package/dist/commands/config/index.js +7 -2
- package/dist/commands/config/list.js +6 -2
- package/dist/commands/config/set.js +31 -4
- package/dist/commands/config/unset.js +12 -2
- package/dist/commands/create/agentResource.js +32 -12
- package/dist/commands/create/environment.js +16 -6
- package/dist/commands/create/index.js +26 -9
- package/dist/commands/create/serviceAccount.js +6 -2
- package/dist/commands/delete/index.js +33 -15
- package/dist/commands/edit/environment.js +21 -6
- package/dist/commands/edit/index.js +8 -4
- package/dist/commands/get/index.js +44 -27
- package/dist/commands/install/agents.js +73 -44
- package/dist/commands/install/apigeexSaasAgents.js +98 -35
- package/dist/commands/install/awsAgents.js +139 -89
- package/dist/commands/install/awsSaasAgents.js +142 -50
- package/dist/commands/install/azureAgents.js +79 -39
- package/dist/commands/install/edgeAgents.js +110 -17
- package/dist/commands/install/helpers/creators.js +70 -17
- package/dist/commands/install/helpers/deleters.js +11 -2
- package/dist/commands/install/helpers/getters.js +30 -4
- package/dist/commands/install/helpers/index.js +48 -13
- package/dist/commands/install/helpers/inputs.js +98 -26
- package/dist/commands/install/helpers/regex.js +34 -29
- package/dist/commands/install/helpers/templates/awsTemplates.js +23 -6
- package/dist/commands/install/helpers/templates/azureTemplates.js +24 -5
- package/dist/commands/install/helpers/templates/edgeTemplates.js +38 -7
- package/dist/commands/install/helpers/templates/istioTemplates.js +16 -5
- package/dist/commands/install/index.js +10 -4
- package/dist/commands/install/istioAgents.js +117 -40
- package/dist/commands/install/platform.js +52 -20
- package/dist/commands/proxies/create.js +18 -2
- package/dist/commands/proxies/index.js +8 -4
- package/dist/commands/proxies/promote.js +21 -2
- package/dist/common/ApiServerClient.js +173 -64
- package/dist/common/CacheController.js +32 -11
- package/dist/common/CliConfigManager.js +27 -14
- package/dist/common/CompositeError.js +30 -6
- package/dist/common/CoreConfigController.js +40 -18
- package/dist/common/DefinitionsManager.js +76 -29
- package/dist/common/Kubectl.js +25 -2
- package/dist/common/PlatformClient.js +63 -19
- package/dist/common/Renderer.js +87 -25
- package/dist/common/TmpFile.js +28 -11
- package/dist/common/bashCommands.js +22 -3
- package/dist/common/basicPrompts.js +43 -8
- package/dist/common/dataService.js +50 -22
- package/dist/common/errorHandler.js +9 -0
- package/dist/common/resultsRenderers.js +42 -10
- package/dist/common/types.js +341 -116
- package/dist/common/utils.js +99 -37
- package/dist/main.js +2 -0
- package/package.json +2 -2
- package/dist/commands/install/gitHubSaasAgents.js +0 -283
package/dist/common/utils.js
CHANGED
|
@@ -7,27 +7,43 @@ exports.FormatString = FormatString;
|
|
|
7
7
|
exports.parseScopeParam = exports.loadAndVerifySpecs = exports.loadAndVerifyApigeeXCredentialFile = exports.isWindows = exports.isValidJson = exports.isApiServerErrorType = exports.isApiServerErrorResponseType = exports.hbsCompare = exports.getConfig = exports.configFile = exports.compareResourcesByKindDesc = exports.compareResourcesByKindAsc = exports.buildTemplate = exports.buildGenericResource = void 0;
|
|
8
8
|
exports.sanitizeMetadata = sanitizeMetadata;
|
|
9
9
|
exports.writeToFile = exports.writeTemplates = exports.verifyScopeParam = exports.verifyFile = exports.transformSimpleFilters = void 0;
|
|
10
|
+
|
|
10
11
|
var _fsExtra = require("fs-extra");
|
|
12
|
+
|
|
11
13
|
var _handlebars = _interopRequireDefault(require("handlebars"));
|
|
14
|
+
|
|
12
15
|
var _jsYaml = require("js-yaml");
|
|
16
|
+
|
|
13
17
|
var _os = require("os");
|
|
18
|
+
|
|
14
19
|
var _path = require("path");
|
|
20
|
+
|
|
15
21
|
var _CompositeError = require("./CompositeError");
|
|
22
|
+
|
|
16
23
|
var _types = require("./types");
|
|
24
|
+
|
|
17
25
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
|
-
|
|
19
|
-
const
|
|
26
|
+
|
|
27
|
+
const isWindows = /^win/.test(process.platform);
|
|
28
|
+
exports.isWindows = isWindows;
|
|
29
|
+
const configFile = (0, _path.join)((0, _os.homedir)(), '.axway', 'central.json');
|
|
30
|
+
exports.configFile = configFile;
|
|
31
|
+
|
|
20
32
|
const getConfig = async () => !(0, _fsExtra.existsSync)(configFile) ? Promise.resolve({}) : await (0, _fsExtra.readJson)(configFile);
|
|
33
|
+
|
|
21
34
|
exports.getConfig = getConfig;
|
|
35
|
+
|
|
22
36
|
const verifyFile = specFilePath => {
|
|
23
37
|
let stats;
|
|
24
38
|
let fileExtension;
|
|
39
|
+
|
|
25
40
|
try {
|
|
26
41
|
stats = (0, _fsExtra.lstatSync)(specFilePath);
|
|
27
42
|
fileExtension = (0, _path.extname)(specFilePath);
|
|
28
43
|
} catch (e) {
|
|
29
44
|
throw new Error(`Couldn't find the definition file: ${specFilePath}`);
|
|
30
45
|
}
|
|
46
|
+
|
|
31
47
|
if (!stats.isFile()) {
|
|
32
48
|
throw new Error(`Couldn't load the definition file: ${specFilePath}`);
|
|
33
49
|
} else if (stats.size >= _types.MAX_FILE_SIZE) {
|
|
@@ -36,7 +52,9 @@ const verifyFile = specFilePath => {
|
|
|
36
52
|
throw new Error(`File extension is invalid, please provide '.yaml' or '.yml' or '.json' file`);
|
|
37
53
|
}
|
|
38
54
|
};
|
|
55
|
+
|
|
39
56
|
exports.verifyFile = verifyFile;
|
|
57
|
+
|
|
40
58
|
const writeToFile = (path, data) => {
|
|
41
59
|
try {
|
|
42
60
|
(0, _fsExtra.writeFileSync)(path, data);
|
|
@@ -45,86 +63,93 @@ const writeToFile = (path, data) => {
|
|
|
45
63
|
throw new Error(`Error while writing the yaml file to: ${path}`);
|
|
46
64
|
}
|
|
47
65
|
};
|
|
48
|
-
|
|
49
66
|
/**
|
|
50
67
|
* Checks if the passed item can be converted to a JSON or is a valid JSON object.
|
|
51
68
|
* @param item item to check
|
|
52
69
|
* @returns true if the item can be converted, false otherwise.
|
|
53
70
|
*/
|
|
71
|
+
|
|
72
|
+
|
|
54
73
|
exports.writeToFile = writeToFile;
|
|
74
|
+
|
|
55
75
|
const isValidJson = item => {
|
|
56
76
|
let parsedItem = typeof item !== 'string' ? JSON.stringify(item) : item;
|
|
77
|
+
|
|
57
78
|
try {
|
|
58
79
|
parsedItem = JSON.parse(parsedItem);
|
|
59
80
|
} catch (e) {
|
|
60
81
|
return false;
|
|
61
82
|
}
|
|
83
|
+
|
|
62
84
|
return typeof parsedItem === 'object' && item !== null;
|
|
63
85
|
};
|
|
64
|
-
|
|
65
86
|
/**
|
|
66
87
|
* Loads and parse file from path, accepts JSON and YAML files. Also completing validation on "kind" values.
|
|
67
88
|
* @param specFilePath file path
|
|
68
89
|
* @param allowedKinds array of allowed "kind" values
|
|
69
90
|
*/
|
|
91
|
+
|
|
92
|
+
|
|
70
93
|
exports.isValidJson = isValidJson;
|
|
94
|
+
|
|
71
95
|
const loadAndVerifySpecs = async (specFilePath, allowedKinds) => {
|
|
72
96
|
// Load the given JSON or YAML file.
|
|
73
97
|
let docs = [];
|
|
74
98
|
let isMissingName = false;
|
|
99
|
+
|
|
75
100
|
try {
|
|
76
101
|
docs = (0, _jsYaml.loadAll)(await (0, _fsExtra.readFile)(specFilePath, 'utf8'));
|
|
77
102
|
} catch (e) {
|
|
78
103
|
throw new Error(e.reason && e.reason.includes('null byte') ? `File encoding is invalid, please make sure it is using UTF-8` : `File content is invalid.`);
|
|
79
|
-
}
|
|
104
|
+
} // if user pass an array of json objects, docs const will have nested array, workaround for this:
|
|
105
|
+
|
|
80
106
|
|
|
81
|
-
// if user pass an array of json objects, docs const will have nested array, workaround for this:
|
|
82
107
|
if ((0, _path.extname)(specFilePath) === '.json' && docs.length === 1 && Array.isArray(docs[0])) {
|
|
83
108
|
docs = docs[0];
|
|
84
|
-
}
|
|
109
|
+
} // Do not continue if given an empty file.
|
|
110
|
+
|
|
85
111
|
|
|
86
|
-
|
|
87
|
-
if (!docs.length) throw new Error(`File is empty.`);
|
|
112
|
+
if (!docs.length) throw new Error(`File is empty.`); // Validate all entries in the file.
|
|
88
113
|
|
|
89
|
-
// Validate all entries in the file.
|
|
90
114
|
const errors = [];
|
|
115
|
+
|
|
91
116
|
const createErrorPrefix = (index, kind, name) => {
|
|
92
117
|
return `Entry ${index + 1}, "${kind}/${name || 'Unknown name'}"`;
|
|
93
118
|
};
|
|
119
|
+
|
|
94
120
|
for (let index = 0; index < docs.length; index++) {
|
|
95
121
|
// Verify document is defined/valid.
|
|
96
122
|
const doc = docs[index];
|
|
123
|
+
|
|
97
124
|
if (typeof doc !== 'object' || !doc) {
|
|
98
125
|
errors.push(new Error(`${createErrorPrefix(index)}: Entry format is invalid.`));
|
|
99
126
|
continue;
|
|
100
|
-
}
|
|
127
|
+
} // Set a flag if at least 1 name is messing in file.
|
|
128
|
+
|
|
101
129
|
|
|
102
|
-
// Set a flag if at least 1 name is messing in file.
|
|
103
130
|
if (!doc.name) {
|
|
104
131
|
isMissingName = true;
|
|
105
|
-
}
|
|
132
|
+
} // Validate resource kind.
|
|
133
|
+
|
|
106
134
|
|
|
107
|
-
// Validate resource kind.
|
|
108
135
|
if (!doc.kind) {
|
|
109
136
|
errors.push(Error(`${createErrorPrefix(index, doc.kind, doc.name)}: The "kind" field is missing.` + `\nCurrently supported values are (case sensitive): ${[...allowedKinds.values()].join(', ')}`));
|
|
110
137
|
} else if (!allowedKinds.has(doc.kind)) {
|
|
111
138
|
errors.push(new Error(`${createErrorPrefix(index, doc.kind, doc.name)}: Kind "${doc.kind}" is unsupported.` + `\nCurrently supported values are (case sensitive): ${[...allowedKinds.values()].join(', ')}`));
|
|
112
|
-
}
|
|
139
|
+
} // TODO: Validate "metadata.scope.kind" if available. Requires DefinitionManager.getSortedKindsMap() result.
|
|
113
140
|
|
|
114
|
-
// TODO: Validate "metadata.scope.kind" if available. Requires DefinitionManager.getSortedKindsMap() result.
|
|
115
141
|
}
|
|
116
142
|
|
|
117
143
|
if (errors.length > 0) {
|
|
118
144
|
throw new _CompositeError.CompositeError(errors);
|
|
119
|
-
}
|
|
145
|
+
} // File's contents appears to be valid. Return loaded info.
|
|
146
|
+
|
|
120
147
|
|
|
121
|
-
// File's contents appears to be valid. Return loaded info.
|
|
122
148
|
return {
|
|
123
149
|
docs,
|
|
124
150
|
isMissingName
|
|
125
151
|
};
|
|
126
152
|
};
|
|
127
|
-
|
|
128
153
|
/**
|
|
129
154
|
* Generate a GenericResource instance from resource definition, resource name, and scope name. Used
|
|
130
155
|
* in some rendering logic for the "delete" command.
|
|
@@ -134,7 +159,10 @@ const loadAndVerifySpecs = async (specFilePath, allowedKinds) => {
|
|
|
134
159
|
* @param {string} scopeName optional scope name
|
|
135
160
|
* @returns {GenericResource} generic resource representation
|
|
136
161
|
*/
|
|
162
|
+
|
|
163
|
+
|
|
137
164
|
exports.loadAndVerifySpecs = loadAndVerifySpecs;
|
|
165
|
+
|
|
138
166
|
const buildGenericResource = ({
|
|
139
167
|
resourceDef,
|
|
140
168
|
resourceName,
|
|
@@ -152,63 +180,74 @@ const buildGenericResource = ({
|
|
|
152
180
|
scope: {
|
|
153
181
|
kind: resourceDef.spec.scope.kind,
|
|
154
182
|
name: scopeName
|
|
155
|
-
}
|
|
156
|
-
|
|
183
|
+
} // note: forced conversion here only because using generated resources for rendering simple text
|
|
184
|
+
|
|
157
185
|
} : undefined,
|
|
158
186
|
spec: {}
|
|
159
187
|
};
|
|
160
188
|
};
|
|
161
|
-
|
|
162
189
|
/**
|
|
163
190
|
* Returns true if error object is of type ApiServerError
|
|
164
191
|
* @param err error object to check
|
|
165
192
|
*/
|
|
193
|
+
|
|
194
|
+
|
|
166
195
|
exports.buildGenericResource = buildGenericResource;
|
|
196
|
+
|
|
167
197
|
const isApiServerErrorType = err => {
|
|
168
198
|
const cast = err;
|
|
169
199
|
return !!cast.status && !!cast.title && !!cast.detail;
|
|
170
200
|
};
|
|
171
|
-
|
|
172
201
|
/**
|
|
173
202
|
* Returns true if error object is of type ApiServerErrorResponse
|
|
174
203
|
* @param err error object to check
|
|
175
204
|
*/
|
|
205
|
+
|
|
206
|
+
|
|
176
207
|
exports.isApiServerErrorType = isApiServerErrorType;
|
|
208
|
+
|
|
177
209
|
const isApiServerErrorResponseType = err => {
|
|
178
210
|
const cast = err;
|
|
179
211
|
return !!cast.errors && Array.isArray(cast.errors);
|
|
180
212
|
};
|
|
181
|
-
|
|
182
213
|
/**
|
|
183
214
|
* Wrapper to return a compare function for sorting by "kind" value in array of resources in ascending
|
|
184
215
|
* order. Order based on "sortedKindValues" array.
|
|
185
216
|
* @param {Array<ResourceDefinition>} sortedResourceDefs array of ResourceDefinitions defining a required order of the resources.
|
|
186
217
|
* @returns {Function} Array sorting function
|
|
187
218
|
*/
|
|
219
|
+
|
|
220
|
+
|
|
188
221
|
exports.isApiServerErrorResponseType = isApiServerErrorResponseType;
|
|
222
|
+
|
|
189
223
|
const compareResourcesByKindAsc = sortedResourceDefs => (a, b) => sortedResourceDefs.findIndex(def => {
|
|
190
224
|
var _def$spec$scope, _a$metadata, _a$metadata$scope;
|
|
225
|
+
|
|
191
226
|
return def.spec.kind === a.kind && ((_def$spec$scope = def.spec.scope) === null || _def$spec$scope === void 0 ? void 0 : _def$spec$scope.kind) === ((_a$metadata = a.metadata) === null || _a$metadata === void 0 ? void 0 : (_a$metadata$scope = _a$metadata.scope) === null || _a$metadata$scope === void 0 ? void 0 : _a$metadata$scope.kind);
|
|
192
227
|
}) - sortedResourceDefs.findIndex(def => {
|
|
193
228
|
var _def$spec$scope2, _b$metadata, _b$metadata$scope;
|
|
229
|
+
|
|
194
230
|
return def.spec.kind === b.kind && ((_def$spec$scope2 = def.spec.scope) === null || _def$spec$scope2 === void 0 ? void 0 : _def$spec$scope2.kind) === ((_b$metadata = b.metadata) === null || _b$metadata === void 0 ? void 0 : (_b$metadata$scope = _b$metadata.scope) === null || _b$metadata$scope === void 0 ? void 0 : _b$metadata$scope.kind);
|
|
195
231
|
});
|
|
196
|
-
|
|
197
232
|
/**
|
|
198
233
|
* Wrapper to return a compare function for sorting by "kind" value in array of resources in descending
|
|
199
234
|
* order. Order based on "sortedKindValues" array.
|
|
200
235
|
* @param {Array<ResourceDefinition>} sortedResourceDefs array of ResourceDefinitions defining a required order of the resources.
|
|
201
236
|
* @returns {Function} Array sorting function
|
|
202
237
|
*/
|
|
238
|
+
|
|
239
|
+
|
|
203
240
|
exports.compareResourcesByKindAsc = compareResourcesByKindAsc;
|
|
241
|
+
|
|
204
242
|
const compareResourcesByKindDesc = sortedResourceDefs => (a, b) => sortedResourceDefs.findIndex(def => {
|
|
205
243
|
var _def$spec$scope3, _b$metadata2, _b$metadata2$scope;
|
|
244
|
+
|
|
206
245
|
return def.spec.kind === b.kind && ((_def$spec$scope3 = def.spec.scope) === null || _def$spec$scope3 === void 0 ? void 0 : _def$spec$scope3.kind) === ((_b$metadata2 = b.metadata) === null || _b$metadata2 === void 0 ? void 0 : (_b$metadata2$scope = _b$metadata2.scope) === null || _b$metadata2$scope === void 0 ? void 0 : _b$metadata2$scope.kind);
|
|
207
246
|
}) - sortedResourceDefs.findIndex(def => {
|
|
208
247
|
var _def$spec$scope4, _a$metadata2, _a$metadata2$scope;
|
|
248
|
+
|
|
209
249
|
return def.spec.kind === a.kind && ((_def$spec$scope4 = def.spec.scope) === null || _def$spec$scope4 === void 0 ? void 0 : _def$spec$scope4.kind) === ((_a$metadata2 = a.metadata) === null || _a$metadata2 === void 0 ? void 0 : (_a$metadata2$scope = _a$metadata2.scope) === null || _a$metadata2$scope === void 0 ? void 0 : _a$metadata2$scope.kind);
|
|
210
250
|
});
|
|
211
|
-
|
|
212
251
|
/**
|
|
213
252
|
* Api-server returns the "resourceVersion" in metadata object as a counter for resource updates.
|
|
214
253
|
* If a user will send this key in the payload it will throw an error so using this helper to sanitizing metadata on
|
|
@@ -216,21 +255,27 @@ const compareResourcesByKindDesc = sortedResourceDefs => (a, b) => sortedResourc
|
|
|
216
255
|
* @param doc resource data
|
|
217
256
|
* @returns {GenericResource} resource data without metadata.resourceVersion key
|
|
218
257
|
*/
|
|
258
|
+
|
|
259
|
+
|
|
219
260
|
exports.compareResourcesByKindDesc = compareResourcesByKindDesc;
|
|
261
|
+
|
|
220
262
|
function sanitizeMetadata(doc) {
|
|
221
263
|
var _doc$metadata;
|
|
264
|
+
|
|
222
265
|
if (doc !== null && doc !== void 0 && (_doc$metadata = doc.metadata) !== null && _doc$metadata !== void 0 && _doc$metadata.resourceVersion) {
|
|
223
266
|
delete doc.metadata.resourceVersion;
|
|
224
267
|
}
|
|
268
|
+
|
|
225
269
|
return doc;
|
|
226
270
|
}
|
|
271
|
+
|
|
227
272
|
const buildTemplate = (templateFunc, input) => {
|
|
228
273
|
const template = _handlebars.default.compile(templateFunc(), {
|
|
229
274
|
noEscape: true
|
|
230
275
|
});
|
|
276
|
+
|
|
231
277
|
return template(input);
|
|
232
278
|
};
|
|
233
|
-
|
|
234
279
|
/**
|
|
235
280
|
* Takes in a set of parameters (values), compiles a string utilizing the provided handlebars templating function (templateFunc)
|
|
236
281
|
* and the buildTemplate function with those parameters, and finally writes the output string to a file of the name that was provided (fileName).
|
|
@@ -238,19 +283,24 @@ const buildTemplate = (templateFunc, input) => {
|
|
|
238
283
|
* @param {object} values
|
|
239
284
|
* @param {()=>string} templateFunc
|
|
240
285
|
*/
|
|
286
|
+
|
|
287
|
+
|
|
241
288
|
exports.buildTemplate = buildTemplate;
|
|
289
|
+
|
|
242
290
|
const writeTemplates = (fileName, values, templateFunc) => {
|
|
243
291
|
const data = buildTemplate(templateFunc, values);
|
|
244
292
|
writeToFile(fileName, data);
|
|
245
293
|
};
|
|
246
|
-
|
|
247
294
|
/**
|
|
248
295
|
* helper function to extend the handlebars built-in helpers functionality to add a way to compare equality of two strings or numbers
|
|
249
296
|
* @param {string|number} lvalue
|
|
250
297
|
* @param {string|number} rvalue
|
|
251
298
|
* @param {{fn:(} options
|
|
252
299
|
*/
|
|
300
|
+
|
|
301
|
+
|
|
253
302
|
exports.writeTemplates = writeTemplates;
|
|
303
|
+
|
|
254
304
|
const hbsCompare = () => {
|
|
255
305
|
_handlebars.default.registerHelper('compare', (context, lvalue, rvalue, options) => {
|
|
256
306
|
let operator = options.hash.operator || '===';
|
|
@@ -281,6 +331,7 @@ const hbsCompare = () => {
|
|
|
281
331
|
}
|
|
282
332
|
};
|
|
283
333
|
var result = operators[operator](lvalue, rvalue);
|
|
334
|
+
|
|
284
335
|
if (result) {
|
|
285
336
|
return options.fn(context);
|
|
286
337
|
} else {
|
|
@@ -288,13 +339,15 @@ const hbsCompare = () => {
|
|
|
288
339
|
}
|
|
289
340
|
});
|
|
290
341
|
};
|
|
291
|
-
|
|
292
342
|
/**
|
|
293
343
|
* Parse and verify scope param, returns undefined if param is undefined. Throws an error if "Kind" is unknown.
|
|
294
344
|
* @param scopeParam raw scope param value
|
|
295
345
|
* @returns {ParsedScopeParam | undefined}
|
|
296
346
|
*/
|
|
347
|
+
|
|
348
|
+
|
|
297
349
|
exports.hbsCompare = hbsCompare;
|
|
350
|
+
|
|
298
351
|
const parseScopeParam = scopeParam => {
|
|
299
352
|
if (!scopeParam) return undefined;else if (scopeParam.indexOf('/') === -1) return {
|
|
300
353
|
name: scopeParam
|
|
@@ -308,7 +361,6 @@ const parseScopeParam = scopeParam => {
|
|
|
308
361
|
};
|
|
309
362
|
}
|
|
310
363
|
};
|
|
311
|
-
|
|
312
364
|
/**
|
|
313
365
|
* Verify parsed scope param:
|
|
314
366
|
* 1. scope kind should be known.
|
|
@@ -317,16 +369,19 @@ const parseScopeParam = scopeParam => {
|
|
|
317
369
|
* @param defs resource definitions where at least one should match the scope kind if some "scoped" resources are there.
|
|
318
370
|
* @param scopeParam parsed scope param.
|
|
319
371
|
*/
|
|
372
|
+
|
|
373
|
+
|
|
320
374
|
exports.parseScopeParam = parseScopeParam;
|
|
375
|
+
|
|
321
376
|
const verifyScopeParam = (allKinds, defs, scopeParam) => {
|
|
322
377
|
const allowedScopeKinds = new Set();
|
|
323
378
|
defs.forEach(defs => !!defs.scope && allowedScopeKinds.add(defs.scope.spec.kind));
|
|
379
|
+
|
|
324
380
|
if (scopeParam !== null && scopeParam !== void 0 && scopeParam.kind) {
|
|
325
381
|
if (!allKinds.has(scopeParam.kind)) throw new Error(`unsupported kind value "${scopeParam.kind}" in the "--scope" param.` + `\nCurrently supported values are (case sensitive): ${[...allKinds.values()].join(', ')}`);
|
|
326
382
|
if (allowedScopeKinds.size > 0 && !allowedScopeKinds.has(scopeParam.kind)) throw Error(`scope kind "${scopeParam.kind}" is invalid.` + `\n"${defs[0].resource.spec.kind}" resource might exist in the following scopes: ${[...allowedScopeKinds.values()].join(', ')}`);
|
|
327
383
|
}
|
|
328
384
|
};
|
|
329
|
-
|
|
330
385
|
/**
|
|
331
386
|
* Transforms simple filters(title, attribute, tag) into an RSQL-formatted query string the GET API supports.
|
|
332
387
|
* @param {string} title The title the user wants to filter the resource list by.
|
|
@@ -334,7 +389,10 @@ const verifyScopeParam = (allKinds, defs, scopeParam) => {
|
|
|
334
389
|
* @param {string} tag The tag the user wants to filter the resource list by.
|
|
335
390
|
* @returns {string} transformedFilter, the RSQL formatted query string
|
|
336
391
|
*/
|
|
392
|
+
|
|
393
|
+
|
|
337
394
|
exports.verifyScopeParam = verifyScopeParam;
|
|
395
|
+
|
|
338
396
|
const transformSimpleFilters = (title, attribute, tag) => {
|
|
339
397
|
const titleFilter = title ? `title=='*${title}*'` : '';
|
|
340
398
|
const attributeKey = attribute && attribute.split('=')[0];
|
|
@@ -345,33 +403,37 @@ const transformSimpleFilters = (title, attribute, tag) => {
|
|
|
345
403
|
const transformedFilter = formattedFilter.charAt(formattedFilter.length - 1) === ';' ? formattedFilter.slice(0, -1) : formattedFilter;
|
|
346
404
|
return transformedFilter;
|
|
347
405
|
};
|
|
406
|
+
|
|
348
407
|
exports.transformSimpleFilters = transformSimpleFilters;
|
|
408
|
+
|
|
349
409
|
function FormatString(str, ...val) {
|
|
350
410
|
for (let index = 0; index < val.length; index++) {
|
|
351
411
|
str = str.replace(`{${index}}`, val[index]);
|
|
352
412
|
}
|
|
413
|
+
|
|
353
414
|
return str;
|
|
354
415
|
}
|
|
355
|
-
|
|
356
416
|
/**
|
|
357
417
|
* Loads and parse file from path, accepts JSON file. Also validates additional details.
|
|
358
418
|
* @param credentialFilePath file path
|
|
359
419
|
*/
|
|
420
|
+
|
|
421
|
+
|
|
360
422
|
const loadAndVerifyApigeeXCredentialFile = async credentialFilePath => {
|
|
361
423
|
// Load the given JSON file.
|
|
362
424
|
let fileInfo = '';
|
|
425
|
+
|
|
363
426
|
try {
|
|
364
427
|
fileInfo = await (0, _fsExtra.readJson)(credentialFilePath);
|
|
365
428
|
} catch (e) {
|
|
366
429
|
throw new Error(e.reason);
|
|
367
|
-
}
|
|
430
|
+
} // Do not continue if given an empty file.
|
|
368
431
|
|
|
369
|
-
// Do not continue if given an empty file.
|
|
370
|
-
if (fileInfo === '') throw new Error(`File is empty.`);
|
|
371
|
-
|
|
372
|
-
// TODO: Validate additional details if needed
|
|
373
432
|
|
|
433
|
+
if (fileInfo === '') throw new Error(`File is empty.`); // TODO: Validate additional details if needed
|
|
374
434
|
// Return loaded info.
|
|
435
|
+
|
|
375
436
|
return fileInfo;
|
|
376
437
|
};
|
|
438
|
+
|
|
377
439
|
exports.loadAndVerifyApigeeXCredentialFile = loadAndVerifyApigeeXCredentialFile;
|
package/dist/main.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _cli = _interopRequireDefault(require("./cli"));
|
|
4
|
+
|
|
4
5
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
6
|
+
|
|
5
7
|
_cli.default.exec().catch(err => {
|
|
6
8
|
console.error(err);
|
|
7
9
|
process.exit(err.exitCode || 1);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axway/axway-central-cli",
|
|
3
|
-
"version": "2.17.0
|
|
3
|
+
"version": "2.17.0",
|
|
4
4
|
"description": "Manage APIs, services and publish to the Unified Catalog",
|
|
5
5
|
"homepage": "https://platform.axway.com",
|
|
6
6
|
"author": {
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"json5": "^2.2.3",
|
|
60
60
|
"lodash": "^4.17.21",
|
|
61
61
|
"node-cache": "^5.1.2",
|
|
62
|
-
"npm-check-updates": "16.
|
|
62
|
+
"npm-check-updates": "^16.10.8",
|
|
63
63
|
"ora": "^5.4.1",
|
|
64
64
|
"promise-limit": "^2.7.0",
|
|
65
65
|
"semver": "^7.3.7",
|