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