clever-tools 3.11.0 → 3.13.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/bin/clever.js +416 -3
- package/package.json +4 -3
- package/src/clever-client/auth-bridge.js +61 -0
- package/src/clever-client/ng.js +18 -0
- package/src/clever-client/operators.js +121 -0
- package/src/commands/addon.js +34 -28
- package/src/commands/cancel-deploy.js +3 -4
- package/src/commands/config.js +16 -20
- package/src/commands/console.js +4 -10
- package/src/commands/create.js +76 -9
- package/src/commands/curl.js +17 -17
- package/src/commands/database.js +9 -9
- package/src/commands/delete.js +11 -10
- package/src/commands/deploy.js +35 -21
- package/src/commands/domain.js +13 -16
- package/src/commands/emails.js +174 -0
- package/src/commands/env.js +15 -8
- package/src/commands/keycloak.js +138 -0
- package/src/commands/kv.js +1 -1
- package/src/commands/link.js +7 -3
- package/src/commands/makeDefault.js +2 -1
- package/src/commands/matomo.js +85 -0
- package/src/commands/metabase.js +112 -0
- package/src/commands/ng.js +202 -0
- package/src/commands/open.js +2 -5
- package/src/commands/otoroshi.js +138 -0
- package/src/commands/profile.js +11 -10
- package/src/commands/published-config.js +7 -7
- package/src/commands/restart.js +1 -1
- package/src/commands/ssh-keys.js +159 -0
- package/src/commands/stop.js +3 -3
- package/src/commands/tcp-redirs.js +8 -8
- package/src/commands/tokens.js +146 -0
- package/src/commands/unlink.js +2 -1
- package/src/experimental-features.js +47 -2
- package/src/lib/ng-print.js +195 -0
- package/src/lib/operator-commands.js +281 -0
- package/src/lib/prompts.js +30 -0
- package/src/lib/slugify.js +10 -0
- package/src/logger.js +3 -0
- package/src/models/activity.js +2 -3
- package/src/models/addon.js +9 -6
- package/src/models/app_configuration.js +12 -9
- package/src/models/application.js +44 -22
- package/src/models/application_configuration.js +72 -72
- package/src/models/configuration.js +1 -0
- package/src/models/git.js +29 -1
- package/src/models/ids-resolver.js +37 -1
- package/src/models/interact.js +0 -24
- package/src/models/log-v4.js +13 -4
- package/src/models/namespaces.js +3 -2
- package/src/models/ng-resources.js +270 -0
- package/src/models/ng.js +276 -0
- package/src/models/operator.js +48 -0
- package/src/models/send-to-api.js +18 -0
- package/src/models/utils.js +21 -0
- package/src/parsers.js +71 -3
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import {
|
|
2
|
+
operatorCheckVersion,
|
|
3
|
+
operatorList,
|
|
4
|
+
operatorOpen,
|
|
5
|
+
operatorOpenLogs,
|
|
6
|
+
operatorOpenWebUi,
|
|
7
|
+
operatorPrint,
|
|
8
|
+
operatorReboot,
|
|
9
|
+
operatorRebuild,
|
|
10
|
+
operatorUpdateVersion,
|
|
11
|
+
} from '../lib/operator-commands.js';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Check the version of a Metabase operator
|
|
15
|
+
* @param {object} params The command's parameters
|
|
16
|
+
* @param {string} params.args[0] The operator's name or ID
|
|
17
|
+
* @param {string} params.options.format The output format
|
|
18
|
+
* @returns {Promise<void>}
|
|
19
|
+
*/
|
|
20
|
+
export async function checkVersion (params) {
|
|
21
|
+
const [addonIdOrName] = params.args;
|
|
22
|
+
const { format } = params.options;
|
|
23
|
+
await operatorCheckVersion('metabase', addonIdOrName, format);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Update the version of a Metabase operator
|
|
28
|
+
* @param {object} params The command's parameters
|
|
29
|
+
* @param {string} params.args[0] The operator's name or ID
|
|
30
|
+
* @returns {Promise<void>}
|
|
31
|
+
*/
|
|
32
|
+
export async function updateVersion (params) {
|
|
33
|
+
const [addonIdOrName] = params.args;
|
|
34
|
+
const { target } = params.options;
|
|
35
|
+
await operatorUpdateVersion('metabase', target, addonIdOrName);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Get the details of a Metabase operator
|
|
40
|
+
* @param {object} params The command's parameters
|
|
41
|
+
* @param {string} params.args[0] The operator's name or ID
|
|
42
|
+
* @param {string} params.options.format The output format
|
|
43
|
+
* @returns {Promise<void>}
|
|
44
|
+
*/
|
|
45
|
+
export async function get (params) {
|
|
46
|
+
const [addonIdOrName] = params.args;
|
|
47
|
+
const { format } = params.options;
|
|
48
|
+
await operatorPrint('metabase', addonIdOrName, format);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* List all Metabase operators
|
|
53
|
+
* @returns {Promise<void>}
|
|
54
|
+
*/
|
|
55
|
+
export async function list (params) {
|
|
56
|
+
await operatorList('metabase', params.options.format);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Open a Metabase operator dashboard in the Clever Cloud Console
|
|
61
|
+
* @param {object} params The command's parameters
|
|
62
|
+
* @param {string} params.args[0] The operator's name or ID
|
|
63
|
+
* @returns {Promise<void>}
|
|
64
|
+
*/
|
|
65
|
+
export async function open (params) {
|
|
66
|
+
const [addonIdOrName] = params.args;
|
|
67
|
+
await operatorOpen('metabase', addonIdOrName);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Open the Logs section of a Metabase Operator application in the Clever Cloud Console
|
|
72
|
+
* @param {object} params The command's parameters
|
|
73
|
+
* @param {string} params.args[0] The operator's name or ID
|
|
74
|
+
* @returns {Promise<void>}
|
|
75
|
+
*/
|
|
76
|
+
export async function openLogs (params) {
|
|
77
|
+
const [addonIdOrName] = params.args;
|
|
78
|
+
await operatorOpenLogs('metabase', addonIdOrName);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Open the Web UI of a Metabase Operator application in the Clever Cloud Console
|
|
83
|
+
* @param {object} params The command's parameters
|
|
84
|
+
* @param {string} params.args[0] The operator's name or ID
|
|
85
|
+
* @returns {Promise<void>}
|
|
86
|
+
*/
|
|
87
|
+
export async function openWebUi (params) {
|
|
88
|
+
const [addonIdOrName] = params.args;
|
|
89
|
+
await operatorOpenWebUi('metabase', addonIdOrName);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Reboot a Metabase operator
|
|
94
|
+
* @param {object} params The command's parameters
|
|
95
|
+
* @param {string} params.args[0] The operator's name or ID
|
|
96
|
+
* @returns {Promise<void>}
|
|
97
|
+
*/
|
|
98
|
+
export async function reboot (params) {
|
|
99
|
+
const [addonIdOrName] = params.args;
|
|
100
|
+
await operatorReboot('metabase', addonIdOrName);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Rebuild a Metabase operator
|
|
105
|
+
* @param {object} params The command's parameters
|
|
106
|
+
* @param {string} params.args[0] The operator's name or ID
|
|
107
|
+
* @returns {Promise<void>}
|
|
108
|
+
*/
|
|
109
|
+
export async function rebuild (params) {
|
|
110
|
+
const [addonIdOrName] = params.args;
|
|
111
|
+
await operatorRebuild('metabase', addonIdOrName);
|
|
112
|
+
}
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import colors from 'colors/safe.js';
|
|
2
|
+
import * as networkGroup from '../models/ng.js';
|
|
3
|
+
import * as networkGroupResources from '../models/ng-resources.js';
|
|
4
|
+
|
|
5
|
+
import { Logger } from '../logger.js';
|
|
6
|
+
import { printResults } from '../lib/ng-print.js';
|
|
7
|
+
|
|
8
|
+
/** Create a Network Group
|
|
9
|
+
* @param {Object} params
|
|
10
|
+
* @param {Array<Object>} params.args
|
|
11
|
+
* @param {Object} params.args[0] Network Group label
|
|
12
|
+
* @param {string} params.options.description Network Group description
|
|
13
|
+
* @param {Array<string>} params.options.link Array of member IDs or labels to link to the Network Group
|
|
14
|
+
* @param {Object} params.options.org Organisation ID or name
|
|
15
|
+
* @param {string} params.options.tags Comma-separated list of tags
|
|
16
|
+
*/
|
|
17
|
+
export async function createNg (params) {
|
|
18
|
+
const [ngLabel] = params.args;
|
|
19
|
+
const label = ngLabel.ngResourceLabel;
|
|
20
|
+
const { description, link: membersIds, org, tags } = params.options;
|
|
21
|
+
|
|
22
|
+
await networkGroup.create(label, description, tags, membersIds, org);
|
|
23
|
+
|
|
24
|
+
const successMessage = `Network Group ${colors.green(label)} successfully created`;
|
|
25
|
+
if (membersIds == null) {
|
|
26
|
+
Logger.printSuccess(`${successMessage}!`);
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
Logger.printSuccess(`${successMessage} with member(s):`);
|
|
30
|
+
Logger.println(membersIds.map((id) => colors.grey(` - ${id}`)).join('\n'));
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Delete a Network Group
|
|
35
|
+
* @param {Object} params
|
|
36
|
+
* @param {Object} params.args[0] Network Group ID or label
|
|
37
|
+
* @param {Object} params.options.org Organisation ID or name
|
|
38
|
+
*/
|
|
39
|
+
export async function deleteNg (params) {
|
|
40
|
+
const [ngIdOrLabel] = params.args;
|
|
41
|
+
const { org } = params.options;
|
|
42
|
+
|
|
43
|
+
await networkGroup.destroy(ngIdOrLabel, org);
|
|
44
|
+
const ngText = ngIdOrLabel.ngResourceLabel ?? ngIdOrLabel.ngId;
|
|
45
|
+
Logger.printSuccess(`Network Group ${colors.green(ngText)} successfully deleted!`);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** Create an external peer in a Network Group
|
|
49
|
+
* @param {Object} params
|
|
50
|
+
* @param {Object} params.args[0] External peer ID or label
|
|
51
|
+
* @param {Object} params.args[1] Network Group ID or label
|
|
52
|
+
* @param {string} params.args[2] Wireguard public key
|
|
53
|
+
* @param {Object} params.options.org Organisation ID or name
|
|
54
|
+
*/
|
|
55
|
+
export async function createExternalPeer (params) {
|
|
56
|
+
const [peerIdOrLabel, ngIdOrLabel, publicKey] = params.args;
|
|
57
|
+
const { org } = params.options;
|
|
58
|
+
|
|
59
|
+
await networkGroupResources.createExternalPeerWithParent(ngIdOrLabel, peerIdOrLabel.ngResourceLabel, publicKey, org);
|
|
60
|
+
const ngText = ngIdOrLabel.ngResourceLabel ?? ngIdOrLabel.ngId;
|
|
61
|
+
Logger.printSuccess(`External peer ${colors.green(peerIdOrLabel.ngResourceLabel)} successfully created in Network Group ${colors.green(ngText)}`);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Delete an external peer from a Network Group
|
|
65
|
+
* @param {Object} params
|
|
66
|
+
* @param {Object} params.args[0] External peer ID or label
|
|
67
|
+
* @param {Object} params.args[1] Network Group ID or label
|
|
68
|
+
* @param {Object} params.options.org Organisation ID or name
|
|
69
|
+
*/
|
|
70
|
+
export async function deleteExternalPeer (params) {
|
|
71
|
+
const [peerIdOrLabel, ngIdOrLabel] = params.args;
|
|
72
|
+
const { org } = params.options;
|
|
73
|
+
|
|
74
|
+
const peerText = peerIdOrLabel.ngResourceLabel ?? peerIdOrLabel.memberId;
|
|
75
|
+
const ngText = ngIdOrLabel.ngResourceLabel ?? ngIdOrLabel.ngId;
|
|
76
|
+
await networkGroupResources.deleteExternalPeerWithParent(ngIdOrLabel, peerText, org);
|
|
77
|
+
Logger.printSuccess(`External peer ${colors.green(peerText)} successfully deleted from Network Group ${colors.green(ngText)}`);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** Link a member to a Network Group
|
|
81
|
+
* @param {Object} params
|
|
82
|
+
* @param {string} params.args[0] Member ID
|
|
83
|
+
* @param {Object} params.args[1] Network Group ID or label
|
|
84
|
+
* @param {Object} params.options.org Organisation ID or name
|
|
85
|
+
*/
|
|
86
|
+
export async function linkToNg (params) {
|
|
87
|
+
const [resourceId, ngIdOrLabel] = params.args;
|
|
88
|
+
const { org } = params.options;
|
|
89
|
+
|
|
90
|
+
await networkGroupResources.linkMember(ngIdOrLabel, resourceId.memberId, org);
|
|
91
|
+
const ngText = ngIdOrLabel.ngResourceLabel ?? ngIdOrLabel.ngId;
|
|
92
|
+
Logger.printSuccess(`Member ${colors.green(resourceId.memberId)} successfully linked to Network Group ${colors.green(ngText)}`);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** Unlink a member from a Network Group
|
|
96
|
+
* @param {Object} params
|
|
97
|
+
* @param {string} params.args[0] Member ID
|
|
98
|
+
* @param {Object} params.args[1] Network Group ID or label
|
|
99
|
+
* @param {Object} params.options.org Organisation ID or name
|
|
100
|
+
*/
|
|
101
|
+
export async function unlinkFromNg (params) {
|
|
102
|
+
const [resourceId, ngIdOrLabel] = params.args;
|
|
103
|
+
const { org } = params.options;
|
|
104
|
+
|
|
105
|
+
await networkGroupResources.unlinkMember(ngIdOrLabel, resourceId.memberId, org);
|
|
106
|
+
const ngText = ngIdOrLabel.ngResourceLabel ?? ngIdOrLabel.ngId;
|
|
107
|
+
Logger.printSuccess(`Member ${colors.green(resourceId.memberId)} successfully unlinked from Network Group ${colors.green(ngText)}`);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** Print the configuration of a Network Group's peer
|
|
111
|
+
* @param {Object} params
|
|
112
|
+
* @param {Object} params.args[0] Peer ID or label
|
|
113
|
+
* @param {Object} params.args[1] Network Group ID or label
|
|
114
|
+
* @param {Object} params.options.org Organisation ID or name
|
|
115
|
+
* @param {string} params.options.format Output format
|
|
116
|
+
*/
|
|
117
|
+
export async function getPeerConfig (params) {
|
|
118
|
+
const [peerIdOrLabel, ngIdOrLabel] = params.args;
|
|
119
|
+
const { org, format } = params.options;
|
|
120
|
+
|
|
121
|
+
const config = await networkGroup.getPeerConfig(peerIdOrLabel, ngIdOrLabel, org);
|
|
122
|
+
|
|
123
|
+
switch (format) {
|
|
124
|
+
case 'json': {
|
|
125
|
+
Logger.printJson(config);
|
|
126
|
+
break;
|
|
127
|
+
}
|
|
128
|
+
case 'human':
|
|
129
|
+
default: {
|
|
130
|
+
const decodedConfiguration = Buffer.from(config.configuration, 'base64').toString('utf8');
|
|
131
|
+
Logger.println(decodedConfiguration);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/** List Network Groups, their members and peers
|
|
137
|
+
* @param {Object} params
|
|
138
|
+
* @param {Object} params.options.orgaIdOrName Organisation ID or name
|
|
139
|
+
* @param {string} params.options.format Output format
|
|
140
|
+
*/
|
|
141
|
+
export async function listNg (params) {
|
|
142
|
+
const { org, format } = params.options;
|
|
143
|
+
|
|
144
|
+
const ngs = await networkGroup.getAllNGs(org);
|
|
145
|
+
|
|
146
|
+
switch (format) {
|
|
147
|
+
case 'json': {
|
|
148
|
+
Logger.printJson(ngs);
|
|
149
|
+
break;
|
|
150
|
+
}
|
|
151
|
+
case 'human':
|
|
152
|
+
default: {
|
|
153
|
+
if (!ngs.length) {
|
|
154
|
+
Logger.println(`ℹ️ No Network Group found, create one with ${colors.blue('clever ng create')} command`);
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
const ngList = ngs.map(({
|
|
158
|
+
id,
|
|
159
|
+
label,
|
|
160
|
+
networkIp,
|
|
161
|
+
members,
|
|
162
|
+
peers,
|
|
163
|
+
}) => ({
|
|
164
|
+
ID: id,
|
|
165
|
+
Label: label,
|
|
166
|
+
'Network CIDR': networkIp,
|
|
167
|
+
Members: Object.keys(members).length,
|
|
168
|
+
Peers: Object.keys(peers).length,
|
|
169
|
+
}));
|
|
170
|
+
|
|
171
|
+
console.table(ngList);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/** Show information about a Network Group, a member or a peer
|
|
177
|
+
* @param {Object} params
|
|
178
|
+
* @param {Object} params.args[0] ID or label of the Network Group, a member or a peer
|
|
179
|
+
* @param {Object} params.options.org Organisation ID or name
|
|
180
|
+
* @param {string} params.options.format Output format
|
|
181
|
+
*/
|
|
182
|
+
export async function get (params) {
|
|
183
|
+
const [idOrLabel] = params.args;
|
|
184
|
+
const { org, format } = params.options;
|
|
185
|
+
const type = params.options.type ?? 'single';
|
|
186
|
+
|
|
187
|
+
await printResults(idOrLabel, org, format, 'get', type);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/** Show information about a Network Group, a member or a peer
|
|
191
|
+
* @param {Object} params
|
|
192
|
+
* @param {Object} params.args[0] ID or label of the Network Group, a member or a peer
|
|
193
|
+
* @param {Object} params.options.org Organisation ID or name
|
|
194
|
+
* @param {string} params.options.format Output format
|
|
195
|
+
*/
|
|
196
|
+
export async function search (params) {
|
|
197
|
+
const [idOrLabel] = params.args;
|
|
198
|
+
const { org, format } = params.options;
|
|
199
|
+
const type = params.options.type;
|
|
200
|
+
|
|
201
|
+
await printResults(idOrLabel, org, format, 'search', type);
|
|
202
|
+
}
|
package/src/commands/open.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import openPage from 'open';
|
|
2
|
-
|
|
3
1
|
import * as Application from '../models/application.js';
|
|
4
2
|
import * as Domain from '../models/domain.js';
|
|
5
|
-
import {
|
|
3
|
+
import { openBrowser } from '../models/utils.js';
|
|
6
4
|
|
|
7
5
|
export async function open (params) {
|
|
8
6
|
const { alias, app: appIdOrName } = params.options;
|
|
@@ -11,6 +9,5 @@ export async function open (params) {
|
|
|
11
9
|
const vhost = await Domain.getBest(appId, ownerId);
|
|
12
10
|
const url = 'https://' + vhost.fqdn;
|
|
13
11
|
|
|
14
|
-
|
|
15
|
-
await openPage(url, { wait: false });
|
|
12
|
+
await openBrowser(url, 'Opening the application in your browser');
|
|
16
13
|
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import {
|
|
2
|
+
operatorCheckVersion,
|
|
3
|
+
operatorList,
|
|
4
|
+
operatorNgDisable,
|
|
5
|
+
operatorNgEnable,
|
|
6
|
+
operatorOpen,
|
|
7
|
+
operatorOpenLogs,
|
|
8
|
+
operatorOpenWebUi,
|
|
9
|
+
operatorPrint,
|
|
10
|
+
operatorReboot,
|
|
11
|
+
operatorRebuild,
|
|
12
|
+
operatorUpdateVersion,
|
|
13
|
+
} from '../lib/operator-commands.js';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Check the version of an Otoroshi operator
|
|
17
|
+
* @param {object} params The command's parameters
|
|
18
|
+
* @param {string} params.args[0] The operator's name or ID
|
|
19
|
+
* @param {string} params.options.format The output format
|
|
20
|
+
* @returns {Promise<void>}
|
|
21
|
+
*/
|
|
22
|
+
export async function checkVersion (params) {
|
|
23
|
+
const [addonIdOrName] = params.args;
|
|
24
|
+
const { format } = params.options;
|
|
25
|
+
await operatorCheckVersion('otoroshi', addonIdOrName, format);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Update the version of an Otoroshi operator
|
|
30
|
+
* @param {object} params The command's parameters
|
|
31
|
+
* @param {string} params.args[0] The operator's name or ID
|
|
32
|
+
* @returns {Promise<void>}
|
|
33
|
+
*/
|
|
34
|
+
export async function updateVersion (params) {
|
|
35
|
+
const [addonIdOrName] = params.args;
|
|
36
|
+
const { target } = params.options;
|
|
37
|
+
await operatorUpdateVersion('otoroshi', target, addonIdOrName);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Get the details of an Otoroshi operator
|
|
42
|
+
* @param {object} params The command's parameters
|
|
43
|
+
* @param {string} params.args[0] The operator's name or ID
|
|
44
|
+
* @param {string} params.options.format The output format
|
|
45
|
+
* @returns {Promise<void>}
|
|
46
|
+
*/
|
|
47
|
+
export async function get (params) {
|
|
48
|
+
const [addonIdOrName] = params.args;
|
|
49
|
+
const { format } = params.options;
|
|
50
|
+
await operatorPrint('otoroshi', addonIdOrName, format);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* List all Otoroshi operators
|
|
55
|
+
* @returns {Promise<void>}
|
|
56
|
+
*/
|
|
57
|
+
export async function list (params) {
|
|
58
|
+
await operatorList('otoroshi', params.options.format);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Unlink a Operator from a Network Group
|
|
63
|
+
* @param {object} params The command's parameters
|
|
64
|
+
* @param {string} params.args[0] The operator's name or ID
|
|
65
|
+
* @returns {Promise<void>}
|
|
66
|
+
* @throws {Error} If the Network Group feature is already disabled
|
|
67
|
+
*/
|
|
68
|
+
export async function ngDisable (params) {
|
|
69
|
+
const [addonIdOrName] = params.args;
|
|
70
|
+
await operatorNgDisable('otoroshi', addonIdOrName);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Link a Operator to a Network Group
|
|
75
|
+
* @param {object} params The command's parameters
|
|
76
|
+
* @param {string} params.args[0] The operator's name or ID
|
|
77
|
+
* @returns {Promise<void>}
|
|
78
|
+
* @throws {Error} If the Network Group feature is already enabled
|
|
79
|
+
*/
|
|
80
|
+
export async function ngEnable (params) {
|
|
81
|
+
const [addonIdOrName] = params.args;
|
|
82
|
+
await operatorNgEnable('otoroshi', addonIdOrName);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Open an Otoroshi operator dashboard in the Clever Cloud Console
|
|
87
|
+
* @param {object} params The command's parameters
|
|
88
|
+
* @param {string} params.args[0] The operator's name or ID
|
|
89
|
+
* @returns {Promise<void>}
|
|
90
|
+
*/
|
|
91
|
+
export async function open (params) {
|
|
92
|
+
const [addonIdOrName] = params.args;
|
|
93
|
+
await operatorOpen('otoroshi', addonIdOrName);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Open the Logs section of an Otoroshi Operator application in the Clever Cloud Console
|
|
98
|
+
* @param {object} params The command's parameters
|
|
99
|
+
* @param {string} params.args[0] The operator's name or ID
|
|
100
|
+
* @returns {Promise<void>}
|
|
101
|
+
*/
|
|
102
|
+
export async function openLogs (params) {
|
|
103
|
+
const [addonIdOrName] = params.args;
|
|
104
|
+
await operatorOpenLogs('otoroshi', addonIdOrName);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Open the Web UI of an Otoroshi Operator application in the Clever Cloud Console
|
|
109
|
+
* @param {object} params The command's parameters
|
|
110
|
+
* @param {string} params.args[0] The operator's name or ID
|
|
111
|
+
* @returns {Promise<void>}
|
|
112
|
+
*/
|
|
113
|
+
export async function openWebUi (params) {
|
|
114
|
+
const [addonIdOrName] = params.args;
|
|
115
|
+
await operatorOpenWebUi('otoroshi', addonIdOrName);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Reboot an Otoroshi operator
|
|
120
|
+
* @param {object} params The command's parameters
|
|
121
|
+
* @param {string} params.args[0] The operator's name or ID
|
|
122
|
+
* @returns {Promise<void>}
|
|
123
|
+
*/
|
|
124
|
+
export async function reboot (params) {
|
|
125
|
+
const [addonIdOrName] = params.args;
|
|
126
|
+
await operatorReboot('otoroshi', addonIdOrName);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Rebuild an Otoroshi operator
|
|
131
|
+
* @param {object} params The command's parameters
|
|
132
|
+
* @param {string} params.args[0] The operator's name or ID
|
|
133
|
+
* @returns {Promise<void>}
|
|
134
|
+
*/
|
|
135
|
+
export async function rebuild (params) {
|
|
136
|
+
const [addonIdOrName] = params.args;
|
|
137
|
+
await operatorRebuild('otoroshi', addonIdOrName);
|
|
138
|
+
}
|
package/src/commands/profile.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import colors from 'colors/safe.js';
|
|
2
|
-
import
|
|
2
|
+
import { openBrowser } from '../models/utils.js';
|
|
3
3
|
import { Logger } from '../logger.js';
|
|
4
4
|
import * as User from '../models/user.js';
|
|
5
|
+
import dedent from 'dedent';
|
|
5
6
|
|
|
6
7
|
export async function profile (params) {
|
|
7
8
|
const { format } = params.options;
|
|
@@ -37,18 +38,18 @@ export async function profile (params) {
|
|
|
37
38
|
}
|
|
38
39
|
case 'human':
|
|
39
40
|
default: {
|
|
40
|
-
Logger.println(
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
41
|
+
Logger.println(dedent`
|
|
42
|
+
You're currently logged in as:
|
|
43
|
+
User id ${formattedUser.id}
|
|
44
|
+
Name ${formattedUser.name ?? colors.red.bold('[not specified]')}
|
|
45
|
+
Email ${formattedUser.email}
|
|
46
|
+
Token expiration ${tokenExpiration}
|
|
47
|
+
Two factor auth ${formattedUser.has2FA ? 'yes' : 'no'}
|
|
48
|
+
`);
|
|
46
49
|
}
|
|
47
50
|
}
|
|
48
51
|
};
|
|
49
52
|
|
|
50
53
|
export async function openProfile () {
|
|
51
|
-
|
|
52
|
-
Logger.debug('Opening the profile page in your browser');
|
|
53
|
-
await openPage(URL, { wait: false });
|
|
54
|
+
await openBrowser('/users/me/information', 'Opening the profile page in your browser');
|
|
54
55
|
}
|
|
@@ -3,13 +3,13 @@ import { Logger } from '../logger.js';
|
|
|
3
3
|
import * as variables from '../models/variables.js';
|
|
4
4
|
import { sendToApi } from '../models/send-to-api.js';
|
|
5
5
|
import { toNameEqualsValueString, validateName } from '@clevercloud/client/esm/utils/env-vars.js';
|
|
6
|
-
import
|
|
6
|
+
import { getAllExposedEnvVars, updateAllExposedEnvVars } from '@clevercloud/client/esm/api/v2/application.js';
|
|
7
7
|
|
|
8
8
|
export async function list (params) {
|
|
9
9
|
const { alias, app: appIdOrName, format } = params.options;
|
|
10
10
|
const { ownerId, appId } = await Application.resolveId(appIdOrName, alias);
|
|
11
11
|
|
|
12
|
-
const publishedConfigs = await
|
|
12
|
+
const publishedConfigs = await getAllExposedEnvVars({ id: ownerId, appId }).then(sendToApi);
|
|
13
13
|
const pairs = Object.entries(publishedConfigs).map(([name, value]) => ({ name, value }));
|
|
14
14
|
|
|
15
15
|
switch (format) {
|
|
@@ -39,9 +39,9 @@ export async function set (params) {
|
|
|
39
39
|
|
|
40
40
|
const { ownerId, appId } = await Application.resolveId(appIdOrName, alias);
|
|
41
41
|
|
|
42
|
-
const publishedConfigs = await
|
|
42
|
+
const publishedConfigs = await getAllExposedEnvVars({ id: ownerId, appId }).then(sendToApi);
|
|
43
43
|
publishedConfigs[varName] = varValue;
|
|
44
|
-
await
|
|
44
|
+
await updateAllExposedEnvVars({ id: ownerId, appId }, publishedConfigs).then(sendToApi);
|
|
45
45
|
|
|
46
46
|
Logger.println('Your published config item has been successfully saved');
|
|
47
47
|
};
|
|
@@ -51,9 +51,9 @@ export async function rm (params) {
|
|
|
51
51
|
const { alias, app: appIdOrName } = params.options;
|
|
52
52
|
const { ownerId, appId } = await Application.resolveId(appIdOrName, alias);
|
|
53
53
|
|
|
54
|
-
const publishedConfigs = await
|
|
54
|
+
const publishedConfigs = await getAllExposedEnvVars({ id: ownerId, appId }).then(sendToApi);
|
|
55
55
|
delete publishedConfigs[varName];
|
|
56
|
-
await
|
|
56
|
+
await updateAllExposedEnvVars({ id: ownerId, appId }, publishedConfigs).then(sendToApi);
|
|
57
57
|
|
|
58
58
|
Logger.println('Your published config item has been successfully removed');
|
|
59
59
|
};
|
|
@@ -64,7 +64,7 @@ export async function importEnv (params) {
|
|
|
64
64
|
const { ownerId, appId } = await Application.resolveId(appIdOrName, alias);
|
|
65
65
|
|
|
66
66
|
const publishedConfigs = await variables.readVariablesFromStdin(format);
|
|
67
|
-
await
|
|
67
|
+
await updateAllExposedEnvVars({ id: ownerId, appId }, publishedConfigs).then(sendToApi);
|
|
68
68
|
|
|
69
69
|
Logger.println('Your published configs have been set');
|
|
70
70
|
};
|
package/src/commands/restart.js
CHANGED
|
@@ -26,7 +26,7 @@ export async function restart (params) {
|
|
|
26
26
|
const commitId = fullCommitId || remoteCommitId;
|
|
27
27
|
if (commitId != null) {
|
|
28
28
|
const cacheSuffix = withoutCache ? ' without using cache' : '';
|
|
29
|
-
Logger.println(
|
|
29
|
+
Logger.println(`🔄 Restarting ${colors.bold(app.name)}${cacheSuffix} ${colors.grey(`(${commitId})`)}`);
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
// This should be handled by the API when a deployment ID is set but we'll do this for now
|