kourou 0.25.2 → 0.26.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/README.md +76 -4
- package/lib/commands/app/debug-proxy.js +2 -0
- package/lib/commands/app/scaffold.d.ts +7 -1
- package/lib/commands/app/scaffold.js +62 -11
- package/lib/commands/app/start-services.js +3 -3
- package/lib/commands/paas/deploy.d.ts +0 -1
- package/lib/commands/paas/deploy.js +0 -22
- package/lib/commands/paas/login.js +3 -2
- package/lib/commands/paas/logs.d.ts +0 -2
- package/lib/commands/paas/logs.js +21 -33
- package/lib/commands/paas/snapshots/cat.d.ts +18 -0
- package/lib/commands/paas/snapshots/cat.js +46 -0
- package/lib/commands/paas/snapshots/dump.d.ts +18 -0
- package/lib/commands/paas/snapshots/dump.js +46 -0
- package/lib/commands/paas/snapshots/restore.d.ts +18 -0
- package/lib/commands/paas/snapshots/restore.js +54 -0
- package/lib/support/PaasKommand.d.ts +1 -0
- package/lib/support/PaasKommand.js +10 -0
- package/lib/support/execute.js +0 -2
- package/lib/support/kuzzle.js +3 -0
- package/lib/support/migrate/providers/elasticsearch.js +1 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
The CLI that helps you manage your Kuzzle instances.
|
|
4
4
|
|
|
5
|
+
|
|
5
6
|
[](https://oclif.io)
|
|
6
7
|
[](https://npmjs.org/package/kourou)
|
|
7
8
|
[](https://npmjs.org/package/kourou)
|
|
@@ -26,7 +27,7 @@ $ npm install -g kourou
|
|
|
26
27
|
$ kourou COMMAND
|
|
27
28
|
running command...
|
|
28
29
|
$ kourou (-v|--version|version)
|
|
29
|
-
kourou/0.
|
|
30
|
+
kourou/0.26.1 darwin-arm64 node-v18.17.1
|
|
30
31
|
$ kourou --help [COMMAND]
|
|
31
32
|
USAGE
|
|
32
33
|
$ kourou COMMAND
|
|
@@ -163,6 +164,9 @@ All other arguments and options will be passed as-is to the `sdk:query` method.
|
|
|
163
164
|
* [`kourou paas:init PROJECT`](#kourou-paasinit-project)
|
|
164
165
|
* [`kourou paas:login`](#kourou-paaslogin)
|
|
165
166
|
* [`kourou paas:logs ENVIRONMENT APPLICATION`](#kourou-paaslogs-environment-application)
|
|
167
|
+
* [`kourou paas:snapshots:cat ENVIRONMENT APPLICATIONID`](#kourou-paassnapshotscat-environment-applicationid)
|
|
168
|
+
* [`kourou paas:snapshots:dump ENVIRONMENT APPLICATIONID`](#kourou-paassnapshotsdump-environment-applicationid)
|
|
169
|
+
* [`kourou paas:snapshots:restore ENVIRONMENT APPLICATIONID SNAPSHOTID`](#kourou-paassnapshotsrestore-environment-applicationid-snapshotid)
|
|
166
170
|
* [`kourou profile:export`](#kourou-profileexport)
|
|
167
171
|
* [`kourou profile:import PATH`](#kourou-profileimport-path)
|
|
168
172
|
* [`kourou realtime:subscribe INDEX COLLECTION [FILTERS]`](#kourou-realtimesubscribe-index-collection-filters)
|
|
@@ -365,9 +369,7 @@ ARGUMENTS
|
|
|
365
369
|
DESTINATION Directory to scaffold the app
|
|
366
370
|
|
|
367
371
|
OPTIONS
|
|
368
|
-
--flavor=flavor [default: generic] Template flavor ("generic", "iot
|
|
369
|
-
Those can be found here: https://github.com/kuzzleio/project-templates
|
|
370
|
-
|
|
372
|
+
--flavor=flavor [default: generic] Template flavor ("generic", "iot").
|
|
371
373
|
--help show CLI help
|
|
372
374
|
```
|
|
373
375
|
|
|
@@ -1121,6 +1123,76 @@ OPTIONS
|
|
|
1121
1123
|
|
|
1122
1124
|
_See code: [src/commands/paas/logs.ts](src/commands/paas/logs.ts)_
|
|
1123
1125
|
|
|
1126
|
+
## `kourou paas:snapshots:cat ENVIRONMENT APPLICATIONID`
|
|
1127
|
+
|
|
1128
|
+
List all snapshots for a given kuzzle application in a environment
|
|
1129
|
+
|
|
1130
|
+
```
|
|
1131
|
+
USAGE
|
|
1132
|
+
$ kourou paas:snapshots:cat ENVIRONMENT APPLICATIONID
|
|
1133
|
+
|
|
1134
|
+
ARGUMENTS
|
|
1135
|
+
ENVIRONMENT Project environment name
|
|
1136
|
+
APPLICATIONID Application Identifier
|
|
1137
|
+
|
|
1138
|
+
OPTIONS
|
|
1139
|
+
--help show CLI help
|
|
1140
|
+
--project=project Current PaaS project
|
|
1141
|
+
--token=token Authentication token
|
|
1142
|
+
|
|
1143
|
+
EXAMPLE
|
|
1144
|
+
kourou paas:snapshots:cat --project paas-project-myproject api main
|
|
1145
|
+
```
|
|
1146
|
+
|
|
1147
|
+
_See code: [src/commands/paas/snapshots/cat.ts](src/commands/paas/snapshots/cat.ts)_
|
|
1148
|
+
|
|
1149
|
+
## `kourou paas:snapshots:dump ENVIRONMENT APPLICATIONID`
|
|
1150
|
+
|
|
1151
|
+
Create a new snapshot of the current application state
|
|
1152
|
+
|
|
1153
|
+
```
|
|
1154
|
+
USAGE
|
|
1155
|
+
$ kourou paas:snapshots:dump ENVIRONMENT APPLICATIONID
|
|
1156
|
+
|
|
1157
|
+
ARGUMENTS
|
|
1158
|
+
ENVIRONMENT Project environment name
|
|
1159
|
+
APPLICATIONID Application Identifier
|
|
1160
|
+
|
|
1161
|
+
OPTIONS
|
|
1162
|
+
--help show CLI help
|
|
1163
|
+
--project=project Current PaaS project
|
|
1164
|
+
--token=token Authentication token
|
|
1165
|
+
|
|
1166
|
+
EXAMPLE
|
|
1167
|
+
kourou paas:snapshots:dump --project paas-project-myproject api main
|
|
1168
|
+
```
|
|
1169
|
+
|
|
1170
|
+
_See code: [src/commands/paas/snapshots/dump.ts](src/commands/paas/snapshots/dump.ts)_
|
|
1171
|
+
|
|
1172
|
+
## `kourou paas:snapshots:restore ENVIRONMENT APPLICATIONID SNAPSHOTID`
|
|
1173
|
+
|
|
1174
|
+
Restore a snapshot of the current application state
|
|
1175
|
+
|
|
1176
|
+
```
|
|
1177
|
+
USAGE
|
|
1178
|
+
$ kourou paas:snapshots:restore ENVIRONMENT APPLICATIONID SNAPSHOTID
|
|
1179
|
+
|
|
1180
|
+
ARGUMENTS
|
|
1181
|
+
ENVIRONMENT Project environment name
|
|
1182
|
+
APPLICATIONID Application Identifier
|
|
1183
|
+
SNAPSHOTID Snapshot Identifier
|
|
1184
|
+
|
|
1185
|
+
OPTIONS
|
|
1186
|
+
--help show CLI help
|
|
1187
|
+
--project=project Current PaaS project
|
|
1188
|
+
--token=token Authentication token
|
|
1189
|
+
|
|
1190
|
+
EXAMPLE
|
|
1191
|
+
kourou paas:snapshots:restore --project paas-project-myproject api main snapshot-id
|
|
1192
|
+
```
|
|
1193
|
+
|
|
1194
|
+
_See code: [src/commands/paas/snapshots/restore.ts](src/commands/paas/snapshots/restore.ts)_
|
|
1195
|
+
|
|
1124
1196
|
## `kourou profile:export`
|
|
1125
1197
|
|
|
1126
1198
|
Exports profiles
|
|
@@ -17,6 +17,8 @@ function sendResponse(response, bodyObject) {
|
|
|
17
17
|
}
|
|
18
18
|
class DebugProxy extends common_1.Kommand {
|
|
19
19
|
async runSafe() {
|
|
20
|
+
// @ts-ignore Disable ping pong since when debugging Kuzzle might not be responding
|
|
21
|
+
clearInterval(this.sdk.sdk.protocol.pingIntervalId);
|
|
20
22
|
const nodeVersionResponse = (await this.sdk.query({
|
|
21
23
|
controller: "debug",
|
|
22
24
|
action: "nodeVersion",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { flags } from "@oclif/command";
|
|
2
2
|
import { Kommand } from "../../common";
|
|
3
3
|
export default class AppScaffold extends Kommand {
|
|
4
|
+
templatesDir: string;
|
|
4
5
|
static initSdk: boolean;
|
|
5
6
|
static description: string;
|
|
6
7
|
static flags: {
|
|
@@ -13,5 +14,10 @@ export default class AppScaffold extends Kommand {
|
|
|
13
14
|
required: boolean;
|
|
14
15
|
}[];
|
|
15
16
|
runSafe(): Promise<void>;
|
|
16
|
-
|
|
17
|
+
getRepo(flavor: string): "template-kuzzle-project" | "template-kiotp-project";
|
|
18
|
+
checkDestination(destination: string): Promise<void>;
|
|
19
|
+
prepareTemplate(): Promise<void>;
|
|
20
|
+
cloneTemplate(flavor: string): Promise<void>;
|
|
21
|
+
copyTemplate(destination: string): Promise<void>;
|
|
22
|
+
cleanup(): Promise<void>;
|
|
17
23
|
}
|
|
@@ -7,25 +7,77 @@ const listr_1 = (0, tslib_1.__importDefault)(require("listr"));
|
|
|
7
7
|
const common_1 = require("../../common");
|
|
8
8
|
const execute_1 = require("../../support/execute");
|
|
9
9
|
class AppScaffold extends common_1.Kommand {
|
|
10
|
+
constructor() {
|
|
11
|
+
super(...arguments);
|
|
12
|
+
this.templatesDir = "/tmp/kuzzle-templates";
|
|
13
|
+
}
|
|
10
14
|
async runSafe() {
|
|
11
15
|
const destination = this.args.destination;
|
|
12
16
|
const flavor = this.flags.flavor;
|
|
13
17
|
const tasks = new listr_1.default([
|
|
14
18
|
{
|
|
15
|
-
title: "
|
|
16
|
-
task: async () => this.
|
|
19
|
+
title: "Checking destination",
|
|
20
|
+
task: async () => this.checkDestination(destination),
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
title: "Prepare temporary folder",
|
|
24
|
+
task: async () => this.prepareTemplate(),
|
|
17
25
|
},
|
|
26
|
+
{
|
|
27
|
+
title: "Cloning template repository",
|
|
28
|
+
task: async () => this.cloneTemplate(flavor)
|
|
29
|
+
}, {
|
|
30
|
+
title: "Copying template files",
|
|
31
|
+
task: async () => this.copyTemplate(destination)
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
title: "Cleaning up",
|
|
35
|
+
task: async () => this.cleanup()
|
|
36
|
+
}
|
|
18
37
|
]);
|
|
19
38
|
await tasks.run();
|
|
20
39
|
this.log("");
|
|
21
|
-
this.logOk(`Scaffolding complete
|
|
40
|
+
this.logOk(`Scaffolding complete!`);
|
|
41
|
+
this.logOk(`Use ${chalk_1.default.blue.bold(`cd ${destination} && docker compose up -d`)} to start your Kuzzle stack.`);
|
|
42
|
+
}
|
|
43
|
+
getRepo(flavor) {
|
|
44
|
+
console.log(flavor);
|
|
45
|
+
switch (flavor) {
|
|
46
|
+
case "generic":
|
|
47
|
+
return "template-kuzzle-project";
|
|
48
|
+
case "iot":
|
|
49
|
+
return "template-kiotp-project";
|
|
50
|
+
default:
|
|
51
|
+
return "template-kuzzle-project";
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
async checkDestination(destination) {
|
|
55
|
+
let process;
|
|
56
|
+
try {
|
|
57
|
+
process = await (0, execute_1.execute)("test", "-d", destination);
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
if (error.result.exitCode === 1) {
|
|
61
|
+
// Destination directory does not exist
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
if (process.exitCode === 0) {
|
|
66
|
+
throw new Error(`Destination directory ${destination} already exists.`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
async prepareTemplate() {
|
|
70
|
+
await (0, execute_1.execute)("rm", "-rf", this.templatesDir);
|
|
71
|
+
}
|
|
72
|
+
async cloneTemplate(flavor) {
|
|
73
|
+
const repo = this.getRepo(flavor);
|
|
74
|
+
await (0, execute_1.execute)("git", "clone", "--depth=1", `https://github.com/kuzzleio/${repo}`, "--branch", "master", "--single-branch", this.templatesDir);
|
|
75
|
+
}
|
|
76
|
+
async copyTemplate(destination) {
|
|
77
|
+
await (0, execute_1.execute)("cp", "-r", `${this.templatesDir}/`, `${destination}/`);
|
|
22
78
|
}
|
|
23
|
-
async
|
|
24
|
-
|
|
25
|
-
await (0, execute_1.execute)("rm", "-rf", templatesDir);
|
|
26
|
-
await (0, execute_1.execute)("git", "clone", "--depth=1", "https://github.com/kuzzleio/project-templates", "--branch", flavor, "--single-branch", templatesDir);
|
|
27
|
-
await (0, execute_1.execute)("cp", "-r", `${templatesDir}/${flavor}`, `${destination}/`);
|
|
28
|
-
await (0, execute_1.execute)("rm", "-rf", templatesDir);
|
|
79
|
+
async cleanup() {
|
|
80
|
+
await (0, execute_1.execute)("rm", "-rf", this.templatesDir);
|
|
29
81
|
}
|
|
30
82
|
}
|
|
31
83
|
exports.default = AppScaffold;
|
|
@@ -35,8 +87,7 @@ AppScaffold.flags = {
|
|
|
35
87
|
help: command_1.flags.help(),
|
|
36
88
|
flavor: command_1.flags.string({
|
|
37
89
|
default: "generic",
|
|
38
|
-
description: `Template flavor ("generic", "iot
|
|
39
|
-
Those can be found here: https://github.com/kuzzleio/project-templates`,
|
|
90
|
+
description: `Template flavor ("generic", "iot").`,
|
|
40
91
|
}),
|
|
41
92
|
};
|
|
42
93
|
AppScaffold.args = [
|
|
@@ -47,9 +47,9 @@ class AppStartServices extends common_1.Kommand {
|
|
|
47
47
|
await (0, execute_1.execute)("docker-compose", "-f", docoFilename, "up", "-d");
|
|
48
48
|
this.logOk("Elasticsearch and Redis are booting in the background right now.");
|
|
49
49
|
this.log(chalk_1.default.grey("\nTo watch the logs, run"));
|
|
50
|
-
this.log(chalk_1.default.
|
|
51
|
-
this.log(
|
|
52
|
-
this.log(
|
|
50
|
+
this.log(chalk_1.default.blue.bold(` docker-compose -f ${docoFilename} logs -f\n`));
|
|
51
|
+
this.log(` Elasticsearch port: ${chalk_1.default.bold("9200")}`);
|
|
52
|
+
this.log(` Redis port: ${chalk_1.default.bold("6379")}`);
|
|
53
53
|
}
|
|
54
54
|
catch (error) {
|
|
55
55
|
this.logKo(` Something went wrong: ${error.message}`);
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
const fs_1 = (0, tslib_1.__importDefault)(require("fs"));
|
|
5
3
|
const command_1 = require("@oclif/command");
|
|
6
|
-
const cli_ux_1 = (0, tslib_1.__importDefault)(require("cli-ux"));
|
|
7
|
-
const login_1 = (0, tslib_1.__importDefault)(require("./login"));
|
|
8
4
|
const PaasKommand_1 = require("../../support/PaasKommand");
|
|
9
5
|
class PaasDeploy extends PaasKommand_1.PaasKommand {
|
|
10
6
|
async runSafe() {
|
|
@@ -29,24 +25,6 @@ class PaasDeploy extends PaasKommand_1.PaasKommand {
|
|
|
29
25
|
});
|
|
30
26
|
this.logOk("Deployment in progress");
|
|
31
27
|
}
|
|
32
|
-
async getCredentials() {
|
|
33
|
-
const project = this.getProject();
|
|
34
|
-
const projectFile = this.fileProjectCredentials(project);
|
|
35
|
-
if (!fs_1.default.existsSync(projectFile)) {
|
|
36
|
-
this.log("");
|
|
37
|
-
const nextStep = await cli_ux_1.default.prompt("Cannot find credentials for this project. Do you want to login first? [Y/N]", { type: "single" });
|
|
38
|
-
this.log("");
|
|
39
|
-
if (nextStep.toLowerCase().startsWith("y")) {
|
|
40
|
-
await login_1.default.run(["--project", project]);
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
this.logKo("Aborting.");
|
|
44
|
-
process.exit(1);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
const credentials = JSON.parse(fs_1.default.readFileSync(projectFile, "utf8"));
|
|
48
|
-
return credentials.apiKey;
|
|
49
|
-
}
|
|
50
28
|
}
|
|
51
29
|
PaasDeploy.description = "Deploy a new version of the application in the PaaS";
|
|
52
30
|
PaasDeploy.flags = {
|
|
@@ -21,9 +21,9 @@ class PaasLogin extends PaasKommand_1.PaasKommand {
|
|
|
21
21
|
return;
|
|
22
22
|
}
|
|
23
23
|
await this.initPaasClient({ username, password });
|
|
24
|
+
await this.authenticateNPM(username, password);
|
|
24
25
|
const apiKey = await this.paas.auth.createApiKey("Kourou PaaS API Key");
|
|
25
26
|
this.createProjectCredentials(apiKey);
|
|
26
|
-
await this.authenticateNPM(username, password);
|
|
27
27
|
this.logOk(`Successfully logged in as ${username}. Your Kuzzle Enterprise license is now enabled on this host.`);
|
|
28
28
|
}
|
|
29
29
|
createProjectCredentials(apiKey) {
|
|
@@ -49,7 +49,8 @@ class PaasLogin extends PaasKommand_1.PaasKommand {
|
|
|
49
49
|
password,
|
|
50
50
|
}),
|
|
51
51
|
};
|
|
52
|
-
const
|
|
52
|
+
const targetUrl = `https://${this.packagesHost}/-/user/org.couchdb.user:${username}`;
|
|
53
|
+
const response = await (0, node_fetch_1.default)(targetUrl, options);
|
|
53
54
|
const json = await response.json();
|
|
54
55
|
if (response.status !== 201) {
|
|
55
56
|
throw new Error(json.error);
|
|
@@ -32,8 +32,6 @@ declare class PaasLogs extends PaasKommand {
|
|
|
32
32
|
*/
|
|
33
33
|
private podsColor;
|
|
34
34
|
runSafe(): Promise<void>;
|
|
35
|
-
getCredentials(): Promise<any>;
|
|
36
|
-
getNumberOfSpaces(names: string[], currentName: string): number;
|
|
37
35
|
/**
|
|
38
36
|
* Returns the color to use for a pod name.
|
|
39
37
|
* @param podName Name of the pod.
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
const fs_1 = (0, tslib_1.__importDefault)(require("fs"));
|
|
5
4
|
const readline = (0, tslib_1.__importStar)(require("readline"));
|
|
6
5
|
const command_1 = require("@oclif/command");
|
|
7
6
|
const chalk_1 = (0, tslib_1.__importDefault)(require("chalk"));
|
|
8
7
|
const chrono = (0, tslib_1.__importStar)(require("chrono-node"));
|
|
9
|
-
const cli_ux_1 = require("cli-ux");
|
|
10
|
-
const login_1 = (0, tslib_1.__importDefault)(require("./login"));
|
|
11
8
|
const PaasKommand_1 = require("../../support/PaasKommand");
|
|
12
9
|
class PaasLogs extends PaasKommand_1.PaasKommand {
|
|
13
10
|
constructor() {
|
|
@@ -61,6 +58,27 @@ class PaasLogs extends PaasKommand_1.PaasKommand {
|
|
|
61
58
|
since,
|
|
62
59
|
until,
|
|
63
60
|
});
|
|
61
|
+
// Don't continue if an error occurred
|
|
62
|
+
if (incomingMessage.statusCode !== 200) {
|
|
63
|
+
return new Promise((_, reject) => {
|
|
64
|
+
// Collect the whole response body
|
|
65
|
+
let responseBody = "";
|
|
66
|
+
incomingMessage.on("data", (buffer) => {
|
|
67
|
+
responseBody += buffer.toString();
|
|
68
|
+
});
|
|
69
|
+
incomingMessage.on("end", () => {
|
|
70
|
+
let response;
|
|
71
|
+
try {
|
|
72
|
+
response = JSON.parse(responseBody);
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
reject(new Error("An error occurred while parsing the error response body from Kuzzle"));
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
reject(response.error);
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
}
|
|
64
82
|
// Read the response line by line
|
|
65
83
|
const lineStream = readline.createInterface({
|
|
66
84
|
input: incomingMessage,
|
|
@@ -99,36 +117,6 @@ class PaasLogs extends PaasKommand_1.PaasKommand {
|
|
|
99
117
|
finally { if (e_1) throw e_1.error; }
|
|
100
118
|
}
|
|
101
119
|
}
|
|
102
|
-
async getCredentials() {
|
|
103
|
-
const project = this.getProject();
|
|
104
|
-
const projectFile = this.fileProjectCredentials(project);
|
|
105
|
-
if (!fs_1.default.existsSync(projectFile)) {
|
|
106
|
-
this.log("");
|
|
107
|
-
const nextStep = await cli_ux_1.cli.prompt("Cannot find credentials for this project. Do you want to login first? [Y/N]", { type: "single" });
|
|
108
|
-
this.log("");
|
|
109
|
-
if (nextStep.toLowerCase().startsWith("y")) {
|
|
110
|
-
await login_1.default.run(["--project", project]);
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
this.logKo("Aborting.");
|
|
114
|
-
process.exit(1);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
const credentials = JSON.parse(fs_1.default.readFileSync(projectFile, "utf8"));
|
|
118
|
-
return credentials.apiKey;
|
|
119
|
-
}
|
|
120
|
-
getNumberOfSpaces(names, currentName) {
|
|
121
|
-
const end = 10;
|
|
122
|
-
let max = { name: "", length: 0 };
|
|
123
|
-
for (const name of names) {
|
|
124
|
-
if (max.length < name.length) {
|
|
125
|
-
max = { name: name, length: name.length };
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
return currentName === max.name
|
|
129
|
-
? end
|
|
130
|
-
: end + (max.length - currentName.length);
|
|
131
|
-
}
|
|
132
120
|
/**
|
|
133
121
|
* Returns the color to use for a pod name.
|
|
134
122
|
* @param podName Name of the pod.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { flags } from "@oclif/command";
|
|
2
|
+
import { PaasKommand } from "../../../support/PaasKommand";
|
|
3
|
+
declare class PaasSnapshotsCat extends PaasKommand {
|
|
4
|
+
static description: string;
|
|
5
|
+
static flags: {
|
|
6
|
+
help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
|
|
7
|
+
token: flags.IOptionFlag<string | undefined>;
|
|
8
|
+
project: flags.IOptionFlag<string | undefined>;
|
|
9
|
+
};
|
|
10
|
+
static args: {
|
|
11
|
+
name: string;
|
|
12
|
+
description: string;
|
|
13
|
+
required: boolean;
|
|
14
|
+
}[];
|
|
15
|
+
static examples: string[];
|
|
16
|
+
runSafe(): Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
export default PaasSnapshotsCat;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const command_1 = require("@oclif/command");
|
|
4
|
+
const PaasKommand_1 = require("../../../support/PaasKommand");
|
|
5
|
+
class PaasSnapshotsCat extends PaasKommand_1.PaasKommand {
|
|
6
|
+
async runSafe() {
|
|
7
|
+
const apiKey = await this.getCredentials();
|
|
8
|
+
await this.initPaasClient({ apiKey });
|
|
9
|
+
const user = await this.paas.auth.getCurrentUser();
|
|
10
|
+
this.logInfo(`Logged as "${user._id}" for project "${this.flags.project || this.getProject()}"`);
|
|
11
|
+
const { result } = await this.paas.query({
|
|
12
|
+
controller: "application",
|
|
13
|
+
action: "snapshots",
|
|
14
|
+
environmentId: this.args.environment,
|
|
15
|
+
projectId: this.flags.project || this.getProject(),
|
|
16
|
+
applicationId: this.args.applicationId,
|
|
17
|
+
body: {},
|
|
18
|
+
});
|
|
19
|
+
this.logInfo(JSON.stringify(result, null, 2));
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
PaasSnapshotsCat.description = "List all snapshots for a given kuzzle application in a environment";
|
|
23
|
+
PaasSnapshotsCat.flags = {
|
|
24
|
+
help: command_1.flags.help(),
|
|
25
|
+
token: command_1.flags.string({
|
|
26
|
+
default: process.env.KUZZLE_PAAS_TOKEN,
|
|
27
|
+
description: "Authentication token",
|
|
28
|
+
}),
|
|
29
|
+
project: command_1.flags.string({
|
|
30
|
+
description: "Current PaaS project",
|
|
31
|
+
}),
|
|
32
|
+
};
|
|
33
|
+
PaasSnapshotsCat.args = [
|
|
34
|
+
{
|
|
35
|
+
name: "environment",
|
|
36
|
+
description: "Project environment name",
|
|
37
|
+
required: true,
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
name: "applicationId",
|
|
41
|
+
description: "Application Identifier",
|
|
42
|
+
required: true,
|
|
43
|
+
}
|
|
44
|
+
];
|
|
45
|
+
PaasSnapshotsCat.examples = ["kourou paas:snapshots:cat --project paas-project-myproject api main"];
|
|
46
|
+
exports.default = PaasSnapshotsCat;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { flags } from "@oclif/command";
|
|
2
|
+
import { PaasKommand } from "../../../support/PaasKommand";
|
|
3
|
+
declare class PaasSnapshotsDump extends PaasKommand {
|
|
4
|
+
static description: string;
|
|
5
|
+
static flags: {
|
|
6
|
+
help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
|
|
7
|
+
token: flags.IOptionFlag<string | undefined>;
|
|
8
|
+
project: flags.IOptionFlag<string | undefined>;
|
|
9
|
+
};
|
|
10
|
+
static args: {
|
|
11
|
+
name: string;
|
|
12
|
+
description: string;
|
|
13
|
+
required: boolean;
|
|
14
|
+
}[];
|
|
15
|
+
static examples: string[];
|
|
16
|
+
runSafe(): Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
export default PaasSnapshotsDump;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const command_1 = require("@oclif/command");
|
|
4
|
+
const PaasKommand_1 = require("../../../support/PaasKommand");
|
|
5
|
+
class PaasSnapshotsDump extends PaasKommand_1.PaasKommand {
|
|
6
|
+
async runSafe() {
|
|
7
|
+
const apiKey = await this.getCredentials();
|
|
8
|
+
await this.initPaasClient({ apiKey });
|
|
9
|
+
const user = await this.paas.auth.getCurrentUser();
|
|
10
|
+
this.logInfo(`Logged as "${user._id}" for project "${this.flags.project || this.getProject()}"`);
|
|
11
|
+
const { result } = await this.paas.query({
|
|
12
|
+
controller: "application",
|
|
13
|
+
action: "dump",
|
|
14
|
+
environmentId: this.args.environment,
|
|
15
|
+
projectId: this.flags.project || this.getProject(),
|
|
16
|
+
applicationId: this.args.applicationId,
|
|
17
|
+
body: {},
|
|
18
|
+
});
|
|
19
|
+
this.logOk(result.body);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
PaasSnapshotsDump.description = "Create a new snapshot of the current application state";
|
|
23
|
+
PaasSnapshotsDump.flags = {
|
|
24
|
+
help: command_1.flags.help(),
|
|
25
|
+
token: command_1.flags.string({
|
|
26
|
+
default: process.env.KUZZLE_PAAS_TOKEN,
|
|
27
|
+
description: "Authentication token",
|
|
28
|
+
}),
|
|
29
|
+
project: command_1.flags.string({
|
|
30
|
+
description: "Current PaaS project",
|
|
31
|
+
}),
|
|
32
|
+
};
|
|
33
|
+
PaasSnapshotsDump.args = [
|
|
34
|
+
{
|
|
35
|
+
name: "environment",
|
|
36
|
+
description: "Project environment name",
|
|
37
|
+
required: true,
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
name: "applicationId",
|
|
41
|
+
description: "Application Identifier",
|
|
42
|
+
required: true,
|
|
43
|
+
}
|
|
44
|
+
];
|
|
45
|
+
PaasSnapshotsDump.examples = ["kourou paas:snapshots:dump --project paas-project-myproject api main"];
|
|
46
|
+
exports.default = PaasSnapshotsDump;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { flags } from "@oclif/command";
|
|
2
|
+
import { PaasKommand } from "../../../support/PaasKommand";
|
|
3
|
+
declare class PaasSnapshotsRestore extends PaasKommand {
|
|
4
|
+
static description: string;
|
|
5
|
+
static flags: {
|
|
6
|
+
help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
|
|
7
|
+
token: flags.IOptionFlag<string | undefined>;
|
|
8
|
+
project: flags.IOptionFlag<string | undefined>;
|
|
9
|
+
};
|
|
10
|
+
static args: {
|
|
11
|
+
name: string;
|
|
12
|
+
description: string;
|
|
13
|
+
required: boolean;
|
|
14
|
+
}[];
|
|
15
|
+
static examples: string[];
|
|
16
|
+
runSafe(): Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
export default PaasSnapshotsRestore;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const command_1 = require("@oclif/command");
|
|
4
|
+
const PaasKommand_1 = require("../../../support/PaasKommand");
|
|
5
|
+
class PaasSnapshotsRestore extends PaasKommand_1.PaasKommand {
|
|
6
|
+
async runSafe() {
|
|
7
|
+
const apiKey = await this.getCredentials();
|
|
8
|
+
await this.initPaasClient({ apiKey });
|
|
9
|
+
const user = await this.paas.auth.getCurrentUser();
|
|
10
|
+
this.logInfo(`Logged as "${user._id}" for project "${this.flags.project || this.getProject()}"`);
|
|
11
|
+
await this.paas.query({
|
|
12
|
+
controller: "application",
|
|
13
|
+
action: "restore",
|
|
14
|
+
environmentId: this.args.environment,
|
|
15
|
+
projectId: this.flags.project || this.getProject(),
|
|
16
|
+
applicationId: this.args.applicationId,
|
|
17
|
+
body: {
|
|
18
|
+
repository: "automated",
|
|
19
|
+
snapshot: this.args.snapshotId,
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
this.logInfo("Ok");
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
PaasSnapshotsRestore.description = "Restore a snapshot of the current application state";
|
|
26
|
+
PaasSnapshotsRestore.flags = {
|
|
27
|
+
help: command_1.flags.help(),
|
|
28
|
+
token: command_1.flags.string({
|
|
29
|
+
default: process.env.KUZZLE_PAAS_TOKEN,
|
|
30
|
+
description: "Authentication token",
|
|
31
|
+
}),
|
|
32
|
+
project: command_1.flags.string({
|
|
33
|
+
description: "Current PaaS project",
|
|
34
|
+
}),
|
|
35
|
+
};
|
|
36
|
+
PaasSnapshotsRestore.args = [
|
|
37
|
+
{
|
|
38
|
+
name: "environment",
|
|
39
|
+
description: "Project environment name",
|
|
40
|
+
required: true,
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: "applicationId",
|
|
44
|
+
description: "Application Identifier",
|
|
45
|
+
required: true,
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: "snapshotId",
|
|
49
|
+
description: "Snapshot Identifier",
|
|
50
|
+
required: true,
|
|
51
|
+
}
|
|
52
|
+
];
|
|
53
|
+
PaasSnapshotsRestore.examples = ["kourou paas:snapshots:restore --project paas-project-myproject api main snapshot-id"];
|
|
54
|
+
exports.default = PaasSnapshotsRestore;
|
|
@@ -56,6 +56,16 @@ class PaasKommand extends common_1.Kommand {
|
|
|
56
56
|
}
|
|
57
57
|
return this.flags.project;
|
|
58
58
|
}
|
|
59
|
+
async getCredentials() {
|
|
60
|
+
const project = this.getProject();
|
|
61
|
+
const projectFile = this.fileProjectCredentials(project);
|
|
62
|
+
if (!fs_1.default.existsSync(projectFile)) {
|
|
63
|
+
this.logKo("You are not logged in. You should run paas:login first. Aborting.");
|
|
64
|
+
process.exit(1);
|
|
65
|
+
}
|
|
66
|
+
const credentials = JSON.parse(fs_1.default.readFileSync(projectFile, "utf8"));
|
|
67
|
+
return credentials.apiKey;
|
|
68
|
+
}
|
|
59
69
|
}
|
|
60
70
|
exports.PaasKommand = PaasKommand;
|
|
61
71
|
PaasKommand.initSdk = false;
|
package/lib/support/execute.js
CHANGED
|
@@ -30,9 +30,7 @@ function execute(...args) {
|
|
|
30
30
|
const process = (0, child_process_1.spawn)(command, commandArgs, options);
|
|
31
31
|
let stdout = "";
|
|
32
32
|
let stderr = "";
|
|
33
|
-
// eslint-disable-next-line
|
|
34
33
|
process.stdout.on("data", (data) => (stdout += data.toString()));
|
|
35
|
-
// eslint-disable-next-line
|
|
36
34
|
process.stderr.on("data", (data) => (stderr += data.toString()));
|
|
37
35
|
const executor = new Promise((resolve, reject) => {
|
|
38
36
|
process.on("close", (code) => {
|
package/lib/support/kuzzle.js
CHANGED
|
@@ -164,7 +164,10 @@ class KuzzleSDK {
|
|
|
164
164
|
const options = {
|
|
165
165
|
method: "POST",
|
|
166
166
|
headers: {
|
|
167
|
+
Accept: "application/json",
|
|
168
|
+
"Accept-Encoding": "identity",
|
|
167
169
|
Authorization: `Bearer ${this.sdk.jwt}`,
|
|
170
|
+
Connection: "keep-alive",
|
|
168
171
|
"Content-Length": Buffer.byteLength(body),
|
|
169
172
|
"Content-Type": "application/json",
|
|
170
173
|
},
|
|
@@ -24,6 +24,7 @@ class Elasticsearch {
|
|
|
24
24
|
delete specifications.settings.index.uuid;
|
|
25
25
|
delete specifications.settings.index.version;
|
|
26
26
|
delete specifications.settings.index.routing;
|
|
27
|
+
delete specifications.settings.index.history;
|
|
27
28
|
return specifications;
|
|
28
29
|
}
|
|
29
30
|
async createIndex(index, specifications) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kourou",
|
|
3
3
|
"description": "The CLI that helps you manage your Kuzzle instances",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.26.1",
|
|
5
5
|
"author": "The Kuzzle Team <support@kuzzle.io>",
|
|
6
6
|
"bin": {
|
|
7
7
|
"kourou": "./bin/run"
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"ndjson": "^2.0.0",
|
|
38
38
|
"node-emoji": "^1.10.0",
|
|
39
39
|
"node-fetch": "^2.6.7",
|
|
40
|
-
"production": "0.0.2",
|
|
40
|
+
"production": "^0.0.2",
|
|
41
41
|
"strip-json-comments": "^3.1.1",
|
|
42
42
|
"tar": "^6.1.11",
|
|
43
43
|
"tmp": "^0.2.1",
|