gigadrive 2.16.0 → 2.17.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/dist/index.mjs CHANGED
@@ -9,7 +9,7 @@ import { Effect as Effect29, Layer, LogLevel, Logger } from "effect";
9
9
  // package.json
10
10
  var package_default = {
11
11
  name: "gigadrive",
12
- version: "2.16.0",
12
+ version: "2.17.1",
13
13
  repository: {
14
14
  type: "git",
15
15
  url: "https://github.com/Gigadrive/sdk.git",
@@ -3384,7 +3384,7 @@ var parseInjectFlags = (values) => Effect22.gen(function* () {
3384
3384
  if (domain === "" || name === "" || equals === value.length - 1) {
3385
3385
  return yield* new InvalidMicroVmOptionsError({
3386
3386
  // The entry is not echoed: it may hold the credential.
3387
- message: '--inject must be DOMAIN:HEADER=VALUE, such as "api.openai.com:Authorization=Bearer $OPENAI_API_KEY".'
3387
+ message: '--inject and --inject-file take DOMAIN:HEADER=VALUE, such as "api.openai.com:Authorization=Bearer $OPENAI_API_KEY".'
3388
3388
  });
3389
3389
  }
3390
3390
  rules.set(domain, { ...rules.get(domain), [name]: value.slice(equals + 1) });
@@ -3394,6 +3394,17 @@ var parseInjectFlags = (values) => Effect22.gen(function* () {
3394
3394
  }
3395
3395
  return [...rules].map(([domain, headers]) => ({ domain, headers }));
3396
3396
  });
3397
+ var readInjectRules = (inject, injectFile) => Effect22.gen(function* () {
3398
+ if (Option14.isNone(injectFile)) return yield* parseInjectFlags(inject);
3399
+ const fs = yield* FileSystem8.FileSystem;
3400
+ const content = yield* fs.readFileString(injectFile.value).pipe(
3401
+ Effect22.mapError(
3402
+ () => new InvalidMicroVmOptionsError({ message: `Could not read --inject-file ${injectFile.value}.` })
3403
+ )
3404
+ );
3405
+ const lines = content.split(/\r?\n/).map((line) => line.trim()).filter((line) => line !== "" && !line.startsWith("#"));
3406
+ return yield* parseInjectFlags([...inject, ...lines]);
3407
+ });
3397
3408
  var checkEgressFlags = (denyEgress, allowEgress) => Effect22.gen(function* () {
3398
3409
  if (denyEgress && allowEgress.length > 0) {
3399
3410
  return yield* new InvalidMicroVmOptionsError({
@@ -3424,7 +3435,7 @@ var createInput = (flags) => Effect22.gen(function* () {
3424
3435
  if (badPort !== void 0) {
3425
3436
  return yield* new InvalidMicroVmOptionsError({ message: `--port must be between 1 and 65535 (got ${badPort}).` });
3426
3437
  }
3427
- const inject = yield* parseInjectFlags(flags.inject);
3438
+ const inject = yield* readInjectRules(flags.inject, flags.injectFile);
3428
3439
  if (inject.length > 0 && flags.denyEgress) {
3429
3440
  return yield* new InvalidMicroVmOptionsError({ message: "--inject cannot be combined with --deny-egress." });
3430
3441
  }
@@ -3551,6 +3562,12 @@ var createCommand = Command12.make(
3551
3562
  ),
3552
3563
  Options7.repeated
3553
3564
  ),
3565
+ injectFile: Options7.text("inject-file").pipe(
3566
+ Options7.withDescription(
3567
+ "Read --inject rules from a file, one DOMAIN:HEADER=VALUE per line (/dev/stdin for a pipe), so the values stay out of the command line"
3568
+ ),
3569
+ Options7.optional
3570
+ ),
3554
3571
  pauseOnTimeout: Options7.boolean("pause-on-timeout").pipe(
3555
3572
  Options7.withDescription("Pause the microVM when its timeout ends instead of stopping it")
3556
3573
  ),
@@ -3920,7 +3937,7 @@ var updateMicroVmNetwork = (microvmId, flags) => Effect22.gen(function* () {
3920
3937
  });
3921
3938
  }
3922
3939
  yield* checkEgressFlags(flags.denyEgress, flags.allowEgress);
3923
- const inject = yield* parseInjectFlags(flags.inject);
3940
+ const inject = yield* readInjectRules(flags.inject, flags.injectFile);
3924
3941
  if (inject.length > 0 && flags.denyEgress) {
3925
3942
  return yield* new InvalidMicroVmOptionsError({ message: "--inject cannot be combined with --deny-egress." });
3926
3943
  }
@@ -3967,6 +3984,12 @@ var networkCommand = Command12.make(
3967
3984
  ),
3968
3985
  Options7.repeated
3969
3986
  ),
3987
+ injectFile: Options7.text("inject-file").pipe(
3988
+ Options7.withDescription(
3989
+ "Read --inject rules from a file, one DOMAIN:HEADER=VALUE per line (/dev/stdin for a pipe), so the values stay out of the command line"
3990
+ ),
3991
+ Options7.optional
3992
+ ),
3970
3993
  clearInject: Options7.boolean("clear-inject").pipe(
3971
3994
  Options7.withDescription("Remove every header rule added with --inject")
3972
3995
  )