@axway/axway-central-cli 2.12.2 → 2.12.3
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.
|
@@ -133,14 +133,13 @@ ${defsManager.getDefsTableForHelpMsg()}`);
|
|
|
133
133
|
|
|
134
134
|
(0, _utils.verifyScopeParam)(defsManager.getAllKindsList(), defs, scope);
|
|
135
135
|
/**
|
|
136
|
-
1)
|
|
137
|
-
param
|
|
138
|
-
|
|
139
|
-
the path so api-server returns the entire list in all scopes, for example for "Document" kind calling
|
|
136
|
+
1) If "scope" param provided: execute getByName or getList calls for every definition that match this scope name/kind.
|
|
137
|
+
2) If "scope" param is not provided: execute list (get all) api calls for scoped resources without providing the scope in
|
|
138
|
+
the path so api-server returns the entire list in all scopes. For example, using "Document" kind and calling
|
|
140
139
|
https://apicentral.axway.com/apis/catalog/v1alpha1/documents returns a list of documents in Asset and AssetRelease
|
|
141
|
-
scopes in a single api call. So
|
|
142
|
-
|
|
143
|
-
|
|
140
|
+
scopes in a single api call. So getting unique list of groups and finding first matching definitions to do a call
|
|
141
|
+
Note: this logic might have some edge cases if same kind can be used for "scoped" and "scope" resources and api-server is
|
|
142
|
+
not handling this case correctly anymore.
|
|
144
143
|
*/
|
|
145
144
|
|
|
146
145
|
if (scope) {
|
|
@@ -158,10 +157,24 @@ ${defsManager.getDefsTableForHelpMsg()}`);
|
|
|
158
157
|
});
|
|
159
158
|
});
|
|
160
159
|
} else {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
160
|
+
const defsMatchingGroup = {};
|
|
161
|
+
defs.forEach(def => {
|
|
162
|
+
if (!defsMatchingGroup[def.resource.metadata.scope.name]) {
|
|
163
|
+
defsMatchingGroup[def.resource.metadata.scope.name] = def;
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
const results = await Promise.all(Object.values(defsMatchingGroup).map(async defs => ({
|
|
167
|
+
response: await getListOrByName(defs.resource, client, undefined, resourceName, undefined, query, progressListener),
|
|
168
|
+
cli: defs.cli
|
|
169
|
+
})));
|
|
170
|
+
results.forEach(({
|
|
171
|
+
response,
|
|
172
|
+
cli
|
|
173
|
+
}) => {
|
|
174
|
+
getResults.push({
|
|
175
|
+
columns: cli.spec.columns,
|
|
176
|
+
response
|
|
177
|
+
});
|
|
165
178
|
});
|
|
166
179
|
}
|
|
167
180
|
} // resolve team guids
|
|
@@ -28,10 +28,10 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
28
28
|
const {
|
|
29
29
|
log
|
|
30
30
|
} = (0, _snooplogg.default)('central:class.DefinitionsManager');
|
|
31
|
+
|
|
31
32
|
/**
|
|
32
33
|
* Get / fetch / set specs.
|
|
33
34
|
*/
|
|
34
|
-
|
|
35
35
|
class DefinitionsManager {
|
|
36
36
|
constructor(apiServerClient) {
|
|
37
37
|
_defineProperty(this, "apiServerClient", void 0);
|
|
@@ -282,6 +282,22 @@ class DefinitionsManager {
|
|
|
282
282
|
});
|
|
283
283
|
return t.sort(['RESOURCE']).toString();
|
|
284
284
|
}
|
|
285
|
+
|
|
286
|
+
findDefsByKind(kind) {
|
|
287
|
+
log('findDefsByKind: ', kind);
|
|
288
|
+
const res = [...this.resources].reduce((a, [_, def]) => {
|
|
289
|
+
if (def.spec.kind === kind) {
|
|
290
|
+
a.push({
|
|
291
|
+
resource: def,
|
|
292
|
+
cli: [...this.cli].find(([_, cliDef]) => cliDef.spec.resourceDefinition === def.name)[1],
|
|
293
|
+
scope: def.spec.scope ? [...this.resources].find(([_, resDef]) => resDef.spec.kind === def.spec.scope.kind)[1] : undefined
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
return a;
|
|
298
|
+
}, []);
|
|
299
|
+
return res.length ? res : null;
|
|
300
|
+
}
|
|
285
301
|
/**
|
|
286
302
|
* Returns set of related definitions if word is known.
|
|
287
303
|
* @param word word to search for
|
|
@@ -307,12 +323,15 @@ class DefinitionsManager {
|
|
|
307
323
|
var _cliDef$spec$names$sh;
|
|
308
324
|
|
|
309
325
|
if (cliDef.spec.names.plural === word || cliDef.spec.names.singular === word || cliDef.spec.names.shortNames.includes(word) || (_cliDef$spec$names$sh = cliDef.spec.names.shortNamesAlias) !== null && _cliDef$spec$names$sh !== void 0 && _cliDef$spec$names$sh.includes(word)) {
|
|
326
|
+
var _this$findDefsByKind;
|
|
327
|
+
|
|
310
328
|
// note: mind non-null assertion
|
|
311
329
|
const resource = this.resources.get(cliDef.spec.resourceDefinition);
|
|
330
|
+
const scope = resource.spec.scope ? (_this$findDefsByKind = this.findDefsByKind(resource.spec.scope.kind)) === null || _this$findDefsByKind === void 0 ? void 0 : _this$findDefsByKind[0].resource : null;
|
|
312
331
|
a.push({
|
|
313
332
|
resource,
|
|
314
333
|
cli: cliDef,
|
|
315
|
-
scope:
|
|
334
|
+
scope: !!scope ? scope : undefined
|
|
316
335
|
});
|
|
317
336
|
}
|
|
318
337
|
|