@platforma-sdk/bootstrap 3.5.21 → 5.0.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/assets/compose-backend.yaml +119 -49
- package/dist/commands/svc/create/arg-parser.cjs +175 -0
- package/dist/commands/svc/create/arg-parser.cjs.map +1 -0
- package/dist/commands/svc/create/arg-parser.d.ts +42 -0
- package/dist/commands/svc/create/arg-parser.js +173 -0
- package/dist/commands/svc/create/arg-parser.js.map +1 -0
- package/dist/commands/svc/create/docker/s3.cjs +26 -3
- package/dist/commands/svc/create/docker/s3.cjs.map +1 -1
- package/dist/commands/svc/create/docker/s3.js +26 -3
- package/dist/commands/svc/create/docker/s3.js.map +1 -1
- package/dist/commands/svc/create/docker.cjs +36 -3
- package/dist/commands/svc/create/docker.cjs.map +1 -1
- package/dist/commands/svc/create/docker.js +36 -3
- package/dist/commands/svc/create/docker.js.map +1 -1
- package/dist/commands/svc/create/local/s3.cjs +21 -3
- package/dist/commands/svc/create/local/s3.cjs.map +1 -1
- package/dist/commands/svc/create/local/s3.js +21 -3
- package/dist/commands/svc/create/local/s3.js.map +1 -1
- package/dist/commands/svc/create/local.cjs +51 -28
- package/dist/commands/svc/create/local.cjs.map +1 -1
- package/dist/commands/svc/create/local.js +51 -28
- package/dist/commands/svc/create/local.js.map +1 -1
- package/dist/core.cjs +174 -44
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.ts +3 -0
- package/dist/core.js +198 -68
- package/dist/core.js.map +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +8 -8
- package/dist/index.js.map +1 -1
- package/dist/package.cjs +21 -2
- package/dist/package.cjs.map +1 -1
- package/dist/package.js +2 -2
- package/dist/package.js.map +1 -1
- package/dist/platforma.js +9 -9
- package/dist/platforma.js.map +1 -1
- package/dist/state.js +13 -13
- package/dist/state.js.map +1 -1
- package/dist/templates/compose.cjs +3 -0
- package/dist/templates/compose.cjs.map +1 -1
- package/dist/templates/compose.d.ts +1 -0
- package/dist/templates/compose.js +6 -3
- package/dist/templates/compose.js.map +1 -1
- package/dist/templates/pl-config.cjs +2 -2
- package/dist/templates/pl-config.cjs.map +1 -1
- package/dist/templates/pl-config.js +4 -4
- package/dist/templates/pl-config.js.map +1 -1
- package/dist/util.js +4 -4
- package/dist/util.js.map +1 -1
- package/package.json +4 -4
package/dist/core.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import fs__default from 'node:fs';
|
|
2
2
|
import os__default from 'node:os';
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import { assets, plImageTag } from './package.js';
|
|
@@ -116,23 +116,23 @@ class Core {
|
|
|
116
116
|
}
|
|
117
117
|
this.logger.debug(' creating pl state directories...');
|
|
118
118
|
for (const dir of storageDirs) {
|
|
119
|
-
if (!
|
|
119
|
+
if (!fs__default.existsSync(dir)) {
|
|
120
120
|
this.logger.debug(` '${dir}'`);
|
|
121
|
-
|
|
121
|
+
fs__default.mkdirSync(dir, { recursive: true });
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
for (const drv of configOptions.core.auth.drivers) {
|
|
125
125
|
if (drv.driver === 'htpasswd') {
|
|
126
|
-
if (!
|
|
126
|
+
if (!fs__default.existsSync(drv.path)) {
|
|
127
127
|
this.logger.debug(` installing default 'users.htpasswd' to ${drv.path}...`);
|
|
128
|
-
|
|
128
|
+
fs__default.copyFileSync(assets('users.htpasswd'), drv.path);
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
132
|
if (!configPath) {
|
|
133
133
|
configPath = path.join(configOptions.localRoot, 'config.yaml');
|
|
134
134
|
this.logger.debug(` rendering configuration '${configPath}'...`);
|
|
135
|
-
|
|
135
|
+
fs__default.writeFileSync(configPath, render(configOptions));
|
|
136
136
|
}
|
|
137
137
|
const upCommands = [];
|
|
138
138
|
if (options?.sourcesPath) {
|
|
@@ -159,6 +159,29 @@ class Core {
|
|
|
159
159
|
GOMAXPROCS: String(options?.configOptions?.numCpu),
|
|
160
160
|
};
|
|
161
161
|
}
|
|
162
|
+
// Process additional environment variables from CLI options
|
|
163
|
+
if (options?.backendCommands) {
|
|
164
|
+
if (!runBinary.runOpts.env) {
|
|
165
|
+
runBinary.runOpts.env = {};
|
|
166
|
+
}
|
|
167
|
+
for (const cmd of options.backendCommands) {
|
|
168
|
+
const equalIndex = cmd.indexOf('=');
|
|
169
|
+
if (equalIndex > 0) {
|
|
170
|
+
const key = cmd.substring(0, equalIndex);
|
|
171
|
+
const value = cmd.substring(equalIndex + 1);
|
|
172
|
+
runBinary.runOpts.env[key] = value;
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
this.logger.warn(`Invalid environment variable format: ${cmd}. Expected format: KEY=VALUE`);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
// Process additional backend commands
|
|
180
|
+
if (options?.backendCommands && options.backendCommands.length > 0) {
|
|
181
|
+
this.logger.debug(`Adding backend commands: ${options.backendCommands.join(' ')}`);
|
|
182
|
+
// Add commands as arguments to the binary
|
|
183
|
+
runBinary.args = [...runBinary.args, ...options.backendCommands];
|
|
184
|
+
}
|
|
162
185
|
upCommands.push(runBinary);
|
|
163
186
|
state.setInstanceInfo(instanceName, {
|
|
164
187
|
type: 'process',
|
|
@@ -182,8 +205,8 @@ class Core {
|
|
|
182
205
|
const minioPort = options?.minioPort ?? 9000;
|
|
183
206
|
const instance = this.createLocal(instanceName, {
|
|
184
207
|
...options,
|
|
185
|
-
primaryURL: options?.primaryURL ?? `s3e://testuser:testpassword@localhost:${minioPort}/
|
|
186
|
-
libraryURL: options?.libraryURL ?? `s3e://testuser:testpassword@localhost:${minioPort}/library-bucket/?region=no-region`,
|
|
208
|
+
primaryURL: options?.primaryURL ?? `s3e://testuser:testpassword@localhost:${minioPort}/platforma-primary-bucket/?region=no-region`,
|
|
209
|
+
libraryURL: options?.libraryURL ?? `s3e://testuser:testpassword@localhost:${minioPort}/platforma-library-bucket/?region=no-region`,
|
|
187
210
|
});
|
|
188
211
|
const localRoot = options?.configOptions?.localRoot;
|
|
189
212
|
const minioRunCmd = this.createMinio(instanceName, {
|
|
@@ -263,20 +286,20 @@ class Core {
|
|
|
263
286
|
return p;
|
|
264
287
|
};
|
|
265
288
|
const logFilePath = storagePath('logs', 'platforma.log');
|
|
266
|
-
if (!
|
|
267
|
-
|
|
268
|
-
|
|
289
|
+
if (!fs__default.existsSync(logFilePath)) {
|
|
290
|
+
fs__default.mkdirSync(path.dirname(logFilePath), { recursive: true });
|
|
291
|
+
fs__default.writeFileSync(logFilePath, '');
|
|
269
292
|
}
|
|
270
293
|
const presignHost = options?.presignHost ?? 'localhost';
|
|
271
294
|
const presignPort = options?.s3Port ?? 9000;
|
|
272
|
-
const primary = storageSettingsFromURL(`s3e://testuser:testpassword@minio:${presignPort}/
|
|
295
|
+
const primary = storageSettingsFromURL(`s3e://testuser:testpassword@minio:${presignPort}/platforma-primary-bucket`);
|
|
273
296
|
if (primary.type !== 'S3') {
|
|
274
297
|
throw new Error('primary storage must have \'S3\' type in \'docker s3\' configuration');
|
|
275
298
|
}
|
|
276
299
|
else {
|
|
277
300
|
primary.presignEndpoint = `http://${presignHost}:${presignPort}`;
|
|
278
301
|
}
|
|
279
|
-
const library = storageSettingsFromURL(`s3e://testuser:testpassword@minio:${presignPort}/library-bucket`);
|
|
302
|
+
const library = storageSettingsFromURL(`s3e://testuser:testpassword@minio:${presignPort}/platforma-library-bucket`);
|
|
280
303
|
if (library.type !== 'S3') {
|
|
281
304
|
throw new Error(`${library.type} storage type is not supported for library storage`);
|
|
282
305
|
}
|
|
@@ -286,11 +309,11 @@ class Core {
|
|
|
286
309
|
const dbFSPath = storageDir('db');
|
|
287
310
|
const workFSPath = storageDir('work');
|
|
288
311
|
const usersFSPath = storagePath('users.htpasswd');
|
|
289
|
-
if (!
|
|
290
|
-
|
|
312
|
+
if (!fs__default.existsSync(usersFSPath)) {
|
|
313
|
+
fs__default.copyFileSync(assets('users.htpasswd'), usersFSPath);
|
|
291
314
|
}
|
|
292
315
|
const composeDstPath = storagePath('compose.yaml');
|
|
293
|
-
if (
|
|
316
|
+
if (fs__default.existsSync(composeDstPath)) {
|
|
294
317
|
this.logger.info(`replacing docker compose file ${composeDstPath}`);
|
|
295
318
|
}
|
|
296
319
|
const backendMounts = [];
|
|
@@ -305,13 +328,14 @@ class Core {
|
|
|
305
328
|
['backend', {
|
|
306
329
|
platform: options?.platformOverride,
|
|
307
330
|
mounts: backendMounts,
|
|
331
|
+
commands: options?.backendCommands,
|
|
308
332
|
}],
|
|
309
333
|
]));
|
|
310
334
|
const envs = {
|
|
311
335
|
MINIO_IMAGE: 'quay.io/minio/minio',
|
|
312
336
|
MINIO_STORAGE: storageDir('minio'),
|
|
313
337
|
PL_IMAGE: image,
|
|
314
|
-
|
|
338
|
+
PL_AUTH_HTPASSWD: usersFSPath,
|
|
315
339
|
PL_LICENSE: options?.license,
|
|
316
340
|
PL_LICENSE_FILE: options?.licenseFile,
|
|
317
341
|
PL_LOG_LEVEL: options?.logLevel ?? 'info',
|
|
@@ -327,36 +351,70 @@ class Core {
|
|
|
327
351
|
...this.configureDockerStorage('primary', primary),
|
|
328
352
|
...this.configureDockerStorage('library', library),
|
|
329
353
|
};
|
|
330
|
-
if (options?.grpcAddr)
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
354
|
+
if (options?.grpcAddr) {
|
|
355
|
+
const addrParts = options.grpcAddr.split(':');
|
|
356
|
+
if (addrParts.length === 2) {
|
|
357
|
+
envs.PL_LISTEN_ADDRESS = addrParts[0];
|
|
358
|
+
envs.PL_LISTEN_PORT = addrParts[1];
|
|
359
|
+
}
|
|
360
|
+
else {
|
|
361
|
+
envs.PL_LISTEN_ADDRESS = options.grpcAddr;
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
else if (options?.grpcPort) {
|
|
365
|
+
envs.PL_LISTEN_PORT = options.grpcPort.toString();
|
|
366
|
+
}
|
|
367
|
+
if (options?.monitoringAddr) {
|
|
368
|
+
const addrParts = options.monitoringAddr.split(':');
|
|
369
|
+
if (addrParts.length === 2) {
|
|
370
|
+
envs.PL_MONITORING_IP = addrParts[0];
|
|
371
|
+
envs.PL_MONITORING_PORT = addrParts[1];
|
|
372
|
+
}
|
|
373
|
+
else {
|
|
374
|
+
envs.PL_MONITORING_IP = options.monitoringAddr;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
else if (options?.monitoringPort) {
|
|
337
378
|
envs.PL_MONITORING_PORT = options.monitoringPort.toString();
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
379
|
+
}
|
|
380
|
+
if (options?.debugAddr) {
|
|
381
|
+
const addrParts = options.debugAddr.split(':');
|
|
382
|
+
if (addrParts.length === 2) {
|
|
383
|
+
envs.PL_DEBUG_IP = addrParts[0];
|
|
384
|
+
envs.PL_DEBUG_PORT = addrParts[1];
|
|
385
|
+
}
|
|
386
|
+
else {
|
|
387
|
+
envs.PL_DEBUG_IP = options.debugAddr;
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
else if (options?.debugPort) {
|
|
341
391
|
envs.PL_DEBUG_PORT = options.debugPort.toString();
|
|
392
|
+
}
|
|
342
393
|
if (options?.s3Port)
|
|
343
394
|
envs.MINIO_PORT = options.s3Port.toString();
|
|
344
395
|
if (options?.s3ConsolePort)
|
|
345
396
|
envs.MINIO_CONSOLE_PORT = options.s3ConsolePort.toString();
|
|
346
397
|
if (options?.auth) {
|
|
347
398
|
if (options.auth.enabled) {
|
|
348
|
-
envs['
|
|
399
|
+
envs['PL_NO_AUTH'] = 'false';
|
|
400
|
+
}
|
|
401
|
+
else {
|
|
402
|
+
envs['PL_NO_AUTH'] = 'true';
|
|
349
403
|
}
|
|
350
404
|
if (options.auth.drivers) {
|
|
351
405
|
for (const drv of options.auth.drivers) {
|
|
352
406
|
if (drv.driver === 'htpasswd') {
|
|
353
|
-
envs['
|
|
407
|
+
envs['PL_AUTH_HTPASSWD'] = path.resolve(drv.path);
|
|
354
408
|
drv.path = '/etc/platforma/users.htpasswd';
|
|
355
409
|
}
|
|
356
410
|
}
|
|
357
411
|
envs['PL_AUTH_DRIVERS'] = JSON.stringify(options.auth.drivers);
|
|
358
412
|
}
|
|
359
413
|
}
|
|
414
|
+
// Process additional backend commands
|
|
415
|
+
if (options?.backendCommands && options.backendCommands.length > 0) {
|
|
416
|
+
this.logger.debug(`Adding backend commands: ${options.backendCommands.join(' ')}`);
|
|
417
|
+
}
|
|
360
418
|
state.setInstanceInfo(instanceName, {
|
|
361
419
|
type: 'docker',
|
|
362
420
|
upCommands: [{
|
|
@@ -401,20 +459,20 @@ class Core {
|
|
|
401
459
|
return p;
|
|
402
460
|
};
|
|
403
461
|
const logFilePath = storagePath('logs', 'platforma.log');
|
|
404
|
-
if (!
|
|
405
|
-
|
|
406
|
-
|
|
462
|
+
if (!fs__default.existsSync(logFilePath)) {
|
|
463
|
+
fs__default.mkdirSync(path.dirname(logFilePath), { recursive: true });
|
|
464
|
+
fs__default.writeFileSync(logFilePath, '');
|
|
407
465
|
}
|
|
408
466
|
const dbFSPath = storageDir('db');
|
|
409
467
|
const primaryFSPath = storageDir('primary');
|
|
410
468
|
const libraryFSPath = storageDir('library');
|
|
411
469
|
const workFSPath = storageDir('work');
|
|
412
470
|
const usersFSPath = storagePath('users.htpasswd');
|
|
413
|
-
if (!
|
|
414
|
-
|
|
471
|
+
if (!fs__default.existsSync(usersFSPath)) {
|
|
472
|
+
fs__default.copyFileSync(assets('users.htpasswd'), usersFSPath);
|
|
415
473
|
}
|
|
416
474
|
const composeDstPath = storagePath('compose.yaml');
|
|
417
|
-
if (
|
|
475
|
+
if (fs__default.existsSync(composeDstPath)) {
|
|
418
476
|
this.logger.info(`replacing docker compose file ${composeDstPath}`);
|
|
419
477
|
}
|
|
420
478
|
const backendMounts = [];
|
|
@@ -429,16 +487,17 @@ class Core {
|
|
|
429
487
|
['backend', {
|
|
430
488
|
platform: options?.platformOverride,
|
|
431
489
|
mounts: backendMounts,
|
|
490
|
+
commands: options?.backendCommands,
|
|
432
491
|
}],
|
|
433
492
|
]));
|
|
434
493
|
const primary = storageSettingsFromURL(options?.primaryStorageURL ?? `file:${primaryFSPath}`, '.');
|
|
435
494
|
const library = storageSettingsFromURL(options?.libraryStorageURL ?? `file:${libraryFSPath}`, '.');
|
|
436
495
|
const envs = {
|
|
437
496
|
PL_IMAGE: image,
|
|
438
|
-
|
|
497
|
+
PL_AUTH_HTPASSWD: usersFSPath,
|
|
439
498
|
PL_LICENSE: options?.license,
|
|
440
499
|
PL_LICENSE_FILE: options?.licenseFile,
|
|
441
|
-
PL_LOG_LEVEL: 'info',
|
|
500
|
+
PL_LOG_LEVEL: options?.logLevel ?? 'info',
|
|
442
501
|
PL_LOG_DIR: path.dirname(logFilePath),
|
|
443
502
|
PL_LOG_ROTATION_ENABLED: 'true',
|
|
444
503
|
PL_RUNNER_WD_CACHE_ON_FAILURE: '1h',
|
|
@@ -450,32 +509,66 @@ class Core {
|
|
|
450
509
|
...this.configureDockerStorage('primary', primary),
|
|
451
510
|
...this.configureDockerStorage('library', library),
|
|
452
511
|
};
|
|
453
|
-
if (options?.grpcAddr)
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
512
|
+
if (options?.grpcAddr) {
|
|
513
|
+
const addrParts = options.grpcAddr.split(':');
|
|
514
|
+
if (addrParts.length === 2) {
|
|
515
|
+
envs.PL_LISTEN_ADDRESS = addrParts[0];
|
|
516
|
+
envs.PL_LISTEN_PORT = addrParts[1];
|
|
517
|
+
}
|
|
518
|
+
else {
|
|
519
|
+
envs.PL_LISTEN_ADDRESS = options.grpcAddr;
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
else if (options?.grpcPort) {
|
|
523
|
+
envs.PL_LISTEN_PORT = options.grpcPort.toString();
|
|
524
|
+
}
|
|
525
|
+
if (options?.monitoringAddr) {
|
|
526
|
+
const addrParts = options.monitoringAddr.split(':');
|
|
527
|
+
if (addrParts.length === 2) {
|
|
528
|
+
envs.PL_MONITORING_IP = addrParts[0];
|
|
529
|
+
envs.PL_MONITORING_PORT = addrParts[1];
|
|
530
|
+
}
|
|
531
|
+
else {
|
|
532
|
+
envs.PL_MONITORING_IP = options.monitoringAddr;
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
else if (options?.monitoringPort) {
|
|
460
536
|
envs.PL_MONITORING_PORT = options.monitoringPort.toString();
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
537
|
+
}
|
|
538
|
+
if (options?.debugAddr) {
|
|
539
|
+
const addrParts = options.debugAddr.split(':');
|
|
540
|
+
if (addrParts.length === 2) {
|
|
541
|
+
envs.PL_DEBUG_IP = addrParts[0];
|
|
542
|
+
envs.PL_DEBUG_PORT = addrParts[1];
|
|
543
|
+
}
|
|
544
|
+
else {
|
|
545
|
+
envs.PL_DEBUG_IP = options.debugAddr;
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
else if (options?.debugPort) {
|
|
464
549
|
envs.PL_DEBUG_PORT = options.debugPort.toString();
|
|
550
|
+
}
|
|
465
551
|
if (options?.auth) {
|
|
466
552
|
if (options.auth.enabled) {
|
|
467
|
-
envs['
|
|
553
|
+
envs['PL_NO_AUTH'] = 'false';
|
|
554
|
+
}
|
|
555
|
+
else {
|
|
556
|
+
envs['PL_NO_AUTH'] = 'true';
|
|
468
557
|
}
|
|
469
558
|
if (options.auth.drivers) {
|
|
470
559
|
for (const drv of options.auth.drivers) {
|
|
471
560
|
if (drv.driver === 'htpasswd') {
|
|
472
|
-
envs['
|
|
561
|
+
envs['PL_AUTH_HTPASSWD'] = path.resolve(drv.path);
|
|
473
562
|
drv.path = '/etc/platforma/users.htpasswd';
|
|
474
563
|
}
|
|
475
564
|
}
|
|
476
565
|
envs['PL_AUTH_DRIVERS'] = JSON.stringify(options.auth.drivers);
|
|
477
566
|
}
|
|
478
567
|
}
|
|
568
|
+
// Process additional backend commands
|
|
569
|
+
if (options?.backendCommands && options.backendCommands.length > 0) {
|
|
570
|
+
this.logger.debug(`Adding backend commands: ${options.backendCommands.join(' ')}`);
|
|
571
|
+
}
|
|
479
572
|
state.setInstanceInfo(instanceName, {
|
|
480
573
|
type: 'docker',
|
|
481
574
|
upCommands: [{
|
|
@@ -561,11 +654,11 @@ You are going to reset the state of all platforma services configured with pl-bo
|
|
|
561
654
|
checkRunError(result.executed, `failed to wipe instance ${name} services`);
|
|
562
655
|
}
|
|
563
656
|
this.logger.info(`Destroying instance '${name}' data directory`);
|
|
564
|
-
|
|
657
|
+
fs__default.rmSync(state.instanceDir(name), { recursive: true, force: true });
|
|
565
658
|
}
|
|
566
659
|
if (!instanceName) {
|
|
567
660
|
this.logger.info(`Destroying state dir '${state.path()}'`);
|
|
568
|
-
|
|
661
|
+
fs__default.rmSync(state.path(), { recursive: true, force: true });
|
|
569
662
|
}
|
|
570
663
|
this.logger.info(`\nIf you want to remove all downloaded platforma binaries, delete '${state.binaries()}' dir manually\n`);
|
|
571
664
|
}
|
|
@@ -582,7 +675,7 @@ You are going to reset the state of all platforma services configured with pl-bo
|
|
|
582
675
|
flags['license-file'] = process.env.MI_LICENSE_FILE;
|
|
583
676
|
else if ((process.env.PL_LICENSE_FILE ?? '') != '')
|
|
584
677
|
flags['license-file'] = process.env.PL_LICENSE_FILE;
|
|
585
|
-
else if (
|
|
678
|
+
else if (fs__default.existsSync(path.resolve(os__default.homedir(), '.pl.license')))
|
|
586
679
|
flags['license-file'] = path.resolve(os__default.homedir(), '.pl.license');
|
|
587
680
|
}
|
|
588
681
|
}
|
|
@@ -614,12 +707,12 @@ You are going to reset the state of all platforma services configured with pl-bo
|
|
|
614
707
|
const jwtFile = state.path('auth.jwt');
|
|
615
708
|
const encoding = 'utf-8';
|
|
616
709
|
let lastJwt = '';
|
|
617
|
-
if (
|
|
618
|
-
lastJwt =
|
|
710
|
+
if (fs__default.existsSync(jwtFile)) {
|
|
711
|
+
lastJwt = fs__default.readFileSync(jwtFile, { encoding });
|
|
619
712
|
}
|
|
620
713
|
if (lastJwt == '') {
|
|
621
714
|
lastJwt = randomStr(64);
|
|
622
|
-
|
|
715
|
+
fs__default.writeFileSync(jwtFile, lastJwt, { encoding });
|
|
623
716
|
}
|
|
624
717
|
return lastJwt;
|
|
625
718
|
}
|
|
@@ -647,21 +740,58 @@ You can obtain the license from "https://licensing.milaboratories.com".`);
|
|
|
647
740
|
storageID = storageID.toUpperCase();
|
|
648
741
|
switch (sType) {
|
|
649
742
|
case 'S3':
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
743
|
+
switch (storageID) {
|
|
744
|
+
case 'PRIMARY': {
|
|
745
|
+
// Construct the S3 URL for primary storage
|
|
746
|
+
if (storage.endpoint && storage.bucketName) {
|
|
747
|
+
envs['PL_DATA_LIBRARY_S3_URL'] = `${storage.endpoint}${storage.bucketName}`;
|
|
748
|
+
}
|
|
749
|
+
if (storage.endpoint)
|
|
750
|
+
envs['PL_PRIMARY_STORAGE_S3_ENDPOINT'] = storage.endpoint;
|
|
751
|
+
if (storage.presignEndpoint)
|
|
752
|
+
envs['PL_PRIMARY_STORAGE_S3_EXTERNAL_ENDPOINT'] = storage.presignEndpoint;
|
|
753
|
+
if (storage.region)
|
|
754
|
+
envs['PL_PRIMARY_STORAGE_S3_REGION'] = storage.region;
|
|
755
|
+
if (storage.key)
|
|
756
|
+
envs['PL_PRIMARY_STORAGE_S3_KEY'] = storage.key;
|
|
757
|
+
if (storage.secret)
|
|
758
|
+
envs['PL_PRIMARY_STORAGE_S3_SECRET'] = storage.secret;
|
|
759
|
+
break;
|
|
760
|
+
}
|
|
761
|
+
case 'LIBRARY': {
|
|
762
|
+
// Construct the S3 URL for library storage
|
|
763
|
+
if (storage.endpoint && storage.bucketName) {
|
|
764
|
+
envs['PL_DATA_LIBRARY_S3_URL'] = `library=${storage.endpoint}${storage.bucketName}`;
|
|
765
|
+
}
|
|
766
|
+
if (storage.endpoint)
|
|
767
|
+
envs['PL_DATA_LIBRARY_S3_ENDPOINT'] = `library=${storage.endpoint}`;
|
|
768
|
+
if (storage.presignEndpoint)
|
|
769
|
+
envs['PL_DATA_LIBRARY_S3_EXTERNAL_ENDPOINT'] = `library=${storage.presignEndpoint}`;
|
|
770
|
+
if (storage.region)
|
|
771
|
+
envs['PL_DATA_LIBRARY_S3_REGION'] = `library=${storage.region}`;
|
|
772
|
+
if (storage.key)
|
|
773
|
+
envs['PL_DATA_LIBRARY_S3_KEY'] = `library=${storage.key}`;
|
|
774
|
+
if (storage.secret)
|
|
775
|
+
envs['PL_DATA_LIBRARY_S3_SECRET'] = `library=${storage.secret}`;
|
|
776
|
+
break;
|
|
777
|
+
}
|
|
778
|
+
default:
|
|
779
|
+
throw new Error(`Unknown storage ID: ${storageID}`);
|
|
780
|
+
}
|
|
662
781
|
return envs;
|
|
663
782
|
case 'FS':
|
|
664
|
-
|
|
783
|
+
switch (storageID) {
|
|
784
|
+
case 'PRIMARY':
|
|
785
|
+
if (storage.rootPath)
|
|
786
|
+
envs['PL_PRIMARY_STORAGE_FS'] = storage.rootPath;
|
|
787
|
+
break;
|
|
788
|
+
case 'LIBRARY':
|
|
789
|
+
if (storage.rootPath)
|
|
790
|
+
envs['PL_DATA_LIBRARY_FS_PATH'] = storage.rootPath;
|
|
791
|
+
break;
|
|
792
|
+
default:
|
|
793
|
+
throw new Error(`Unknown storage ID: ${storageID}`);
|
|
794
|
+
}
|
|
665
795
|
return envs;
|
|
666
796
|
default:
|
|
667
797
|
assertNever();
|