clever-tools 4.4.0 → 4.4.1
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 +0 -3
- package/package.json +1 -1
- package/src/clever-client/auth-bridge.js +0 -9
- package/src/clever-client/drains.js +0 -17
- package/src/clever-client/operators.js +1 -1
- package/src/commands/k8s.js +1 -1
- package/src/commands/otoroshi.js +0 -1
- package/src/lib/k8s.js +1 -1
- package/src/models/addon.js +0 -16
- package/src/models/app_configuration.js +0 -30
- package/src/models/log-v4.js +10 -4
- package/src/parsers.js +0 -19
package/bin/clever.js
CHANGED
|
@@ -206,9 +206,6 @@ async function run() {
|
|
|
206
206
|
aliases: ['w'],
|
|
207
207
|
description: 'Watch the deployment until the cluster is deployed',
|
|
208
208
|
}),
|
|
209
|
-
kubeConfigForceDownload: cliparse.flag('force', {
|
|
210
|
-
description: 'Force the download of the kubeconfig file, even if it already exists',
|
|
211
|
-
}),
|
|
212
209
|
targetVersion: cliparse.option('target', {
|
|
213
210
|
metavar: 'version',
|
|
214
211
|
description: 'Target version to upgrade to (e.g.: 24, 2.4, 2.4.1)',
|
package/package.json
CHANGED
|
@@ -15,15 +15,6 @@ export function listApiTokens() {
|
|
|
15
15
|
});
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
export function updateApiToken(apiTokenId, { name, description }) {
|
|
19
|
-
return Promise.resolve({
|
|
20
|
-
method: 'put',
|
|
21
|
-
url: `/api-tokens/${apiTokenId}`,
|
|
22
|
-
headers: { Accept: 'application/json', 'Content-Type': 'application/json' },
|
|
23
|
-
body: { name, description },
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
|
|
27
18
|
export function deleteApiToken(apiTokenId) {
|
|
28
19
|
return Promise.resolve({
|
|
29
20
|
method: 'delete',
|
|
@@ -108,20 +108,3 @@ export function enableDrain(params) {
|
|
|
108
108
|
// no body
|
|
109
109
|
});
|
|
110
110
|
}
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* PATCH /v4/drains/organisations/{ownerId}/applications/{applicationId}/drains/{drainId}/reset-cursor
|
|
114
|
-
* @param {Object} params
|
|
115
|
-
* @param {String} params.ownerId
|
|
116
|
-
* @param {String} params.applicationId
|
|
117
|
-
* @param {String} params.drainId
|
|
118
|
-
*/
|
|
119
|
-
export function resetDrainCursor(params) {
|
|
120
|
-
// no multipath for /self or /organisations/{id}
|
|
121
|
-
return Promise.resolve({
|
|
122
|
-
method: 'patch',
|
|
123
|
-
url: `/v4/drains/organisations/${params.ownerId}/applications/${params.applicationId}/drains/${params.drainId}/reset-cursor`,
|
|
124
|
-
headers: { Accept: 'application/json' },
|
|
125
|
-
// no body
|
|
126
|
-
});
|
|
127
|
-
}
|
|
@@ -130,7 +130,7 @@ export function getOtoroshiConfig(params) {
|
|
|
130
130
|
return Promise.resolve({
|
|
131
131
|
method: 'get',
|
|
132
132
|
url: `/v4/addon-providers/addon-otoroshi/addons/${params.realId}/config.yaml`,
|
|
133
|
-
|
|
133
|
+
headers: { Accept: 'application/yaml' },
|
|
134
134
|
// no queryParams
|
|
135
135
|
// no body
|
|
136
136
|
});
|
package/src/commands/k8s.js
CHANGED
|
@@ -73,7 +73,7 @@ export async function del(params) {
|
|
|
73
73
|
const [clusterIdOrName] = params.args;
|
|
74
74
|
const { org: orgIdOrName, yes: confirmDeletion } = params.options;
|
|
75
75
|
|
|
76
|
-
let proceedDeletion
|
|
76
|
+
let proceedDeletion;
|
|
77
77
|
if (confirmDeletion) {
|
|
78
78
|
proceedDeletion = true;
|
|
79
79
|
} else {
|
package/src/commands/otoroshi.js
CHANGED
package/src/lib/k8s.js
CHANGED
|
@@ -42,7 +42,7 @@ export async function k8sCreate(name, ownerId) {
|
|
|
42
42
|
* @param {string} format The output format
|
|
43
43
|
* @returns {Promise<void>}
|
|
44
44
|
*/
|
|
45
|
-
export async function k8sList(orgIdOrName
|
|
45
|
+
export async function k8sList(orgIdOrName) {
|
|
46
46
|
const ownerId = await getOwnerIdFromOrgIdOrName(orgIdOrName);
|
|
47
47
|
const deployed = await listK8sClusters({ ownerId }).then(sendToApi);
|
|
48
48
|
|
package/src/models/addon.js
CHANGED
|
@@ -228,22 +228,6 @@ export function completePlan() {
|
|
|
228
228
|
return cliparse.autocomplete.words(['dev', 's', 'm', 'l', 'xl', 'xxl']);
|
|
229
229
|
}
|
|
230
230
|
|
|
231
|
-
export async function findById(addonId) {
|
|
232
|
-
const { user, organisations } = await getSummary({}).then(sendToApi);
|
|
233
|
-
for (const orga of [user, ...organisations]) {
|
|
234
|
-
for (const simpleAddon of orga.addons) {
|
|
235
|
-
if (simpleAddon.id === addonId) {
|
|
236
|
-
const addon = await getAddon({ id: orga.id, addonId }).then(sendToApi);
|
|
237
|
-
return {
|
|
238
|
-
...addon,
|
|
239
|
-
orgaId: orga.id,
|
|
240
|
-
};
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
throw new Error(`Could not find add-on with ID: ${addonId}`);
|
|
245
|
-
}
|
|
246
|
-
|
|
247
231
|
export async function findByName(addonName) {
|
|
248
232
|
const { user, organisations } = await getSummary({}).then(sendToApi);
|
|
249
233
|
for (const orga of [user, ...organisations]) {
|
|
@@ -131,27 +131,6 @@ function findDefaultApp(config) {
|
|
|
131
131
|
);
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
-
async function getAppDetailsForId(appId) {
|
|
135
|
-
const config = await loadApplicationConf();
|
|
136
|
-
|
|
137
|
-
if (_.isEmpty(config.apps)) {
|
|
138
|
-
throw new Error('There is no linked or targeted application. Use `--app` option or `clever link` command.');
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
const [appById, secondAppById] = _.filter(config.apps, { app_id: appId });
|
|
142
|
-
if (appById == null) {
|
|
143
|
-
throw new Error(`There are no applications matching id '${appId}'`);
|
|
144
|
-
}
|
|
145
|
-
if (secondAppById != null) {
|
|
146
|
-
throw new Error(
|
|
147
|
-
`There are several applications matching id '${appId}'.` +
|
|
148
|
-
'This should not happen, your `.clever.json` should be fixed.',
|
|
149
|
-
);
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
return appById;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
134
|
export async function getAppDetails({ alias }) {
|
|
156
135
|
const config = await loadApplicationConf();
|
|
157
136
|
const app = findApp(config, alias);
|
|
@@ -165,15 +144,6 @@ export async function getAppDetails({ alias }) {
|
|
|
165
144
|
};
|
|
166
145
|
}
|
|
167
146
|
|
|
168
|
-
export async function getMostNaturalName(appId) {
|
|
169
|
-
try {
|
|
170
|
-
const details = await getAppDetailsForId(appId);
|
|
171
|
-
return details.alias || details.name || appId;
|
|
172
|
-
} catch {
|
|
173
|
-
return appId;
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
|
|
177
147
|
function persistConfig(modifiedConfig) {
|
|
178
148
|
const jsonContents = JSON.stringify(modifiedConfig, null, 2);
|
|
179
149
|
return fs.writeFile(conf.APP_CONFIGURATION_FILE, jsonContents);
|
package/src/models/log-v4.js
CHANGED
|
@@ -134,11 +134,17 @@ export async function watchDeploymentAndDisplayLogs(options) {
|
|
|
134
134
|
}
|
|
135
135
|
|
|
136
136
|
if (deploymentEnded.state === 'OK') {
|
|
137
|
-
const favouriteDomain = await getBest(appId, ownerId);
|
|
138
137
|
Logger.println('');
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
);
|
|
138
|
+
|
|
139
|
+
// There can be applications without any domain, so we don't fail if we can't get one
|
|
140
|
+
const favouriteDomain = await getBest(appId, ownerId).catch(() => null);
|
|
141
|
+
|
|
142
|
+
if (favouriteDomain) {
|
|
143
|
+
Logger.println(
|
|
144
|
+
`${styleText(['bold', 'green'], '✓ Access your application:')} ${styleText(['underline', 'bold'], `https://${favouriteDomain.fqdn}`)}`,
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
|
|
142
148
|
Logger.println(
|
|
143
149
|
`${styleText(['bold', 'blue'], '→ Manage your application:')} ${styleText(['underline', 'bold'], `${conf.GOTO_URL}/${appId}`)}`,
|
|
144
150
|
);
|
package/src/parsers.js
CHANGED
|
@@ -154,25 +154,6 @@ export function tags(string) {
|
|
|
154
154
|
return cliparse.parsers.success(tags);
|
|
155
155
|
}
|
|
156
156
|
|
|
157
|
-
export const ipAddressRegex =
|
|
158
|
-
/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])$/;
|
|
159
|
-
|
|
160
|
-
export function ipAddress(string) {
|
|
161
|
-
if (string.match(ipAddressRegex)) {
|
|
162
|
-
return cliparse.parsers.success(string);
|
|
163
|
-
}
|
|
164
|
-
return cliparse.parsers.error(`Invalid IP address '${string}'. Should match ${ipAddressRegex}`);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
export const portNumberRegex = /^\d{1,5}$/;
|
|
168
|
-
|
|
169
|
-
export function portNumber(number) {
|
|
170
|
-
if (String(number).match(portNumberRegex)) {
|
|
171
|
-
return cliparse.parsers.success(number);
|
|
172
|
-
}
|
|
173
|
-
return cliparse.parsers.error(`Invalid port number '${number}'. Should match ${portNumberRegex}`);
|
|
174
|
-
}
|
|
175
|
-
|
|
176
157
|
/**
|
|
177
158
|
* Parse a duration into seconds
|
|
178
159
|
* A Zero seconds duration is allowed
|