@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.
Files changed (58) hide show
  1. package/dist/cli.js +28 -6
  2. package/dist/commands/apply/index.js +24 -9
  3. package/dist/commands/completion/index.js +9 -3
  4. package/dist/commands/config/common/index.js +11 -2
  5. package/dist/commands/config/index.js +7 -2
  6. package/dist/commands/config/list.js +6 -2
  7. package/dist/commands/config/set.js +31 -4
  8. package/dist/commands/config/unset.js +12 -2
  9. package/dist/commands/create/agentResource.js +32 -12
  10. package/dist/commands/create/environment.js +16 -6
  11. package/dist/commands/create/index.js +26 -9
  12. package/dist/commands/create/serviceAccount.js +6 -2
  13. package/dist/commands/delete/index.js +33 -15
  14. package/dist/commands/edit/environment.js +21 -6
  15. package/dist/commands/edit/index.js +8 -4
  16. package/dist/commands/get/index.js +44 -27
  17. package/dist/commands/install/agents.js +73 -44
  18. package/dist/commands/install/apigeexSaasAgents.js +98 -35
  19. package/dist/commands/install/awsAgents.js +139 -89
  20. package/dist/commands/install/awsSaasAgents.js +142 -50
  21. package/dist/commands/install/azureAgents.js +79 -39
  22. package/dist/commands/install/edgeAgents.js +110 -17
  23. package/dist/commands/install/helpers/creators.js +70 -17
  24. package/dist/commands/install/helpers/deleters.js +11 -2
  25. package/dist/commands/install/helpers/getters.js +30 -4
  26. package/dist/commands/install/helpers/index.js +48 -13
  27. package/dist/commands/install/helpers/inputs.js +98 -26
  28. package/dist/commands/install/helpers/regex.js +34 -29
  29. package/dist/commands/install/helpers/templates/awsTemplates.js +23 -6
  30. package/dist/commands/install/helpers/templates/azureTemplates.js +24 -5
  31. package/dist/commands/install/helpers/templates/edgeTemplates.js +38 -7
  32. package/dist/commands/install/helpers/templates/istioTemplates.js +16 -5
  33. package/dist/commands/install/index.js +10 -4
  34. package/dist/commands/install/istioAgents.js +117 -40
  35. package/dist/commands/install/platform.js +52 -20
  36. package/dist/commands/proxies/create.js +18 -2
  37. package/dist/commands/proxies/index.js +8 -4
  38. package/dist/commands/proxies/promote.js +21 -2
  39. package/dist/common/ApiServerClient.js +173 -64
  40. package/dist/common/CacheController.js +32 -11
  41. package/dist/common/CliConfigManager.js +27 -14
  42. package/dist/common/CompositeError.js +30 -6
  43. package/dist/common/CoreConfigController.js +40 -18
  44. package/dist/common/DefinitionsManager.js +76 -29
  45. package/dist/common/Kubectl.js +25 -2
  46. package/dist/common/PlatformClient.js +63 -19
  47. package/dist/common/Renderer.js +87 -25
  48. package/dist/common/TmpFile.js +28 -11
  49. package/dist/common/bashCommands.js +22 -3
  50. package/dist/common/basicPrompts.js +43 -8
  51. package/dist/common/dataService.js +50 -22
  52. package/dist/common/errorHandler.js +9 -0
  53. package/dist/common/resultsRenderers.js +42 -10
  54. package/dist/common/types.js +341 -116
  55. package/dist/common/utils.js +99 -37
  56. package/dist/main.js +2 -0
  57. package/package.json +2 -2
  58. package/dist/commands/install/gitHubSaasAgents.js +0 -283
@@ -4,21 +4,35 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.create = void 0;
7
+
7
8
  var _snooplogg = _interopRequireDefault(require("snooplogg"));
9
+
8
10
  var _ApiServerClient = require("../../common/ApiServerClient");
11
+
9
12
  var _DefinitionsManager = require("../../common/DefinitionsManager");
13
+
10
14
  var _Renderer = _interopRequireDefault(require("../../common/Renderer"));
15
+
11
16
  var _types = require("../../common/types");
17
+
12
18
  var _utils = require("../../common/utils");
19
+
13
20
  var _environment = require("./environment");
21
+
14
22
  var _serviceAccount = require("./serviceAccount");
23
+
15
24
  var _agentResource = require("./agentResource");
25
+
16
26
  var _basicPrompts = require("../../common/basicPrompts");
27
+
17
28
  var _chalk = _interopRequireDefault(require("chalk"));
29
+
18
30
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
31
+
19
32
  const {
20
33
  log
21
34
  } = (0, _snooplogg.default)('central: create');
35
+
22
36
  const action = async ({
23
37
  argv,
24
38
  console
@@ -32,10 +46,9 @@ const action = async ({
32
46
  cache,
33
47
  yes
34
48
  } = argv;
35
- let commandIsSuccessful = false;
36
-
37
- // need to verify args here since if "-f" is required
49
+ let commandIsSuccessful = false; // need to verify args here since if "-f" is required
38
50
  // cli-kit is also enforcing it on sub-commands
51
+
39
52
  log(`verifying args`);
40
53
  if (!file) throw new Error('To create resources from a file, please provide -f, --file [path] option');
41
54
  log(`verifying file: ${file}`);
@@ -54,6 +67,7 @@ const action = async ({
54
67
  });
55
68
  const defsManager = new _DefinitionsManager.DefinitionsManager(client);
56
69
  log(`executing api calls`);
70
+
57
71
  try {
58
72
  await defsManager.init();
59
73
  log(`loading and verifying specs`);
@@ -61,6 +75,7 @@ const action = async ({
61
75
  docs,
62
76
  isMissingName
63
77
  } = await (0, _utils.loadAndVerifySpecs)(file, defsManager.getAllKindsList());
78
+
64
79
  if (!yes && isMissingName) {
65
80
  render.stopSpin();
66
81
  if ((await (0, _basicPrompts.askList)({
@@ -70,13 +85,14 @@ const action = async ({
70
85
  })) === _types.YesNo.No) process.exit(1);
71
86
  render.startSpin('Creating resource(s)');
72
87
  }
88
+
73
89
  const sortedKindsMap = defsManager.getSortedKindsMap();
74
90
  results = await client.bulkCreate(docs, sortedKindsMap);
75
91
  render.bulkResult(results, 'has successfully been created.');
76
92
  commandIsSuccessful = !results.error.length;
77
93
  } catch (e) {
78
- log('command error', e);
79
- // if some calls have been completed, rendering the result
94
+ log('command error', e); // if some calls have been completed, rendering the result
95
+
80
96
  if (results.success.length || results.error.length) render.bulkResult(results, 'has successfully been created.');
81
97
  render.anyError(e);
82
98
  } finally {
@@ -85,7 +101,8 @@ const action = async ({
85
101
  !commandIsSuccessful && process.exit(1);
86
102
  }
87
103
  };
88
- const create = exports.create = {
104
+
105
+ const create = {
89
106
  action,
90
107
  commands: {
91
108
  'service-account': _serviceAccount.serviceAccount,
@@ -93,8 +110,7 @@ const create = exports.create = {
93
110
  'agent-resource': _agentResource.agentResource
94
111
  },
95
112
  desc: 'Create one or more resources from a file or stdin',
96
- options: {
97
- ..._types.commonCmdArgsDescription,
113
+ options: { ..._types.commonCmdArgsDescription,
98
114
  '-o, --output [value]': {
99
115
  desc: `Additional output formats. One of: ${_types.OutputTypes.yaml} | ${_types.OutputTypes.json}`,
100
116
  type: 'string'
@@ -106,4 +122,5 @@ const create = exports.create = {
106
122
  },
107
123
  '-y, --yes': 'Automatically reply "yes" to any command prompts.'
108
124
  }
109
- };
125
+ };
126
+ exports.create = create;
@@ -4,12 +4,16 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.serviceAccount = void 0;
7
+
7
8
  const action = async ({}) => {
8
9
  throw new Error('Creating a service account via "central" is no longer supported. ' + 'Use the "axway" CLI instead. ' + 'Example: "axway service-account create [options]"');
9
10
  };
10
- const serviceAccount = exports.serviceAccount = {
11
+
12
+ const serviceAccount = {
11
13
  aliases: ['service account', 'service-account', 'serviceaccount'],
12
14
  action,
13
15
  desc: 'Create a service account',
14
16
  hidden: true // Hide this command line option since it's no longer supported.
15
- };
17
+
18
+ };
19
+ exports.serviceAccount = serviceAccount;
@@ -4,18 +4,29 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.deleteCmd = void 0;
7
+
7
8
  var _chalk = _interopRequireDefault(require("chalk"));
9
+
8
10
  var _snooplogg = _interopRequireDefault(require("snooplogg"));
11
+
9
12
  var _ApiServerClient = require("../../common/ApiServerClient");
13
+
10
14
  var _basicPrompts = require("../../common/basicPrompts");
15
+
11
16
  var _DefinitionsManager = require("../../common/DefinitionsManager");
17
+
12
18
  var _Renderer = _interopRequireDefault(require("../../common/Renderer"));
19
+
13
20
  var _types = require("../../common/types");
21
+
14
22
  var _utils = require("../../common/utils");
23
+
15
24
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25
+
16
26
  const {
17
27
  log
18
28
  } = (0, _snooplogg.default)('central: delete');
29
+
19
30
  const action = async ({
20
31
  argv,
21
32
  console
@@ -31,6 +42,7 @@ const action = async ({
31
42
  yes
32
43
  } = argv;
33
44
  let isCmdError = true; // let's be pessimistic.
45
+
34
46
  const typedResource = args[0];
35
47
  const typedName = args[1];
36
48
  let bulkResults = {
@@ -45,6 +57,7 @@ const action = async ({
45
57
  useCache: cache
46
58
  });
47
59
  const defsManager = new _DefinitionsManager.DefinitionsManager(client);
60
+
48
61
  if (file && args.length) {
49
62
  render.error('Error: Invalid command arguments, please provide a file path or resource type and name.');
50
63
  console.log(`\nUSAGE:
@@ -52,10 +65,12 @@ To delete resources by filenames:\t"axway central delete -f/--file <path>
52
65
  To delete a single resource:\t\t"axway central delete <Resource> <Name>"`);
53
66
  process.exit(1);
54
67
  }
68
+
55
69
  try {
56
70
  log(`load and verify specs`);
57
71
  await defsManager.init();
58
72
  const scope = (0, _utils.parseScopeParam)(argv.scope);
73
+
59
74
  if (!file && !args.length) {
60
75
  // user typed just "axway central delete"
61
76
  render.error('Error: You must specify the type and name of the resource to delete or a file path.');
@@ -75,6 +90,7 @@ The server supports the following resources:
75
90
  ${defsManager.getDefsTableForHelpMsg()}`);
76
91
  process.exit(1);
77
92
  }
93
+
78
94
  if (args.length) {
79
95
  // SINGLE RESOURCE MODE
80
96
  log(`executing api calls in single delete mode`);
@@ -82,21 +98,20 @@ ${defsManager.getDefsTableForHelpMsg()}`);
82
98
  if (!defs) throw Error(`the server doesn't have a resource type "${typedResource}"`);
83
99
  if (!typedName) throw Error('resource name is required.');
84
100
  if (defs.every(defs => !!defs.scope) && !scope) throw Error(`scope name param (-s/--scope) is required for the scoped "${defs[0].resource.spec.kind}" resource.`);
85
- (0, _utils.verifyScopeParam)(defsManager.getAllKindsList(), defs, scope);
101
+ (0, _utils.verifyScopeParam)(defsManager.getAllKindsList(), defs, scope); // find needed defs by specified resource type + scope name + scope kind (if provided)
86
102
 
87
- // find needed defs by specified resource type + scope name + scope kind (if provided)
88
103
  const matchingDefs = defs.filter(defs => {
89
104
  var _defs$scope;
90
- return scope && (scope.kind && scope.kind === ((_defs$scope = defs.scope) === null || _defs$scope === void 0 ? void 0 : _defs$scope.spec.kind) || !scope.kind && !!defs.scope) || !scope && !defs.scope;
91
- });
92
105
 
93
- // this should never happen, the filtering logic is probably invalid if true
94
- if (!matchingDefs.length) throw Error(`can't find matching resource definitions.`);
106
+ return scope && (scope.kind && scope.kind === ((_defs$scope = defs.scope) === null || _defs$scope === void 0 ? void 0 : _defs$scope.spec.kind) || !scope.kind && !!defs.scope) || !scope && !defs.scope;
107
+ }); // this should never happen, the filtering logic is probably invalid if true
95
108
 
96
- // Ask user if it's okay to delete unless the "--yes" option is set.
109
+ if (!matchingDefs.length) throw Error(`can't find matching resource definitions.`); // Ask user if it's okay to delete unless the "--yes" option is set.
97
110
  // Note: Only prompt if it ends up deleting multiple associated resources.
111
+
98
112
  if (!yes) {
99
113
  let result = _types.YesNo.Yes;
114
+
100
115
  if (!scope) {
101
116
  result = await (0, _basicPrompts.askList)({
102
117
  msg: 'Deleting this will delete all resources under its scope. Are you sure you want to do this?',
@@ -110,10 +125,12 @@ ${defsManager.getDefsTableForHelpMsg()}`);
110
125
  default: _types.YesNo.No
111
126
  });
112
127
  }
128
+
113
129
  if (result === _types.YesNo.No) {
114
130
  process.exit(1);
115
131
  }
116
132
  }
133
+
117
134
  render.startSpin(`Deleting resources${wait ? ' and waiting for them to be deleted' : ''}`);
118
135
  const results = await Promise.all(matchingDefs.map(async defs => client.deleteResourceByName({
119
136
  resourceDef: defs.resource,
@@ -121,12 +138,12 @@ ${defsManager.getDefsTableForHelpMsg()}`);
121
138
  scopeDef: defs.scope,
122
139
  scopeName: scope === null || scope === void 0 ? void 0 : scope.name,
123
140
  wait
124
- })));
141
+ }))); // considering the command successful if at least 1 response found
125
142
 
126
- // considering the command successful if at least 1 response found
127
143
  isCmdError = !results.filter(res => res.data !== null).length;
128
144
  results.forEach(res => {
129
145
  var _res$error, _res$error2;
146
+
130
147
  // rendering errors only if the command is unsuccessful
131
148
  if (isCmdError && (_res$error = res.error) !== null && _res$error !== void 0 && _res$error.length) render.anyError(res.error[0]);else if (!((_res$error2 = res.error) !== null && _res$error2 !== void 0 && _res$error2.length)) render.success(`${render.resourceAndScopeKinds(res.data)} has successfully been deleted.`); // mind the non-null assertion
132
149
  });
@@ -144,8 +161,8 @@ ${defsManager.getDefsTableForHelpMsg()}`);
144
161
  isCmdError = !!bulkResults.error.length;
145
162
  }
146
163
  } catch (e) {
147
- log('command error', e);
148
- // if some calls finished, rendering the result
164
+ log('command error', e); // if some calls finished, rendering the result
165
+
149
166
  if (bulkResults.success.length || bulkResults.error.length) render.bulkResult(bulkResults, 'has successfully been deleted.');
150
167
  render.anyError(e);
151
168
  } finally {
@@ -154,7 +171,8 @@ ${defsManager.getDefsTableForHelpMsg()}`);
154
171
  isCmdError && process.exit(1);
155
172
  }
156
173
  };
157
- const deleteCmd = exports.deleteCmd = {
174
+
175
+ const deleteCmd = {
158
176
  action,
159
177
  desc: 'Delete resources',
160
178
  args: [{
@@ -164,8 +182,7 @@ const deleteCmd = exports.deleteCmd = {
164
182
  required: false,
165
183
  type: 'string'
166
184
  }],
167
- options: {
168
- ..._types.commonCmdArgsDescription,
185
+ options: { ..._types.commonCmdArgsDescription,
169
186
  '-f, --file [path]': {
170
187
  desc: `Filename to use to delete the resource.`,
171
188
  type: 'string'
@@ -177,4 +194,5 @@ const deleteCmd = exports.deleteCmd = {
177
194
  '-y, --yes': 'Automatically reply "yes" to any command prompts.',
178
195
  '--wait': 'Wait for the resources to be completely deleted.'
179
196
  }
180
- };
197
+ };
198
+ exports.deleteCmd = deleteCmd;
@@ -4,18 +4,29 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.environment = void 0;
7
+
7
8
  var _cliKit = require("cli-kit");
9
+
8
10
  var _snooplogg = _interopRequireDefault(require("snooplogg"));
11
+
9
12
  var _dataService = require("../../common/dataService");
13
+
10
14
  var _Renderer = _interopRequireDefault(require("../../common/Renderer"));
15
+
11
16
  var _resultsRenderers = require("../../common/resultsRenderers");
17
+
12
18
  var _TmpFile = _interopRequireDefault(require("../../common/TmpFile"));
19
+
13
20
  var _types = require("../../common/types");
21
+
14
22
  var _utils = require("../../common/utils");
23
+
15
24
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25
+
16
26
  const {
17
27
  log
18
28
  } = (0, _snooplogg.default)('central:edit:environment');
29
+
19
30
  const action = async ({
20
31
  argv,
21
32
  console
@@ -31,6 +42,7 @@ const action = async ({
31
42
  let file;
32
43
  let commandIsSuccessful = true;
33
44
  const render = new _Renderer.default(console, output).startSpin(`Fetching details of "environment/${name}".`);
45
+
34
46
  try {
35
47
  const service = await (0, _dataService.dataService)({
36
48
  baseUrl,
@@ -38,20 +50,21 @@ const action = async ({
38
50
  region
39
51
  });
40
52
  let response = await service.get(`/management/v1alpha1/environments/${name}`);
41
- file = new _TmpFile.default(response);
42
- // stop spinner or it will interfere stdio of editor
53
+ file = new _TmpFile.default(response); // stop spinner or it will interfere stdio of editor
54
+
43
55
  render.stopSpin();
44
56
  const {
45
57
  isUpdated
46
58
  } = await file.edit();
59
+
47
60
  if (isUpdated) {
48
61
  // intentionally taking just first doc even if user will provide more in the same file while editing.
49
62
  const {
50
63
  docs
51
64
  } = await (0, _utils.loadAndVerifySpecs)(file.path, new Set([_types.Kind.Environment]));
52
65
  response = await service.put(`/management/v1alpha1/environments/${name}`, docs[0]);
53
- render.success((0, _cliKit.chalk)`{greenBright "environment/${name}" has successfully been edited.}`);
54
- // render result if output flag has been provided
66
+ render.success((0, _cliKit.chalk)`{greenBright "environment/${name}" has successfully been edited.}`); // render result if output flag has been provided
67
+
55
68
  output && (0, _resultsRenderers.renderResponse)(console, response, output);
56
69
  } else {
57
70
  log('no changes has been made to file');
@@ -71,7 +84,8 @@ const action = async ({
71
84
  !commandIsSuccessful && process.exit(1);
72
85
  }
73
86
  };
74
- const environment = exports.environment = {
87
+
88
+ const environment = {
75
89
  aliases: ['env'],
76
90
  action,
77
91
  desc: 'Edit an environment with the specified name.',
@@ -80,4 +94,5 @@ const environment = exports.environment = {
80
94
  desc: 'Name of the environment',
81
95
  required: true
82
96
  }]
83
- };
97
+ };
98
+ exports.environment = environment;
@@ -4,10 +4,14 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.edit = void 0;
7
+
7
8
  var _cliKit = require("cli-kit");
9
+
8
10
  var _environment = require("./environment");
11
+
9
12
  var _types = require("../../common/types");
10
- const edit = exports.edit = {
13
+
14
+ const edit = {
11
15
  action: ({
12
16
  console
13
17
  }) => {
@@ -18,11 +22,11 @@ const edit = exports.edit = {
18
22
  environment: _environment.environment
19
23
  },
20
24
  desc: 'Edit and update resources by using the default editor',
21
- options: {
22
- ..._types.commonCmdArgsDescription,
25
+ options: { ..._types.commonCmdArgsDescription,
23
26
  '-o, --output [value]': {
24
27
  desc: `Additional output formats. One of: ${_types.OutputTypes.yaml}|${_types.OutputTypes.json}`,
25
28
  type: 'string'
26
29
  }
27
30
  }
28
- };
31
+ };
32
+ exports.edit = edit;
@@ -4,18 +4,29 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.get = void 0;
7
+
7
8
  var _snooplogg = _interopRequireDefault(require("snooplogg"));
9
+
8
10
  var _chalk = _interopRequireDefault(require("chalk"));
11
+
9
12
  var _ApiServerClient = require("../../common/ApiServerClient");
13
+
10
14
  var _DefinitionsManager = require("../../common/DefinitionsManager");
15
+
11
16
  var _Renderer = _interopRequireDefault(require("../../common/Renderer"));
17
+
12
18
  var _resultsRenderers = require("../../common/resultsRenderers");
19
+
13
20
  var _types = require("../../common/types");
21
+
14
22
  var _utils = require("../../common/utils");
23
+
15
24
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25
+
16
26
  const {
17
27
  log
18
28
  } = (0, _snooplogg.default)('central: get');
29
+
19
30
  const getListOrByName = async (resourceDef, client, scopeName, resourceName, scopeDef, query, progressListener) => {
20
31
  return resourceName ? await client.getResourceByName({
21
32
  resourceDef,
@@ -30,7 +41,8 @@ const getListOrByName = async (resourceDef, client, scopeName, resourceName, sco
30
41
  progressListener
31
42
  });
32
43
  };
33
- const get = exports.get = {
44
+
45
+ const get = {
34
46
  action: async function ({
35
47
  argv,
36
48
  console
@@ -40,6 +52,7 @@ const get = exports.get = {
40
52
  // to get teams that do not have an owner
41
53
  argv.team = null;
42
54
  }
55
+
43
56
  const {
44
57
  args,
45
58
  attribute,
@@ -50,15 +63,16 @@ const get = exports.get = {
50
63
  tag,
51
64
  team,
52
65
  title
53
- } = argv;
54
- // will be set to true and exit 1 if any get result contains an error or args invalid
55
- let isCmdError = true;
56
- // name can be provided or not (args[0] is the resource type)
57
- const resourceName = args[1];
58
- // verify output argument
66
+ } = argv; // will be set to true and exit 1 if any get result contains an error or args invalid
67
+
68
+ let isCmdError = true; // name can be provided or not (args[0] is the resource type)
69
+
70
+ const resourceName = args[1]; // verify output argument
71
+
59
72
  if (!!argv.output && !(argv.output in _types.OutputTypes)) throw Error(`invalid "output" (-o,--output) value provided, allowed: ${_types.OutputTypes.yaml} | ${_types.OutputTypes.json}`);
60
73
  const renderer = new _Renderer.default(console, argv.output);
61
74
  const getResults = [];
75
+
62
76
  try {
63
77
  // get specs and allowed words
64
78
  const client = new _ApiServerClient.ApiServerClient({
@@ -72,10 +86,12 @@ const get = exports.get = {
72
86
  const scope = (0, _utils.parseScopeParam)(argv.scope);
73
87
  const formattedFilter = (0, _utils.transformSimpleFilters)(title, attribute, tag);
74
88
  const query = argv.query ? argv.query : formattedFilter;
89
+
75
90
  if (argv.query && formattedFilter) {
76
91
  console.log(`${_chalk.default.yellow('Both simple queries and advanced query parameters have been provided. Only the advanced query parameter will be applied.')}`);
77
- }
78
- // verify passed args
92
+ } // verify passed args
93
+
94
+
79
95
  if (!args.length) {
80
96
  renderer.error('Error: You must specify the type of resource to get.');
81
97
  console.log(`\nUSAGE:
@@ -97,25 +113,25 @@ The server supports the following resources:
97
113
 
98
114
  ${defsManager.getDefsTableForHelpMsg()}`);
99
115
  process.exit(1);
100
- }
116
+ } // Start showing download progress.
117
+
101
118
 
102
- // Start showing download progress.
103
119
  const downloadMessage = 'Retrieving resource(s)';
104
120
  renderer.startSpin(downloadMessage);
121
+
105
122
  const progressListener = percent => {
106
123
  renderer.updateSpinText(`${downloadMessage} - ${percent}%`);
107
- };
124
+ }; // parse passed resources types (if passed comma-separated)
125
+
108
126
 
109
- // parse passed resources types (if passed comma-separated)
110
127
  for (const typedResource of args[0].split(',')) {
111
- const defs = defsManager.findDefsByWord(typedResource);
112
- // is typed resource known?
113
- if (!defs) throw Error(`the server doesn't have a resource type "${typedResource}"`);
114
- // check if a user is trying to get a scoped-only resource by name without providing a scope name
115
- if (defs.every(defs => !!defs.scope) && resourceName && !scope) throw Error(`scope name param (-s/--scope) is required for the scoped "${defs[0].resource.spec.kind}" resource.`);
116
- // verify passed scope param kind
117
- (0, _utils.verifyScopeParam)(defsManager.getAllKindsList(), defs, scope);
128
+ const defs = defsManager.findDefsByWord(typedResource); // is typed resource known?
118
129
 
130
+ if (!defs) throw Error(`the server doesn't have a resource type "${typedResource}"`); // check if a user is trying to get a scoped-only resource by name without providing a scope name
131
+
132
+ if (defs.every(defs => !!defs.scope) && resourceName && !scope) throw Error(`scope name param (-s/--scope) is required for the scoped "${defs[0].resource.spec.kind}" resource.`); // verify passed scope param kind
133
+
134
+ (0, _utils.verifyScopeParam)(defsManager.getAllKindsList(), defs, scope);
119
135
  /**
120
136
  1) If "scope" param provided: execute getByName or getList calls for every definition that match this scope name/kind.
121
137
  2) If "scope" param is not provided: execute list (get all) api calls for scoped resources without providing the scope in
@@ -125,6 +141,7 @@ ${defsManager.getDefsTableForHelpMsg()}`);
125
141
  Note: this logic might have some edge cases if same kind can be used for "scoped" and "scope" resources and api-server is
126
142
  not handling this case correctly anymore.
127
143
  */
144
+
128
145
  if (scope) {
129
146
  const results = await Promise.all(defs.filter(defs => !scope.kind || !defs.scope || defs.scope.spec.kind === scope.kind).map(async defs => ({
130
147
  response: await getListOrByName(defs.resource, client, scope.name, resourceName, defs.scope, query, progressListener),
@@ -160,14 +177,14 @@ ${defsManager.getDefsTableForHelpMsg()}`);
160
177
  });
161
178
  });
162
179
  }
163
- }
180
+ } // resolve team guids
181
+
164
182
 
165
- // resolve team guids
166
183
  for (const obj of getResults) {
167
184
  await (0, _resultsRenderers.resolveTeamNames)(obj);
168
- }
185
+ } // considering the command successful if at least 1 response found
186
+
169
187
 
170
- // considering the command successful if at least 1 response found
171
188
  isCmdError = !getResults.filter(res => res.response.data !== null).length;
172
189
  renderer.renderGetResults(getResults, 'Resource(s) successfully retrieved');
173
190
  } catch (e) {
@@ -187,8 +204,7 @@ ${defsManager.getDefsTableForHelpMsg()}`);
187
204
  multiple: true,
188
205
  required: false
189
206
  }],
190
- options: {
191
- ..._types.commonCmdArgsDescription,
207
+ options: { ..._types.commonCmdArgsDescription,
192
208
  '-o, --output [value]': {
193
209
  desc: `Additional output formats. One of: ${_types.OutputTypes.yaml} | ${_types.OutputTypes.json}`
194
210
  },
@@ -210,4 +226,5 @@ ${defsManager.getDefsTableForHelpMsg()}`);
210
226
  '--team [guid|name]': 'The team name or guid to use',
211
227
  '--no-owner': 'Returns resources which do not have an owner'
212
228
  }
213
- };
229
+ };
230
+ exports.get = get;