@axway/axway-central-cli 2.4.1 → 2.5.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/README.md CHANGED
@@ -456,8 +456,8 @@ USAGE: axway central create <command> [options]
456
456
  Create one or more resources from a file or stdin
457
457
 
458
458
  CREATE COMMANDS:
459
- environment Create an environment with the specified name
460
- service-account Create a service account
459
+ agent-resource Create an agent resource
460
+ environment Create an environment with the specified name
461
461
 
462
462
  CREATE OPTIONS:
463
463
  --account [value] Override your default account config
@@ -504,8 +504,6 @@ axway central create env newenv
504
504
  axway central create environment newenv -o yaml
505
505
  # create multiple resources from file
506
506
  axway central create -f ./some/folder/resources.yaml
507
- # create a service account(DOSA)
508
- axway central create service-account
509
507
  # create an agent resource
510
508
  axway central create agent-resource
511
509
  ```
@@ -5,57 +5,15 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.serviceAccount = void 0;
7
7
 
8
- var _snooplogg = _interopRequireDefault(require("snooplogg"));
9
-
10
- var _ApiCentralClient = require("../../common/ApiCentralClient");
11
-
12
- var _bashCommands = require("../../common/bashCommands");
13
-
14
- var _Renderer = _interopRequireDefault(require("../../common/Renderer"));
15
-
16
- var _helpers = require("../install/helpers");
17
-
18
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
-
20
- const {
21
- log
22
- } = (0, _snooplogg.default)('central: create: service-account');
23
-
24
- const action = async ({
25
- argv,
26
- console
27
- }) => {
28
- const {
29
- baseUrl,
30
- account,
31
- region
32
- } = argv;
33
- const render = new _Renderer.default(console);
34
- let isCmdError = false;
35
- const apiCentralClient = new _ApiCentralClient.ApiCentralClient({
36
- baseUrl,
37
- account,
38
- region
39
- });
40
-
41
- try {
42
- await (0, _bashCommands.isOpenSslInstalled)();
43
- const dosaName = await (0, _helpers.askServiceAccountName)();
44
- await (0, _helpers.createDosaAndCerts)(apiCentralClient, dosaName);
45
- } catch (e) {
46
- log('command error', e);
47
- render.anyError(e);
48
- isCmdError = true;
49
- } finally {
50
- log('command finished, error = ', isCmdError);
51
- if (isCmdError) process.exit(1);
52
- process.exit(0);
53
- }
8
+ const action = async ({}) => {
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]"');
54
10
  };
55
11
 
56
12
  const serviceAccount = {
57
13
  aliases: ['service account', 'service-account', 'serviceaccount'],
58
14
  action,
59
- desc: 'Create a service account'
15
+ desc: 'Create a service account',
16
+ hidden: true // Hide this command line option since it's no longer supported.
17
+
60
18
  };
61
19
  exports.serviceAccount = serviceAccount;
@@ -106,14 +106,29 @@ ${defsManager.getDefsTableForHelpMsg()}`);
106
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
107
  }); // this should never happen, the filtering logic is probably invalid if true
108
108
 
109
- if (!matchingDefs.length) throw Error(`can't find matching resource definitions.`); // Prompt the confirmation if action will be executed on multiple resources
110
-
111
- if (!yes && matchingDefs.length > 1) {
112
- if ((await (0, _basicPrompts.askList)({
113
- msg: 'The resource may exist in many scopes, and multiple entities might be deleted. Do you want to continue?',
114
- choices: _types.YesNoChoices,
115
- default: _types.YesNo.Yes
116
- })) === _types.YesNo.No) process.exit(1);
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.
111
+
112
+ if (!yes) {
113
+ let result = _types.YesNo.Yes;
114
+
115
+ if (!scope) {
116
+ result = await (0, _basicPrompts.askList)({
117
+ msg: 'Deleting this will delete all resources under its scope. Are you sure you want to do this?',
118
+ choices: _types.YesNoChoices,
119
+ default: _types.YesNo.No
120
+ });
121
+ } else if (matchingDefs.length > 1) {
122
+ result = await (0, _basicPrompts.askList)({
123
+ msg: 'The resource may exist in many scopes, and multiple entities might be deleted. Do you want to continue?',
124
+ choices: _types.YesNoChoices,
125
+ default: _types.YesNo.No
126
+ });
127
+ }
128
+
129
+ if (result === _types.YesNo.No) {
130
+ process.exit(1);
131
+ }
117
132
  }
118
133
 
119
134
  render.startSpin(`Deleting resources${wait ? ' and waiting for them to be deleted' : ''}`);
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.transactionLoggingMessages = exports.selectServiceAccount = exports.selectIngestionProtocol = exports.secretAlreadyExists = exports.namespaceAlreadyExists = exports.k8sClusterMessages = exports.envMessages = exports.enterServiceAccountName = exports.enterPublicKeyPath = exports.enterPrivateKeyPath = exports.enterNamespaceName = exports.createNamespace = exports.createGatewayAgentCredsSecret = exports.createAmplifyAgentKeysSecret = exports.askToEnableTransactionLogging = exports.askServiceAccountName = exports.askPublicKeyPath = exports.askPublicAndPrivateKeysPath = exports.askPrivateKeyPath = exports.askNamespace = exports.askK8sClusterName = exports.askIngestionProtocol = exports.askForSecretName = exports.askEnvironmentName = exports.askDosaClientId = exports.askBundleType = exports.askAgentName = exports.agentMessages = void 0;
6
+ exports.transactionLoggingMessages = exports.serviceAccountNameAlreadyExists = exports.selectServiceAccount = exports.selectIngestionProtocol = exports.secretAlreadyExists = exports.namespaceAlreadyExists = exports.k8sClusterMessages = exports.fetchServiceAccount = exports.envMessages = exports.enterServiceAccountName = exports.enterPublicKeyPath = exports.enterPrivateKeyPath = exports.enterNamespaceName = exports.createNamespace = exports.createGatewayAgentCredsSecret = exports.createAmplifyAgentKeysSecret = exports.askToEnableTransactionLogging = exports.askServiceAccountName = exports.askPublicKeyPath = exports.askPublicAndPrivateKeysPath = exports.askPrivateKeyPath = exports.askNamespace = exports.askK8sClusterName = exports.askIngestionProtocol = exports.askForSecretName = exports.askEnvironmentName = exports.askDosaClientId = exports.askBundleType = exports.askAgentName = exports.agentMessages = void 0;
7
7
 
8
8
  var _chalk = _interopRequireDefault(require("chalk"));
9
9
 
@@ -71,39 +71,50 @@ const enterPrivateKeyPath = 'Enter the file path to the private key';
71
71
  exports.enterPrivateKeyPath = enterPrivateKeyPath;
72
72
  const selectIngestionProtocol = 'Select Traceability protocol';
73
73
  exports.selectIngestionProtocol = selectIngestionProtocol;
74
+ const serviceAccountNameAlreadyExists = 'Service account already exists. Please enter a new name.';
75
+ exports.serviceAccountNameAlreadyExists = serviceAccountNameAlreadyExists;
74
76
 
75
- const askServiceAccountName = async () => {
76
- console.warn(_chalk.default.yellow(`WARNING: Creating a new DOSA account will overwrite any existing "private_key.pem" and "public_key.pem" files in this directory`));
77
+ const askServiceAccountName = async serviceAccounts => {
78
+ console.warn(_chalk.default.yellow(`WARNING: Creating a new DOSA account will overwrite any existing "private_key.pem" and "public_key.pem" files in this directory`)); // map to get sa names
79
+
80
+ const serviceAccountNames = serviceAccounts.map(a => a.name);
77
81
  const name = await (0, _basicPrompts.askInput)({
78
82
  msg: enterServiceAccountName,
79
83
  defaultValue: cliNowString,
80
- validate: (0, _basicPrompts.validateRegex)(_regex.dosaRegex, _regex.invalidDosaName)
84
+ validate: (0, _basicPrompts.runValidations)((0, _basicPrompts.validateInputIsNew)(serviceAccountNames, serviceAccountNameAlreadyExists), (0, _basicPrompts.validateRegex)(_regex.dosaRegex, _regex.invalidDosaName))
81
85
  });
82
86
  return name;
83
87
  };
84
88
 
85
89
  exports.askServiceAccountName = askServiceAccountName;
86
90
 
87
- const askDosaClientId = async (client, showWarning = true) => {
91
+ const fetchServiceAccount = async client => {
88
92
  const res = await client.getServiceAccounts();
89
93
  if (!res.data) throw Error('Get service accounts error.');
94
+ return res.data;
95
+ };
96
+
97
+ exports.fetchServiceAccount = fetchServiceAccount;
98
+
99
+ const askDosaClientId = async (client, showWarning = true) => {
100
+ const serviceAccounts = await fetchServiceAccount(client);
90
101
  const answer = await (0, _basicPrompts.askList)({
91
102
  msg: selectServiceAccount,
92
103
  choices: [{
93
104
  name: 'Create a new account',
94
105
  value: 'CREATE_NEW'
95
- }, new _inquirer.default.Separator(), ...res.data.map(a => a.name), new _inquirer.default.Separator()]
106
+ }, new _inquirer.default.Separator(), ...serviceAccounts.map(a => a.name), new _inquirer.default.Separator()]
96
107
  });
97
108
 
98
109
  if (answer === 'CREATE_NEW') {
99
- const name = await askServiceAccountName();
110
+ const name = await askServiceAccountName(serviceAccounts);
100
111
  return {
101
112
  clientId: null,
102
113
  name,
103
114
  isNew: true
104
115
  };
105
116
  } else {
106
- const dosa = res.data.find(a => a.name === answer);
117
+ const dosa = serviceAccounts.find(a => a.name === answer);
107
118
 
108
119
  if (showWarning) {
109
120
  console.log(_chalk.default.yellow('Please make sure your "private_key.pem" and "public_key.pem" files for the selected service account are copied to the folder location of the agents.'));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axway/axway-central-cli",
3
- "version": "2.4.1",
3
+ "version": "2.5.0",
4
4
  "description": "Manage APIs, services and publish to the Unified Catalog",
5
5
  "homepage": "https://platform.axway.com",
6
6
  "author": {