@camunda8/cli 4.1.0 → 4.2.0-alpha.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 +3 -0
- package/dist/default-plugins/cluster/c8ctl-plugin.js +380 -37
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -67,6 +67,9 @@ npm install @camunda8/cli -g
|
|
|
67
67
|
# Start a local Camunda 8 cluster (no Docker required)
|
|
68
68
|
c8ctl cluster start
|
|
69
69
|
|
|
70
|
+
# Store a secret for local development (values are never shown or stored by c8ctl)
|
|
71
|
+
c8ctl cluster secrets set OPENAI_API_KEY
|
|
72
|
+
|
|
70
73
|
# Deploy a process and start an instance
|
|
71
74
|
c8ctl deploy ./my-process.bpmn
|
|
72
75
|
c8ctl run my-process
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
} from 'node:fs';
|
|
21
21
|
import { chmod } from 'node:fs/promises';
|
|
22
22
|
import { homedir, platform as osPlatform, arch as osArch } from 'node:os';
|
|
23
|
-
import { join, dirname } from 'node:path';
|
|
23
|
+
import { join, dirname, isAbsolute, resolve } from 'node:path';
|
|
24
24
|
import { fileURLToPath } from 'node:url';
|
|
25
25
|
|
|
26
26
|
// ---------------------------------------------------------------------------
|
|
@@ -321,6 +321,7 @@ export const metadata = {
|
|
|
321
321
|
{ name: 'log', description: 'Stream cluster logs' },
|
|
322
322
|
{ name: 'logs', description: 'Stream cluster logs' },
|
|
323
323
|
{ name: 'purge', description: 'Delete runtime data (keeps binary) so the next start is fresh' },
|
|
324
|
+
{ name: 'secrets', description: 'Manage local development secrets (passed through to c8run)' },
|
|
324
325
|
],
|
|
325
326
|
examples: [
|
|
326
327
|
{ command: 'c8ctl cluster start', description: 'Start a local Camunda 8 cluster (latest stable)' },
|
|
@@ -335,6 +336,10 @@ export const metadata = {
|
|
|
335
336
|
{ command: 'c8ctl cluster delete 8.8', description: 'Remove a locally cached version' },
|
|
336
337
|
{ command: 'c8ctl cluster purge 8.8', description: 'Delete runtime data for a version (binary stays intact)' },
|
|
337
338
|
{ command: 'c8ctl cluster stop --purge', description: 'Stop the running cluster and delete its runtime data' },
|
|
339
|
+
{ command: 'c8ctl cluster secrets set OPENAI_API_KEY', description: 'Store a secret (prompts, no-echo)' },
|
|
340
|
+
{ command: 'c8ctl cluster secrets list', description: 'List secret names (values are never shown)' },
|
|
341
|
+
{ command: 'c8ctl cluster secrets import .env.secrets', description: 'Import secrets from a dotenv file' },
|
|
342
|
+
{ command: 'c8ctl cluster secrets delete OPENAI_API_KEY --yes', description: 'Delete a secret without prompting' },
|
|
338
343
|
],
|
|
339
344
|
},
|
|
340
345
|
},
|
|
@@ -550,45 +555,61 @@ async function extractArchive(archivePath, targetDir) {
|
|
|
550
555
|
|
|
551
556
|
mkdirSync(targetDir, { recursive: true });
|
|
552
557
|
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
})
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
),
|
|
571
|
-
);
|
|
572
|
-
});
|
|
558
|
+
const { command, args } = resolveExtractCommand({
|
|
559
|
+
archivePath,
|
|
560
|
+
targetDir,
|
|
561
|
+
platform: osPlatform(),
|
|
562
|
+
});
|
|
563
|
+
|
|
564
|
+
return new Promise((resolve, reject) => {
|
|
565
|
+
const proc = spawn(command, args, { stdio: 'inherit' });
|
|
566
|
+
proc.on('exit', (code, signal) => {
|
|
567
|
+
if (code === 0) {
|
|
568
|
+
logger.info('Extraction complete.');
|
|
569
|
+
resolve();
|
|
570
|
+
} else if (signal) {
|
|
571
|
+
reject(new Error(`Extraction terminated by signal ${signal}`));
|
|
572
|
+
} else {
|
|
573
|
+
reject(new Error(`Extraction failed with code ${code}`));
|
|
574
|
+
}
|
|
573
575
|
});
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
logger.info('Extraction complete.');
|
|
582
|
-
resolve();
|
|
583
|
-
} else {
|
|
584
|
-
reject(new Error(`Extraction failed with code ${code}`));
|
|
585
|
-
}
|
|
586
|
-
});
|
|
587
|
-
proc.on('error', reject);
|
|
576
|
+
proc.on('error', (err) => {
|
|
577
|
+
reject(
|
|
578
|
+
new Error(
|
|
579
|
+
`Failed to extract archive with "${command}": ${err.message}. ` +
|
|
580
|
+
`Make sure "${command}" is available on your PATH.`,
|
|
581
|
+
),
|
|
582
|
+
);
|
|
588
583
|
});
|
|
589
|
-
}
|
|
590
|
-
|
|
584
|
+
});
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
/**
|
|
588
|
+
* Decide which extractor to spawn for a given archive and platform.
|
|
589
|
+
*
|
|
590
|
+
* Windows has no POSIX `unzip`, but ships bsdtar/libarchive as
|
|
591
|
+
* C:\Windows\System32\tar.exe (Windows 10 1803 / Server 2019+), and libarchive
|
|
592
|
+
* reads ZIP — so on win32 we extract a `.zip` with `tar -xf`. Any other
|
|
593
|
+
* platform extracts a `.zip` with `unzip -q`: macOS ships `unzip`
|
|
594
|
+
* preinstalled, and in practice Linux callers only ever pass a `.tar.gz`
|
|
595
|
+
* (handled below), never a `.zip`. If a Linux `.zip` were ever passed here it
|
|
596
|
+
* would resolve to `unzip`, and extractArchive() surfaces a clear "make sure unzip is
|
|
597
|
+
* on your PATH" error if the binary is missing.
|
|
598
|
+
*
|
|
599
|
+
* @param {{ archivePath: string, targetDir: string, platform: string }} opts
|
|
600
|
+
* @returns {{ command: string, args: string[] }}
|
|
601
|
+
*/
|
|
602
|
+
export function resolveExtractCommand({ archivePath, targetDir, platform }) {
|
|
603
|
+
if (archivePath.endsWith('.zip')) {
|
|
604
|
+
if (platform === 'win32') {
|
|
605
|
+
return { command: 'tar', args: ['-xf', archivePath, '-C', targetDir] };
|
|
606
|
+
}
|
|
607
|
+
return { command: 'unzip', args: ['-q', archivePath, '-d', targetDir] };
|
|
608
|
+
}
|
|
609
|
+
if (archivePath.endsWith('.tar.gz')) {
|
|
610
|
+
return { command: 'tar', args: ['-xzf', archivePath, '-C', targetDir] };
|
|
591
611
|
}
|
|
612
|
+
throw new Error(`Unsupported archive format: ${archivePath}`);
|
|
592
613
|
}
|
|
593
614
|
|
|
594
615
|
export function findC8RunBinaryPath(config) {
|
|
@@ -1197,6 +1218,299 @@ export async function stopC8Run(config, debug = false) {
|
|
|
1197
1218
|
return stoppedVersion;
|
|
1198
1219
|
}
|
|
1199
1220
|
|
|
1221
|
+
// ---------------------------------------------------------------------------
|
|
1222
|
+
// Secrets passthrough (#314)
|
|
1223
|
+
//
|
|
1224
|
+
// c8run itself owns secret storage, validation, and locking (`c8run secrets
|
|
1225
|
+
// set|list|path|delete|import`). c8ctl adds no store and sees no values —
|
|
1226
|
+
// it only locates the right c8run binary and forwards the call to it.
|
|
1227
|
+
// ---------------------------------------------------------------------------
|
|
1228
|
+
|
|
1229
|
+
// Global c8ctl flags, mirrored from src/framework/command-registry.ts's
|
|
1230
|
+
// GLOBAL_FLAGS (a plugin cannot import src/ — see the layering rules in
|
|
1231
|
+
// AGENTS.md). Needed to correctly identify the "cluster secrets" token pair
|
|
1232
|
+
// in raw argv: c8ctl accepts these flags anywhere on the command line, not
|
|
1233
|
+
// just before the verb, so one can legitimately sit between "cluster" and
|
|
1234
|
+
// "secrets" (e.g. `c8ctl cluster --profile prod secrets set KEY --stdin`).
|
|
1235
|
+
const GLOBAL_BOOLEAN_FLAGS = new Set(['--help', '-h', '--dry-run', '--verbose', '--json', '--yes', '-y']);
|
|
1236
|
+
const GLOBAL_STRING_FLAGS = new Set(['--profile', '--fields', '--version', '-v']);
|
|
1237
|
+
|
|
1238
|
+
/** True for a recognized global boolean flag token (never consumes a following token). */
|
|
1239
|
+
function isGlobalBooleanFlagToken(token) {
|
|
1240
|
+
return GLOBAL_BOOLEAN_FLAGS.has(token);
|
|
1241
|
+
}
|
|
1242
|
+
|
|
1243
|
+
/**
|
|
1244
|
+
* True for a recognized global string flag token, in either "--flag value"
|
|
1245
|
+
* or "--flag=value" form. The caller still needs to know which form it was
|
|
1246
|
+
* to decide whether to also skip the next token — see `stringFlagTokenWidth`.
|
|
1247
|
+
*/
|
|
1248
|
+
function isGlobalStringFlagToken(token) {
|
|
1249
|
+
const name = token.includes('=') ? token.slice(0, token.indexOf('=')) : token;
|
|
1250
|
+
return GLOBAL_STRING_FLAGS.has(name);
|
|
1251
|
+
}
|
|
1252
|
+
|
|
1253
|
+
/** How many argv slots a global string flag token occupies: 1 for "--flag=value", 2 for "--flag value". */
|
|
1254
|
+
function stringFlagTokenWidth(token) {
|
|
1255
|
+
return token.includes('=') ? 1 : 2;
|
|
1256
|
+
}
|
|
1257
|
+
|
|
1258
|
+
/**
|
|
1259
|
+
* Recover the raw argv tail that follows "cluster secrets", reading
|
|
1260
|
+
* `argv` (normally `process.argv.slice(2)`) directly instead of the array
|
|
1261
|
+
* the c8ctl host passes to a plugin command. The host's top-level parser
|
|
1262
|
+
* treats an unrecognized flag as a boolean and strips it from the
|
|
1263
|
+
* positionals a plugin receives (see #364 in src/index.ts), which would
|
|
1264
|
+
* silently drop flags like --stdin, --all, and --yes before they ever
|
|
1265
|
+
* reached this plugin.
|
|
1266
|
+
*
|
|
1267
|
+
* Walks argv from the start, skipping recognized global flags (in both
|
|
1268
|
+
* "--flag value" and "--flag=value" form) wherever they appear — including
|
|
1269
|
+
* between "cluster" and "secrets" — until it finds that pair, then returns
|
|
1270
|
+
* everything after it. Falls back to `hostArgs.slice(1)` — the args array a
|
|
1271
|
+
* plugin host actually delivers — only when no such pair is found at all,
|
|
1272
|
+
* e.g. a direct/programmatic call, or "cluster" is followed by some other
|
|
1273
|
+
* verb.
|
|
1274
|
+
*/
|
|
1275
|
+
export function sliceSecretsArgv(argv, hostArgs) {
|
|
1276
|
+
let i = 0;
|
|
1277
|
+
let foundCluster = false;
|
|
1278
|
+
|
|
1279
|
+
while (i < argv.length) {
|
|
1280
|
+
const token = argv[i];
|
|
1281
|
+
|
|
1282
|
+
if (!foundCluster && token === 'cluster') {
|
|
1283
|
+
foundCluster = true;
|
|
1284
|
+
i += 1;
|
|
1285
|
+
continue;
|
|
1286
|
+
}
|
|
1287
|
+
|
|
1288
|
+
if (foundCluster && token === 'secrets') {
|
|
1289
|
+
return argv.slice(i + 1);
|
|
1290
|
+
}
|
|
1291
|
+
|
|
1292
|
+
if (isGlobalBooleanFlagToken(token)) {
|
|
1293
|
+
i += 1;
|
|
1294
|
+
continue;
|
|
1295
|
+
}
|
|
1296
|
+
if (isGlobalStringFlagToken(token)) {
|
|
1297
|
+
i += stringFlagTokenWidth(token);
|
|
1298
|
+
continue;
|
|
1299
|
+
}
|
|
1300
|
+
|
|
1301
|
+
// After "cluster", anything that isn't a recognized global flag and
|
|
1302
|
+
// isn't "secrets" means this isn't the invocation we're looking for
|
|
1303
|
+
// (e.g. "cluster start") — give up and fall back.
|
|
1304
|
+
if (foundCluster) break;
|
|
1305
|
+
|
|
1306
|
+
i += 1;
|
|
1307
|
+
}
|
|
1308
|
+
|
|
1309
|
+
return hostArgs.slice(1);
|
|
1310
|
+
}
|
|
1311
|
+
|
|
1312
|
+
/**
|
|
1313
|
+
* Split a `cluster secrets` argv tail into an optional pinned c8run version
|
|
1314
|
+
* and the passthrough arguments that go to `c8run secrets` unchanged.
|
|
1315
|
+
*
|
|
1316
|
+
* Only strips --c8-version (in either "--c8-version value" or
|
|
1317
|
+
* "--c8-version=value" form, matching how the rest of c8ctl accepts string
|
|
1318
|
+
* flags) when it is the very first token, so any later occurrence reaches
|
|
1319
|
+
* c8run untouched. There is deliberately no verb allowlist here — c8ctl
|
|
1320
|
+
* does not validate or enumerate c8run's own verbs, so an older, newer, or
|
|
1321
|
+
* unreleased c8run's verb set (including one c8ctl has never heard of) is
|
|
1322
|
+
* still forwarded and its own error surfaces as-is.
|
|
1323
|
+
*/
|
|
1324
|
+
export function parseSecretsArgs(tail) {
|
|
1325
|
+
let version = null;
|
|
1326
|
+
let passthrough = tail;
|
|
1327
|
+
|
|
1328
|
+
const first = passthrough[0];
|
|
1329
|
+
const isC8VersionFlag = first === '--c8-version' || (typeof first === 'string' && first.startsWith('--c8-version='));
|
|
1330
|
+
if (isC8VersionFlag) {
|
|
1331
|
+
if (first.startsWith('--c8-version=')) {
|
|
1332
|
+
version = first.slice('--c8-version='.length);
|
|
1333
|
+
passthrough = passthrough.slice(1);
|
|
1334
|
+
} else {
|
|
1335
|
+
version = passthrough[1];
|
|
1336
|
+
passthrough = passthrough.slice(2);
|
|
1337
|
+
}
|
|
1338
|
+
if (!version || version.startsWith('-')) {
|
|
1339
|
+
throw new Error(
|
|
1340
|
+
'Missing value for --c8-version. Example: c8ctl cluster secrets --c8-version 8.10 list',
|
|
1341
|
+
);
|
|
1342
|
+
}
|
|
1343
|
+
}
|
|
1344
|
+
|
|
1345
|
+
if (passthrough.length === 0) {
|
|
1346
|
+
throw new Error(
|
|
1347
|
+
'usage: c8ctl cluster secrets [--c8-version <version>] <set|list|path|delete|import|...>',
|
|
1348
|
+
);
|
|
1349
|
+
}
|
|
1350
|
+
|
|
1351
|
+
return { version, passthrough };
|
|
1352
|
+
}
|
|
1353
|
+
|
|
1354
|
+
/**
|
|
1355
|
+
* Resolve paths in a secrets passthrough call against the caller's cwd, not
|
|
1356
|
+
* c8run's. c8run always runs with its cwd set to its own binary directory
|
|
1357
|
+
* (see startC8Run below), so a relative `import <file>` or
|
|
1358
|
+
* C8RUN_SECRETS_DIR would otherwise resolve against the wrong directory and
|
|
1359
|
+
* silently miss the file the user meant.
|
|
1360
|
+
*
|
|
1361
|
+
* Only touches an `import` positional and C8RUN_SECRETS_DIR; every other
|
|
1362
|
+
* verb and flag passes through untouched. "-" (stdin) and already-absolute
|
|
1363
|
+
* paths are left alone. Never mutates the passthrough array or env object
|
|
1364
|
+
* it receives.
|
|
1365
|
+
*/
|
|
1366
|
+
export function resolveSecretsPaths(passthrough, { cwd = process.cwd(), env = process.env } = {}) {
|
|
1367
|
+
let resolvedPassthrough = passthrough;
|
|
1368
|
+
if (
|
|
1369
|
+
passthrough[0] === 'import' &&
|
|
1370
|
+
passthrough[1] &&
|
|
1371
|
+
passthrough[1] !== '-' &&
|
|
1372
|
+
!isAbsolute(passthrough[1])
|
|
1373
|
+
) {
|
|
1374
|
+
resolvedPassthrough = [...passthrough];
|
|
1375
|
+
resolvedPassthrough[1] = resolve(cwd, passthrough[1]);
|
|
1376
|
+
}
|
|
1377
|
+
|
|
1378
|
+
let resolvedEnv = env;
|
|
1379
|
+
const secretsDir = env.C8RUN_SECRETS_DIR;
|
|
1380
|
+
if (secretsDir && !isAbsolute(secretsDir)) {
|
|
1381
|
+
resolvedEnv = { ...env, C8RUN_SECRETS_DIR: resolve(cwd, secretsDir) };
|
|
1382
|
+
}
|
|
1383
|
+
|
|
1384
|
+
return { passthrough: resolvedPassthrough, env: resolvedEnv };
|
|
1385
|
+
}
|
|
1386
|
+
|
|
1387
|
+
/**
|
|
1388
|
+
* True when a cluster is currently running, returning its version. Requires
|
|
1389
|
+
* both marker files plus a live pidfile — a stale marker with no live
|
|
1390
|
+
* process must not misdirect a secrets call at a version that is not
|
|
1391
|
+
* actually running.
|
|
1392
|
+
*/
|
|
1393
|
+
function runningMarkerVersion(cacheDir) {
|
|
1394
|
+
const markerFile = join(cacheDir, ACTIVE_MARKER_FILE);
|
|
1395
|
+
const versionFile = join(cacheDir, VERSION_MARKER_FILE);
|
|
1396
|
+
if (!existsSync(markerFile) || !existsSync(versionFile)) return null;
|
|
1397
|
+
if (!hasRunningClusterPidfiles(cacheDir)) return null;
|
|
1398
|
+
const version = readFileSync(versionFile, 'utf-8').trim();
|
|
1399
|
+
return version || null;
|
|
1400
|
+
}
|
|
1401
|
+
|
|
1402
|
+
/**
|
|
1403
|
+
* Pick which installed c8run binary should handle a `secrets` passthrough
|
|
1404
|
+
* call. Order: an explicit --c8-version always wins; otherwise prefer the
|
|
1405
|
+
* version currently running (its store is the one actually in effect),
|
|
1406
|
+
* otherwise fall back to the highest locally installed version.
|
|
1407
|
+
*
|
|
1408
|
+
* Never triggers a download — fetching a multi-hundred-MB c8run archive to
|
|
1409
|
+
* run `secrets list` would be a surprising side effect. Returns null when
|
|
1410
|
+
* nothing is installed so the caller can point the user at `cluster install`.
|
|
1411
|
+
*/
|
|
1412
|
+
export async function selectSecretsVersion(cacheDir, { explicit } = {}) {
|
|
1413
|
+
if (explicit) {
|
|
1414
|
+
validateVersionSpec(explicit);
|
|
1415
|
+
return resolveVersion(explicit, { preferLocal: true, cacheDir });
|
|
1416
|
+
}
|
|
1417
|
+
|
|
1418
|
+
const running = runningMarkerVersion(cacheDir);
|
|
1419
|
+
if (running) return running;
|
|
1420
|
+
|
|
1421
|
+
const installed = getInstalledVersionsList(cacheDir)
|
|
1422
|
+
.sort((a, b) => a.localeCompare(b, undefined, { numeric: true }));
|
|
1423
|
+
return installed.length > 0 ? installed[installed.length - 1] : null;
|
|
1424
|
+
}
|
|
1425
|
+
|
|
1426
|
+
/**
|
|
1427
|
+
* Translate c8run's "unsupported operation" failure into an actionable hint
|
|
1428
|
+
* naming the resolved version, instead of leaving the user to guess why a
|
|
1429
|
+
* documented subcommand didn't work. Any other failure — a validation
|
|
1430
|
+
* error, a permission error, and so on — is c8run's own message, already
|
|
1431
|
+
* streamed to stderr as it was produced; this returns null so the caller
|
|
1432
|
+
* does not print anything extra.
|
|
1433
|
+
*/
|
|
1434
|
+
export function mapSecretsFailure(exitCode, stderrTail, version) {
|
|
1435
|
+
if (exitCode === 0) return null;
|
|
1436
|
+
if (!/unsupported operation:\s*secrets/i.test(stderrTail)) return null;
|
|
1437
|
+
|
|
1438
|
+
return (
|
|
1439
|
+
`c8run ${version} does not support "secrets" yet.\n` +
|
|
1440
|
+
`Install a c8run build that includes it, e.g.: c8ctl cluster install ${version}\n` +
|
|
1441
|
+
'Until then, pass secrets as environment variables when starting instead:\n' +
|
|
1442
|
+
' SECRET_MY_KEY=value c8ctl cluster start\n'
|
|
1443
|
+
);
|
|
1444
|
+
}
|
|
1445
|
+
|
|
1446
|
+
/**
|
|
1447
|
+
* Forward a `cluster secrets` call to the resolved c8run binary's own
|
|
1448
|
+
* `secrets` subcommand, unchanged. stdin/stdout/stderr are inherited so the
|
|
1449
|
+
* no-echo prompt, --stdin, and `import -` all behave exactly as they would
|
|
1450
|
+
* calling c8run directly — c8ctl adds no validation and never sees a value.
|
|
1451
|
+
*
|
|
1452
|
+
* `spawnFn`, `cwd`, and `env` are injectable for testing; production calls
|
|
1453
|
+
* rely on their defaults (the real `spawn`, the current process's cwd and
|
|
1454
|
+
* environment).
|
|
1455
|
+
*/
|
|
1456
|
+
export async function runClusterSecrets(
|
|
1457
|
+
cacheDir,
|
|
1458
|
+
tail,
|
|
1459
|
+
{ explicitVersion, spawnFn = spawn, cwd = process.cwd(), env = process.env } = {},
|
|
1460
|
+
) {
|
|
1461
|
+
const logger = getLogger();
|
|
1462
|
+
|
|
1463
|
+
const version = await selectSecretsVersion(cacheDir, { explicit: explicitVersion });
|
|
1464
|
+
if (!version) {
|
|
1465
|
+
logger.error(
|
|
1466
|
+
'No c8run installed locally. Install one first: c8ctl cluster install alpha',
|
|
1467
|
+
);
|
|
1468
|
+
process.exit(1);
|
|
1469
|
+
return;
|
|
1470
|
+
}
|
|
1471
|
+
|
|
1472
|
+
let binaryPath;
|
|
1473
|
+
try {
|
|
1474
|
+
binaryPath = getC8RunBinaryPath({ cacheDir, version });
|
|
1475
|
+
} catch (error) {
|
|
1476
|
+
logger.error(`Failed to run secrets command: ${error.message}`);
|
|
1477
|
+
process.exit(1);
|
|
1478
|
+
return;
|
|
1479
|
+
}
|
|
1480
|
+
|
|
1481
|
+
const { passthrough, env: resolvedEnv } = resolveSecretsPaths(tail, { cwd, env });
|
|
1482
|
+
|
|
1483
|
+
const exitCode = await new Promise((resolvePromise, reject) => {
|
|
1484
|
+
const proc = spawnFn(binaryPath, ['secrets', ...passthrough], {
|
|
1485
|
+
stdio: ['inherit', 'inherit', 'pipe'],
|
|
1486
|
+
cwd: dirname(binaryPath),
|
|
1487
|
+
env: resolvedEnv,
|
|
1488
|
+
});
|
|
1489
|
+
|
|
1490
|
+
let stderrTail = '';
|
|
1491
|
+
proc.stderr?.on('data', (chunk) => {
|
|
1492
|
+
const text = typeof chunk === 'string' ? chunk : chunk.toString('utf-8');
|
|
1493
|
+
process.stderr.write(text);
|
|
1494
|
+
stderrTail = (stderrTail + text).slice(-4096);
|
|
1495
|
+
});
|
|
1496
|
+
|
|
1497
|
+
proc.on('error', (err) => {
|
|
1498
|
+
reject(new Error(`Failed to spawn c8run: ${err.message}`));
|
|
1499
|
+
});
|
|
1500
|
+
proc.on('close', (code) => {
|
|
1501
|
+
const hint = mapSecretsFailure(code ?? 1, stderrTail, version);
|
|
1502
|
+
if (hint) {
|
|
1503
|
+
logger.error(hint);
|
|
1504
|
+
}
|
|
1505
|
+
resolvePromise(code ?? 1);
|
|
1506
|
+
});
|
|
1507
|
+
});
|
|
1508
|
+
|
|
1509
|
+
if (exitCode !== 0) {
|
|
1510
|
+
process.exit(exitCode);
|
|
1511
|
+
}
|
|
1512
|
+
}
|
|
1513
|
+
|
|
1200
1514
|
// ---------------------------------------------------------------------------
|
|
1201
1515
|
// Status
|
|
1202
1516
|
// ---------------------------------------------------------------------------
|
|
@@ -1670,6 +1984,25 @@ const VALID_SUBCOMMANDS = ['start', 'stop', 'status', 'list', 'list-remote', 'in
|
|
|
1670
1984
|
export const commands = {
|
|
1671
1985
|
'cluster': async (args) => {
|
|
1672
1986
|
const logger = getLogger();
|
|
1987
|
+
|
|
1988
|
+
// Secrets passthrough (#314) is intercepted before parsePluginArgs:
|
|
1989
|
+
// its arguments (verbs, flags, positionals) belong to c8run, not to
|
|
1990
|
+
// c8ctl's own version/--debug/--purge parsing.
|
|
1991
|
+
if (args[0] === 'secrets') {
|
|
1992
|
+
let parsedSecrets;
|
|
1993
|
+
try {
|
|
1994
|
+
parsedSecrets = parseSecretsArgs(sliceSecretsArgv(process.argv.slice(2), args));
|
|
1995
|
+
} catch (error) {
|
|
1996
|
+
logger.error(error.message);
|
|
1997
|
+
process.exit(1);
|
|
1998
|
+
return;
|
|
1999
|
+
}
|
|
2000
|
+
await runClusterSecrets(getCacheDir(), parsedSecrets.passthrough, {
|
|
2001
|
+
explicitVersion: parsedSecrets.version,
|
|
2002
|
+
});
|
|
2003
|
+
return;
|
|
2004
|
+
}
|
|
2005
|
+
|
|
1673
2006
|
const parsed = parsePluginArgs(args);
|
|
1674
2007
|
|
|
1675
2008
|
if (!parsed.subcommand || !VALID_SUBCOMMANDS.includes(parsed.subcommand)) {
|
|
@@ -1683,6 +2016,7 @@ export const commands = {
|
|
|
1683
2016
|
console.log(' c8ctl cluster install <version>');
|
|
1684
2017
|
console.log(' c8ctl cluster delete <version>');
|
|
1685
2018
|
console.log(' c8ctl cluster purge <version>');
|
|
2019
|
+
console.log(' c8ctl cluster secrets [--c8-version <version>] <set|list|path|delete|import|...>');
|
|
1686
2020
|
console.log('');
|
|
1687
2021
|
console.log('Subcommands:');
|
|
1688
2022
|
console.log(' start Download (if needed) and start a local Camunda 8 cluster');
|
|
@@ -1694,6 +2028,7 @@ export const commands = {
|
|
|
1694
2028
|
console.log(' install Download a version without starting it');
|
|
1695
2029
|
console.log(' delete Remove a locally cached version to reclaim disk space');
|
|
1696
2030
|
console.log(' purge Delete runtime data for a version (binary stays intact, next start is fresh)');
|
|
2031
|
+
console.log(' secrets Manage local development secrets (forwarded verbatim to c8run)');
|
|
1697
2032
|
console.log('');
|
|
1698
2033
|
console.log('Options:');
|
|
1699
2034
|
console.log(' <version> Camunda version, alias, or major.minor (default: stable)');
|
|
@@ -1728,6 +2063,14 @@ export const commands = {
|
|
|
1728
2063
|
console.log(' c8ctl cluster delete 8.8');
|
|
1729
2064
|
console.log(' c8ctl cluster purge 8.8 # Delete runtime data, keep binary');
|
|
1730
2065
|
console.log(' c8ctl cluster stop --purge # Stop cluster and delete its runtime data');
|
|
2066
|
+
console.log(' c8ctl cluster secrets set OPENAI_API_KEY # Prompts, no-echo; use --stdin for automation');
|
|
2067
|
+
console.log(' c8ctl cluster secrets list');
|
|
2068
|
+
console.log(' c8ctl cluster secrets import .env.secrets');
|
|
2069
|
+
console.log(' c8ctl cluster secrets delete OPENAI_API_KEY --yes');
|
|
2070
|
+
console.log('');
|
|
2071
|
+
console.log('secrets forwards everything after it to c8run\'s own "secrets" command —');
|
|
2072
|
+
console.log('c8ctl never sees or stores a secret value. Run "c8ctl cluster secrets help"');
|
|
2073
|
+
console.log('for c8run\'s own secrets help (--help here belongs to c8ctl).');
|
|
1731
2074
|
return;
|
|
1732
2075
|
}
|
|
1733
2076
|
|